Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ResourceExport's json tag as lowerCamelCase #4211

Merged
merged 1 commit into from
Sep 10, 2022

Conversation

luolanzone
Copy link
Contributor

@luolanzone luolanzone commented Sep 7, 2022

Change ResourceExport's json tag to lowerCamelCase. After
antrea-mc-controller is upgraded from an older version to a version
with this change, it will get an empty spec for an existing existing
ResourceExport/ResourceImport of type ClusterInfo or
ClusterNetworkPolicy type, so we add code to skip importing any
ResoureImport if it doesn't have a valid spec.

Signed-off-by: Lan Luo [email protected]

@luolanzone luolanzone added the area/multi-cluster Issues or PRs related to multi cluster. label Sep 7, 2022
@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e

@codecov
Copy link

codecov bot commented Sep 7, 2022

Codecov Report

Merging #4211 (b5dc762) into main (264aefa) will increase coverage by 3.16%.
The diff coverage is 93.33%.

❗ Current head b5dc762 differs from pull request most recent head d62a4ca. Consider uploading reports for the commit d62a4ca to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4211      +/-   ##
==========================================
+ Coverage   58.30%   61.47%   +3.16%     
==========================================
  Files         384      395      +11     
  Lines       54376    54447      +71     
==========================================
+ Hits        31702    33469    +1767     
+ Misses      20257    18511    -1746     
- Partials     2417     2467      +50     
Flag Coverage Δ *Carryforward flag
e2e-tests 56.08% <0.00%> (?)
integration-tests 34.78% <0.00%> (+0.04%) ⬆️ Carriedforward from 2ce2ef0
kind-e2e-tests 47.78% <85.71%> (+6.42%) ⬆️ Carriedforward from 2ce2ef0
unit-tests 42.92% <66.66%> (+0.98%) ⬆️ Carriedforward from 2ce2ef0

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
...apis/multicluster/v1alpha1/resourceexport_types.go 100.00% <ø> (ø)
...llers/multicluster/leader_clusterset_controller.go 77.39% <ø> (+21.35%) ⬆️
...rs/multicluster/commonarea/clusterinfo_importer.go 77.96% <75.00%> (+14.13%) ⬆️
...uster/commonarea/acnp_resourceimport_controller.go 62.09% <100.00%> (-6.66%) ⬇️
...lowaggregator/clickhouseclient/clickhouseclient.go 80.48% <100.00%> (+6.89%) ⬆️
pkg/flowaggregator/exporter/clickhouse.go 78.26% <100.00%> (+23.91%) ⬆️
pkg/controller/networkpolicy/tier.go 50.00% <0.00%> (-5.00%) ⬇️
pkg/controller/grouping/controller.go 65.13% <0.00%> (-1.98%) ⬇️
...gent/controller/noderoute/node_route_controller.go 57.54% <0.00%> (-1.87%) ⬇️
... and 87 more

Change ResourceExport's json tag to lowerCamelCase.
Since any existing ResourceExport/ResourceImport's spec will be empty
if it's ClusterInfo or ClusterNetworkPolicy type after this change,
add a few steps to skip importing any ResoureImport if it doesn't
have valid spec.

Signed-off-by: Lan Luo <[email protected]>
@@ -43,6 +43,10 @@ var (
)

func (r *ResourceImportReconciler) handleResImpUpdateForClusterNetworkPolicy(ctx context.Context, resImp *multiclusterv1alpha1.ResourceImport) (ctrl.Result, error) {
if resImp.Spec.ClusterNetworkPolicy == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions:

  1. Do we need this check for ResourceExport reconcilers too?
  2. But what will happen if this ResourceImport was not processed before mc-controller upgrade? After such change, we should either recreate all impacted resources or support old version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can skip reconciling ResourceExport if spec is empty, but the main purpose of this change is to avoid controller crash for any existing ResourceImport with empty spec. When users deploy latest manifest with this change, the existing ResourceImport spec will become empty due to mismatch json tag.
When users upgrade all member and leader clusters, they need to restart controller manually, then all impacted resources will be updated automatically because ResourceExports will be updated by member controllers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking maybe we can add an empty line in the config file so that the ConfigMap checksum annotation can be updated. In this case, user don't have to restart controller manually. Deployment will be updated and restarted automatically due to annotation change. What's your thought?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After upgrading from 1.8.0 to 1.9.0 which includes this change, mc-controller will be restarted. Why manual restart is required? But could you confirm in the current implementation, mc-controller will update all existing ResourceExports after restart? Could you verify that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes, you are right. For this standalone PR, the manifest change is for CRD part only, so controller won't be restarted. But for a new release 1.9, mc-controller will be restarted.
I verified this locally, when the leader CRD is updated, the spec of existing ResourceExport will be empty, but it will be updated soon after member controller restart since there are difference between new ResourceExport and existing one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, will ResourceImport be recreated too? How about imported resources in the member cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The corresponding ResourceImport will be updated, then the member controller will be notified and handles the update event properly to refresh imported resources.

@jianjuns
Copy link
Contributor

jianjuns commented Sep 9, 2022

/test-multicluster-e2e
/skip-all

@jianjuns jianjuns merged commit ede7626 into antrea-io:main Sep 10, 2022
@luolanzone luolanzone deleted the update-resourceexport-tags branch September 16, 2022 02:29
heanlan pushed a commit to heanlan/antrea that referenced this pull request Mar 29, 2023
Change ResourceExport's json tag to lowerCamelCase. After
antrea-mc-controller is upgraded from an older version to a version
with this change, it will get an empty spec for an existing existing
ResourceExport/ResourceImport of type ClusterInfo or
ClusterNetworkPolicy type, so we add code to skip importing any
ResoureImport if it doesn't have a valid spec.

Signed-off-by: Lan Luo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/multi-cluster Issues or PRs related to multi cluster.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants