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

Stop caching constraint status to OPA #313

Merged

Conversation

EmandM
Copy link
Contributor

@EmandM EmandM commented Nov 28, 2019

Signed-off-by: Emma McMillan emma.mcmillan@microsoft.com

Fixes #272

Emma McMillan added 2 commits November 27, 2019 16:49
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")
Copy link
Contributor

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>
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

@maxsmythe maxsmythe merged commit 1542b46 into open-policy-agent:master Nov 28, 2019
@@ -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 {
Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

@EmandM EmandM deleted the feature/advanced-constraint-cache branch December 4, 2019 20:16
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.

Do not cache status field of constraints
3 participants