-
Notifications
You must be signed in to change notification settings - Fork 769
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: upgrading to 0.30 api, creating v1 or v1beta1 VAP/VAPB #3472
Changes from 2 commits
4d3f669
9298580
f43b6bf
9f58850
ef94027
f6b9ebe
c5793ea
3a0eede
bb19964
f8791e6
1dff1e5
de48c99
1e26786
ed5c510
fe4998e
3a77ea3
a63f998
6cb62fa
7e39997
f3a4977
2f0b758
5b3ffa0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,7 +357,7 @@ func (r *ReconcileConstraint) Reconcile(ctx context.Context, request reconcile.R | |
return reconcile.Result{}, err | ||
} | ||
|
||
newVapBinding, err := r.getRunTimeVAPBinding(groupVersion, transformedVapBinding, currentVapBinding) | ||
newVapBinding, err := getRunTimeVAPBinding(groupVersion, transformedVapBinding, currentVapBinding) | ||
if err != nil { | ||
status.Status.Errors = append(status.Status.Errors, constraintstatusv1beta1.Error{Message: err.Error()}) | ||
if err2 := r.writer.Update(ctx, status); err2 != nil { | ||
|
@@ -629,6 +629,13 @@ func (c *ConstraintsCache) reportTotalConstraints(ctx context.Context, reporter | |
} | ||
|
||
func IsVapAPIEnabled() (bool, *schema.GroupVersion) { | ||
vapMux.RLock() | ||
if VapAPIEnabled != nil { | ||
vapMux.RUnlock() | ||
return *VapAPIEnabled, GroupVersion | ||
} | ||
|
||
vapMux.RUnlock() | ||
vapMux.Lock() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want to have an RWMutex here to enable parallelism in the future. This is especially true because this function is being called by two different reconcilers (constraint/constraint template). General pattern:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added read lock |
||
defer vapMux.Unlock() | ||
|
||
|
@@ -692,7 +699,7 @@ func vapBindingForVersion(gvk schema.GroupVersion) (client.Object, error) { | |
} | ||
} | ||
|
||
func (r *ReconcileConstraint) getRunTimeVAPBinding(gvk *schema.GroupVersion, transformedVapBinding *admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, currentVapBinding client.Object) (client.Object, error) { | ||
func getRunTimeVAPBinding(gvk *schema.GroupVersion, transformedVapBinding *admissionregistrationv1beta1.ValidatingAdmissionPolicyBinding, currentVapBinding client.Object) (client.Object, error) { | ||
if currentVapBinding == nil { | ||
if gvk.Version == "v1" { | ||
return v1beta1ToV1(transformedVapBinding) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For strict correctness, you should only access the variable while it's under a read lock. Suggest using intermediate variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added local variables for strict correctness.