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

feat: role binding backfill #295

Merged
merged 25 commits into from
Jan 16, 2023
Merged

feat: role binding backfill #295

merged 25 commits into from
Jan 16, 2023

Conversation

james-milligan
Copy link
Contributor

@james-milligan james-milligan commented Jan 12, 2023

This PR

  • backfill the flagd-kubernetes-sync role binding on upgrade

Related Issues

#292

Notes

Follow-up Tasks

This PR expands one of the options for resolving the bug described in the issue above. On startup a grouroutine is started with a 5 second timeout (to allow cache to be ready), and all pods with the openfeature.dev/enabled annotation set to "true" will have their service accounts added to the flagd-kubernetes-sync role binding, restoring its state to that which it was prior to the upgrade.

How to test

Upgrade helm and verify that the flagd connection is reestablished.

Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
config/manager/kustomization.yaml Outdated Show resolved Hide resolved
config/manager/manager.yaml Outdated Show resolved Hide resolved
help.yaml Outdated Show resolved Hide resolved
index.yaml Outdated Show resolved Hide resolved
this.yaml Outdated Show resolved Hide resolved
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
@james-milligan james-milligan marked this pull request as ready for review January 12, 2023 16:22
james-milligan and others added 6 commits January 12, 2023 16:23
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
webhooks/pod_webhook.go Outdated Show resolved Hide resolved
@toddbaert
Copy link
Member

toddbaert commented Jan 12, 2023

@james-milligan I could be missing something, but I still seem to have the issue after an upgrade. Here are the steps I took:

  • checked out main
  • built/pushed my docker image: toddbaert/ofo:main
  • built charts: make build && make helm-package
  • edited rendered.yaml to use toddbaert/ofo:main
  • did helm install ofo . from chart dir
  • deployed workload and verified everything worked

Then I applied the fix:

  • checked out this branch
  • edited Makefile, updating version to v0.2.24
  • built/pushed my docker image: toddbaert/ofo:fix
  • built charts: make build && make helm-package
  • edited rendered.yaml to use toddbaert/ofo:fix
  • did helm upgrade ofo . from chart dir, which upgraded the operator
  • changed a flag value on the workload, saw:
"end-to-end\" is forbidden: User \"s │
│ ystem:serviceaccount:default:default\" cannot get resource \"featureflagconfigurations\" in API group \

Maybe I've somehow tested this fix incorrectly? If so please let me know what I did wrong.

@toddbaert
Copy link
Member

toddbaert commented Jan 12, 2023

@james-milligan

As discussed on on slack, the root cause of my issue was that I was using the old invalid annotation openfeature.dev: "enabled" not openfeature.dev/enabled: "true" (which works as expected).

As you noted, we may want to add support for the deprecated annotation too.

But otherwise, this works as expected. Nice job!

Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
@james-milligan
Copy link
Contributor Author

@james-milligan

As discussed on on slack, the root cause of my issue was that I was using the old invalid annotation openfeature.dev: "enabled" not openfeature.dev/enabled: "true" (which works as expected).

As you noted, we may want to add support for the deprecated annotation too.

But otherwise, this works as expected. Nice job!

Ive added in support for the core.openfeature.dev: "enabled" annotation, as well as expanded the test to include it

Signed-off-by: James Milligan <james@omnant.co.uk>
@codecov-commenter
Copy link

codecov-commenter commented Jan 13, 2023

Codecov Report

Merging #295 (0ea83fc) into main (1eff914) will increase coverage by 0.70%.
The diff coverage is 57.40%.

@@            Coverage Diff             @@
##             main     #295      +/-   ##
==========================================
+ Coverage   50.90%   51.60%   +0.70%     
==========================================
  Files           3        3              
  Lines         444      498      +54     
==========================================
+ Hits          226      257      +31     
- Misses        202      222      +20     
- Partials       16       19       +3     
Impacted Files Coverage Δ
webhooks/pod_webhook.go 65.96% <57.40%> (-1.67%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
webhooks/pod_webhook.go Outdated Show resolved Hide resolved
webhooks/pod_webhook.go Outdated Show resolved Hide resolved
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
main.go Outdated Show resolved Hide resolved
webhooks/pod_webhook.go Outdated Show resolved Hide resolved
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
Signed-off-by: James Milligan <james@omnant.co.uk>
@james-milligan
Copy link
Contributor Author

james-milligan commented Jan 13, 2023

resolved test race condition through introducing a 'complete' channel to the BackfillPermissions method, this is not used in main as the process can happen asynchronously, allowing the mgr.Start(ctx) method to block

Signed-off-by: James Milligan <james@omnant.co.uk>
@james-milligan james-milligan merged commit 04bcf68 into open-feature:main Jan 16, 2023
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.

6 participants