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 failed token deletion #194

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rev3r4nt
Copy link

Randomly, the openshift_auth module exits in error and does not delete the token.

Couldn't delete user oauth access token 'sha256~BmhQbi0TLPGJqA15PdLbbfJesJlQX_208Iv9saVpU2U' due to: useroauthaccesstokens.oauth.openshift.io \"sha256~BmhQbi0TLPGJqA15PdLbbfJesJlQX_208Iv9saVpU2U\" not found

When this happens, the token name does not match the one returned by the Openshift API.

$ oc get useroauthaccesstokens
NAME                                                 CLIENT NAME
sha256~CZMJTLYVJAyDWZ4JvOrE48J97xpn0HIstFSDT3yHyWM   openshift-challenging-client

Ansible version: core 2.15.3
Python version: 3.10.8
Collection community.okd version 2.3.0

I discovered that it failed because Python strip method argument is not a prefix or suffix; rather, all combinations of its values are stripped. So if the token begins with a character of the set sha256~, the token name is not correctly deducted.

@openshift-ci openshift-ci bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 11, 2023
@openshift-ci
Copy link

openshift-ci bot commented Sep 11, 2023

Hi @rev3r4nt. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -222,7 +222,7 @@ def get_oauthaccesstoken_objectname_from_token(token_name):
"""

sha256Prefix = "sha256~"
content = token_name.strip(sha256Prefix)
content = token_name[len(sha256Prefix):]
Copy link
Member

Choose a reason for hiding this comment

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

We should only slice if the string starts with the prefix:

if token_name.startswith(sha256Prefix):
    content = token_name[len(sha256Prefix):]
else:
    content = token_name

@gravesm
Copy link
Member

gravesm commented Sep 11, 2023

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 11, 2023
@rev3r4nt
Copy link
Author

/retest

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 12, 2023
@openshift-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 11, 2024
@gravesm
Copy link
Member

gravesm commented Jan 17, 2024

/remove-lifecycle rotten

@openshift-ci openshift-ci bot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jan 17, 2024
@HaleCT2
Copy link

HaleCT2 commented Mar 20, 2024

Would love to see this fixed - Using this module with AAP/ACM, it's frustrating having an Automation Template Job fail at the "logout" task randomly

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 19, 2024
@HaleCT2
Copy link

HaleCT2 commented Jun 21, 2024

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 21, 2024
@seanmalloy
Copy link

/retest

@seanmalloy
Copy link

seanmalloy commented Jun 21, 2024

@rev3r4nt I see the CI automation failed previously. I've re-triggered the failing tests. Are you still interested in having this change merged?

@seanmalloy
Copy link

seanmalloy commented Jun 21, 2024

@gravesm and @alinabuzachis the two required CI checks are now passing. Would you have time to review? Is there anything else needed?

/assign @gravesm @alinabuzachis

Copy link

openshift-ci bot commented Jun 21, 2024

@seanmalloy: changing LGTM is restricted to collaborators

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@gravesm gravesm force-pushed the fix_failed_to_delete_token branch from acc848d to 41600d5 Compare June 24, 2024 18:04
Copy link

openshift-ci bot commented Jun 24, 2024

@seanmalloy: changing LGTM is restricted to collaborators

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

openshift-ci bot commented Jun 24, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rev3r4nt, seanmalloy
Once this PR has been reviewed and has the lgtm label, please ask for approval from alinabuzachis. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

openshift-ci bot commented Jun 24, 2024

@rev3r4nt: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@seanmalloy
Copy link

@gravesm and @alinabuzachis is there anything else needed before this can be merged?

@gravesm
Copy link
Member

gravesm commented Jul 2, 2024

@seanmalloy The sanity checks need to pass, but I haven't had time to look into why they're failing. It's likely nothing to do with this PR and is probably some config issue with CI. Will try to get to it as soon as I can.

@alinabuzachis
Copy link
Contributor

@seanmalloy Can you please fix the indentation?

ERROR: Found 2 pep8 issue(s) which need to be resolved:
--
970 | 2024-06-24 18:20:05.525014 \| controller \| ERROR: plugins/modules/openshift_auth.py:228:7: E111: indentation is not a multiple of 4
971 | 2024-06-24 18:20:05.525054 \| controller \| ERROR: plugins/modules/openshift_auth.py:230:7: E111: indentation is not a multiple of 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants