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

chore: adding annotation to generate VAPB right away once the waiting window is over to protect against clock skews #3773

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

JaydipGabani
Copy link
Contributor

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Fixes #3683

Special notes for your reviewer:

@JaydipGabani JaydipGabani requested a review from a team as a code owner January 11, 2025 02:06
@codecov-commenter
Copy link

codecov-commenter commented Jan 11, 2025

Codecov Report

Attention: Patch coverage is 56.25000% with 14 lines in your changes missing coverage. Please review.

Project coverage is 47.76%. Comparing base (3350319) to head (c8602fc).
Report is 245 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controller/constraint/constraint_controller.go 0.00% 13 Missing ⚠️
...onstrainttemplate/constrainttemplate_controller.go 94.73% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (3350319) and HEAD (c8602fc). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3350319) HEAD (c8602fc)
unittests 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3773      +/-   ##
==========================================
- Coverage   54.49%   47.76%   -6.74%     
==========================================
  Files         134      235     +101     
  Lines       12329    19865    +7536     
==========================================
+ Hits         6719     9488    +2769     
- Misses       5116     9488    +4372     
- Partials      494      889     +395     
Flag Coverage Δ
unittests 47.76% <56.25%> (-6.74%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM with one nit

@@ -65,9 +65,12 @@ import (

const (
BlockVAPBGenerationUntilAnnotation = "gatekeeper.sh/block-vapb-generation-until"
VAPBGenerationAnnotation = "gatekeeper.sh/vapb-generation"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: vapb-generation-lock or similar to more clearly specify intent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about vapb-generation-state?

@JaydipGabani JaydipGabani requested a review from a team January 22, 2025 22:07
Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -745,6 +747,9 @@ func TestReconcile(t *testing.T) {
if vapBindingCreationTime.Before(blockTime) {
return fmt.Errorf("VAPBinding should be created after default wait")
}
if ct.GetAnnotations()[constraint.VAPBGenerationAnnotation] == constraint.VAPBGenerationUnblocked {
return fmt.Errorf("expected %s annotations on CT to be unblocked", constraint.VAPBGenerationAnnotation)
Copy link
Member

Choose a reason for hiding this comment

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

shouldnt the expected to be the opposite?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed test

@@ -873,6 +881,9 @@ func TestReconcile(t *testing.T) {
if vapBindingCreationTime.Before(blockTime) {
return fmt.Errorf("VAPBinding should not be created before the timestamp")
}
if ct.GetAnnotations()[constraint.VAPBGenerationAnnotation] == constraint.VAPBGenerationUnblocked {
return fmt.Errorf("expected %s annotations on CT to be unblocked", constraint.VAPBGenerationAnnotation)
}
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the test

Copy link
Member

Choose a reason for hiding this comment

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

Did the tests fail before you updated this test logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but in that case the condition was not evaluating to true (due to CT reconciler being slightly slow to update the annotation than constraint controller in creating vapb once the "time window" is crossed) so the error was not being returned.

… is over to protect against clock skews

Signed-off-by: Jaydip Gabani <[email protected]>
Signed-off-by: Jaydip Gabani <[email protected]>
@JaydipGabani JaydipGabani requested a review from ritazh January 27, 2025 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add non-clock-dependent annotation for VAPB generation
5 participants