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: call TokenRequest API when service account token secret is missing #3377

Merged
merged 4 commits into from
Sep 12, 2024

Conversation

OchiengEd
Copy link
Contributor

Description of the change:

This pull requests introduces code that will attempt to request a service account token via the TokenRequest API whenever an error is return regarding a missing service account token secret.

Motivation for the change:

Beyond Kubernetes 1.22, the service account token secret is not automatically created. Therefore, unless manually created, the service account token secret is expect to be missing.

As a result, it is necessary to update the Operator Lifecycle manager(OLM) code to account for the above change in the Kubernetes behavior.

Architectural changes:

Testing remarks:

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Bug fixes are accompanied by regression test(s)
  • e2e tests and flake fixes are accompanied evidence of flake testing, e.g. executing the test 100(0) times
  • tech debt/todo is accompanied by issue link(s) in comments in the surrounding code
  • Tests are comprehensible, e.g. Ginkgo DSL is being used appropriately
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive
  • Tests marked as [FLAKE] are truly flaky and have an issue
  • Code is properly formatted

Closes #3376

@openshift-ci openshift-ci bot requested review from anik120 and tmshort August 27, 2024 21:19
@perdasilva
Copy link
Collaborator

P.S. if you rebase, the flake will go away =D

Beyond Kubernetes 1.22, the service account token secret is not
automatically, created. Therefore, when OLM is not able to find the
service account token secret, it should request one from the k8s api
server.

Ref: https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#manual-secret-management-for-serviceaccounts

Signed-off-by: Edmund Ochieng <[email protected]>
Signed-off-by: Edmund Ochieng <[email protected]>
@OchiengEd
Copy link
Contributor Author

@perdasilva All done. You should be good to review

Move the return to line 48. This will ensure a value is returned whether
we successully create a service account token from the TokenRequest API or get an error

Signed-off-by: Edmund Ochieng <[email protected]>
Copy link
Collaborator

@perdasilva perdasilva left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 12, 2024
@perdasilva perdasilva added this pull request to the merge queue Sep 12, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 12, 2024
…ng (#3377)

* fix: call TokenRequest API when service account token secret is missing

Beyond Kubernetes 1.22, the service account token secret is not
automatically, created. Therefore, when OLM is not able to find the
service account token secret, it should request one from the k8s api
server.

Ref: https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#manual-secret-management-for-serviceaccounts

Signed-off-by: Edmund Ochieng <[email protected]>

* fix: return error

Signed-off-by: Edmund Ochieng <[email protected]>

* handle error when creating sa token from TokenRequest API fails

Signed-off-by: Edmund Ochieng <[email protected]>

* move return from inner loop

Move the return to line 48. This will ensure a value is returned whether
we successully create a service account token from the TokenRequest API or get an error

Signed-off-by: Edmund Ochieng <[email protected]>

---------

Signed-off-by: Edmund Ochieng <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 12, 2024
@perdasilva perdasilva added this pull request to the merge queue Sep 12, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 12, 2024
…ng (#3377)

* fix: call TokenRequest API when service account token secret is missing

Beyond Kubernetes 1.22, the service account token secret is not
automatically, created. Therefore, when OLM is not able to find the
service account token secret, it should request one from the k8s api
server.

Ref: https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#manual-secret-management-for-serviceaccounts

Signed-off-by: Edmund Ochieng <[email protected]>

* fix: return error

Signed-off-by: Edmund Ochieng <[email protected]>

* handle error when creating sa token from TokenRequest API fails

Signed-off-by: Edmund Ochieng <[email protected]>

* move return from inner loop

Move the return to line 48. This will ensure a value is returned whether
we successully create a service account token from the TokenRequest API or get an error

Signed-off-by: Edmund Ochieng <[email protected]>

---------

Signed-off-by: Edmund Ochieng <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 12, 2024
@perdasilva perdasilva added this pull request to the merge queue Sep 12, 2024
Merged via the queue into operator-framework:master with commit e20778c Sep 12, 2024
12 checks passed
@OchiengEd OchiengEd deleted the sa_token_req branch September 18, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle missing Service Account Token Secret
3 participants