-
Notifications
You must be signed in to change notification settings - Fork 779
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
Stop caching constraint status to OPA #313
Stop caching constraint status to OPA #313
Conversation
Signed-off-by: Emma McMillan <emma.mcmillan@microsoft.com>
func (r *ReconcileConstraint) cacheConstraint(instance *unstructured.Unstructured) error { | ||
obj := instance.DeepCopy() | ||
// Remove the status field since we do not need it for OPA | ||
unstructured.RemoveNestedField(obj.Object, "status", "byPod") |
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.
We can remove all of status
Signed-off-by: Emma McMillan <emma.mcmillan@microsoft.com>
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.
LGTM
@@ -127,7 +127,7 @@ func (r *ReconcileConstraint) Reconcile(request reconcile.Request) (reconcile.Re | |||
if err = util.SetHAStatus(instance, status); err != nil { | |||
return reconcile.Result{}, err | |||
} | |||
if _, err := r.opa.AddConstraint(context.Background(), instance); err != nil { | |||
if err := r.cacheConstraint(instance); err != nil { |
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.
I don't think err needs to be instantiated here. linter should have caught this.
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.
Doesn't need to be but valid if it is. If instantiated it avoids clobbering whatever err was in the outer scope.
Does linter complain when you run it locally?
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.
No complaints when run locally for me.
Signed-off-by: Emma McMillan emma.mcmillan@microsoft.com
Fixes #272