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

fix: retries for policies cm comprised of multiple dependent file #163

Merged
merged 3 commits into from
Jun 21, 2022

Conversation

eshepelyuk
Copy link
Contributor

@eshepelyuk eshepelyuk commented Jun 11, 2022

This fixes an error when loading multiple policy files from a single config map.
kube-mgmt is sorting config map keys so it may happen that some files ( like a.rego ) is loaded before it's dependencies.
Since config map is not modified anymore - the policy is kept unloaded, although it's completely correct.

A simple retry is completely fixing the issue, since just another load may be successful because the dependencies (functions) were already loaded

---
kind: ConfigMap
metadata:
  name: multi-file-policy
  labels:
    kube-mgmt/e2e: "true"
    openpolicyagent.org/policy: rego
apiVersion: v1
data:
  a.rego: |
    package my_pkg
    import data.my_pkg.functions.my_func
    default my_rule := false
    my_rule {
      my_func(input.hello)
    }
  b.rego: |
    package my_pkg.functions
    my_func(str) := startswith("world", str)

Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

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

Code looks good to me, but there's no description or issue linked, so it's a bit hard to know what this solves.

@eshepelyuk
Copy link
Contributor Author

Code looks good to me, but there's no description or issue linked, so it's a bit hard to know what this solves.

I am sorry. I should have put it to draft for now.
will update description later.

@eshepelyuk eshepelyuk marked this pull request as draft June 13, 2022 08:36
@eshepelyuk eshepelyuk force-pushed the fix/policy-update branch 4 times, most recently from 4b84472 to 6f4208c Compare June 15, 2022 12:02
@eshepelyuk eshepelyuk changed the title Fix/policy update fix: retries for policies cm comprised of multiple dependent file Jun 15, 2022
@eshepelyuk eshepelyuk marked this pull request as ready for review June 15, 2022 12:07
@eshepelyuk eshepelyuk force-pushed the fix/policy-update branch 5 times, most recently from 58d59b5 to 508559e Compare June 21, 2022 17:24
@eshepelyuk eshepelyuk merged commit 2ae02bd into master Jun 21, 2022
@eshepelyuk eshepelyuk deleted the fix/policy-update branch January 26, 2023 05:04
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.

2 participants