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

Add retry to update NetworkPolicy status #3134

Merged
merged 1 commit into from Jan 6, 2022

Conversation

Jexf
Copy link
Member

@Jexf Jexf commented Dec 14, 2021

To reslove the conflict problem in updating NetworkPolicy status
process, add a retry logic in updating NetworkPolicy status function.

Fixes: #3133

Signed-off-by: Wu zhengdong zhengdong.wu@transwarp.io

@Jexf
Copy link
Member Author

Jexf commented Dec 14, 2021

/test-all

@codecov-commenter
Copy link

codecov-commenter commented Dec 14, 2021

Codecov Report

Merging #3134 (442af62) into main (a5114e7) will increase coverage by 17.92%.
The diff coverage is 32.14%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #3134       +/-   ##
===========================================
+ Coverage   40.35%   58.28%   +17.92%     
===========================================
  Files         167      295      +128     
  Lines       20879    24927     +4048     
===========================================
+ Hits         8426    14528     +6102     
+ Misses      11632     8818     -2814     
- Partials      821     1581      +760     
Flag Coverage Δ
kind-e2e-tests 44.57% <32.14%> (?)
unit-tests 40.31% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/controller/networkpolicy/status_controller.go 65.89% <32.14%> (+16.87%) ⬆️
pkg/apiserver/handlers/webhook/convert_crd.go 2.56% <0.00%> (ø)
pkg/apiserver/handlers/webhook/mutation_labels.go 24.71% <0.00%> (ø)
...ed/typed/security/v1alpha1/clusternetworkpolicy.go 24.09% <0.00%> (ø)
...t/informers/externalversions/security/interface.go 100.00% <0.00%> (ø)
...s/externalversions/core/v1alpha2/externalentity.go 64.28% <0.00%> (ø)
...et/versioned/typed/system/v1beta1/system_client.go 45.45% <0.00%> (ø)
pkg/apiserver/handlers/loglevel/handler.go 0.00% <0.00%> (ø)
...ormers/externalversions/core/v1alpha2/interface.go 100.00% <0.00%> (ø)
pkg/legacyclient/listers/security/v1alpha1/tier.go 9.09% <0.00%> (ø)
... and 233 more

@Jexf
Copy link
Member Author

Jexf commented Dec 14, 2021

/test-all

@Jexf
Copy link
Member Author

Jexf commented Dec 14, 2021

/test-integration

@Jexf Jexf added the area/network-policy Issues or PRs related to network policies. label Dec 16, 2021
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

Thanks for making the code more robust. I'd like to know @antoninbas's opinion on the change of the metrics' meaning.

return err
}
klog.V(2).InfoS("Updated Antrea NetworkPolicy", "NetworkPolicy", klog.KObj(toUpdate))
metrics.AntreaNetworkPolicyStatusUpdates.Inc()
Copy link
Member

Choose a reason for hiding this comment

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

@antoninbas do you think it's ok to count successful updates only? Before it counted the number of status update attempt regardless of result.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am ok with the change. I think if this is responsible for causing heavy load on the apiserver and etcd, the metric will still reflect that.

@tnqn
Copy link
Member

tnqn commented Dec 16, 2021

s/reslove/resolve/

To resolve the conflict problem in updating NetworkPolicy status
process, add a retry logic in updating NetworkPolicy status function.

Signed-off-by: Wu zhengdong <zhengdong.wu@transwarp.io>
@Jexf
Copy link
Member Author

Jexf commented Dec 16, 2021

s/reslove/resolve/

@tnqn Thanks for the review, updated.

@Jexf
Copy link
Member Author

Jexf commented Dec 16, 2021

/test-all

@Jexf Jexf requested a review from tnqn January 6, 2022 11:54
@tnqn
Copy link
Member

tnqn commented Jan 6, 2022

/skip-all

2 similar comments
@tnqn
Copy link
Member

tnqn commented Jan 6, 2022

/skip-all

@tnqn
Copy link
Member

tnqn commented Jan 6, 2022

/skip-all

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn tnqn merged commit f6a102a into antrea-io:main Jan 6, 2022
@Jexf Jexf deleted the fix-update-status branch January 10, 2022 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/network-policy Issues or PRs related to network policies.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need add retry to udpate NetworkPolicy status
4 participants