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

UpdateOrCreateToken get secrets err handling optimization #115000

Conversation

helen-frank
Copy link
Contributor

Signed-off-by: helen haitao.zhang@daocloud.io

What type of PR is this?

/kind feature

What this PR does / why we need it:

when UpdateOrCreateToken get secrets, if the error is not a NotFound, the error is thrown in time

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 12, 2023
@k8s-ci-robot k8s-ci-robot added sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 12, 2023
@k8s-ci-robot
Copy link
Contributor

@helen-frank: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot
Copy link
Contributor

Hi @helen-frank. Thanks for your PR.

I'm waiting for a kubernetes 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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 12, 2023
@pacoxu
Copy link
Member

pacoxu commented Jan 12, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot 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 Jan 12, 2023
@helen-frank
Copy link
Contributor Author

/retest

@@ -43,6 +44,8 @@ func UpdateOrCreateTokens(client clientset.Interface, failIfExists bool, tokens
secret, err := client.CoreV1().Secrets(metav1.NamespaceSystem).Get(context.TODO(), secretName, metav1.GetOptions{})
if secret != nil && err == nil && failIfExists {
return errors.Errorf("a token with id %q already exists", token.Token.ID)
} else if err != nil && !apierrors.IsNotFound(err) {
return err
Copy link
Member

Choose a reason for hiding this comment

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

can this be written like this?

	if err != nil && !apierrors.IsNotFound(err) {
		return err
	}	
	if secret != nil && failIfExists {
		return errors.Errorf("a token with id %q already exists", token.Token.ID)
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it, thanks

@neolit123
Copy link
Member

when UpdateOrCreateToken get secrets, if the error is not a NotFound, the error is thrown in time

can you explain in more detail what errors you are seeing and under what conditions?

…, the error is thrown in time

Signed-off-by: helen <haitao.zhang@daocloud.io>
@helen-frank helen-frank force-pushed the feature/UpdateOrCreateTokenAddErrProcessing branch from 8fb1f8e to e6591d2 Compare January 12, 2023 12:50
@helen-frank
Copy link
Contributor Author

when UpdateOrCreateToken get secrets, if the error is not a NotFound, the error is thrown in time

can you explain in more detail what errors you are seeing and under what conditions?

This is not a bug, this kind of treatment is to deal with the error in time, not to continue no matter what the error is.

@helen-frank helen-frank requested review from neolit123 and removed request for pacoxu and RA489 January 12, 2023 12:54
@helen-frank
Copy link
Contributor Author

/retest

1 similar comment
@helen-frank
Copy link
Contributor Author

/retest

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

/approve

i think this is safe to change, if we don't retry the API calls (wrap UpdateOrCreateTokens in a retry loop?)
i could not find any cases in the kubeadm code that do the retries.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: helen-frank, neolit123

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 12, 2023
@helen-frank
Copy link
Contributor Author

/approve

i think this is safe to change, if we don't retry the API calls (wrap UpdateOrCreateTokens in a retry loop?) i could not find any cases in the kubeadm code that do the retries.

Is a good idea, maybe I can add a concurrent processing to it, what do you think
If you think this is feasible, I can do this job as soon as possible.

@neolit123
Copy link
Member

Is a good idea, maybe I can add a concurrent processing to it, what do you think
If you think this is feasible, I can do this job as soon as possible.

no i think we should keep it the way it is, right now.
we don't have much concurrent code in kubeadm.

@helen-frank
Copy link
Contributor Author

Is a good idea, maybe I can add a concurrent processing to it, what do you think
If you think this is feasible, I can do this job as soon as possible.

no i think we should keep it the way it is, right now. we don't have much concurrent code in kubeadm.

Got it, I will do it as soon as possible to retry the development of logic.

@neolit123
Copy link
Member

Got it, I will do it as soon as possible to retry the development of logic.

i meant we should probably keep it the way it is for now without retry.
if we decide to add retry to this code, ideally it should follow some of the existing retry patterns.

perhaps for a separate PR.

@helen-frank
Copy link
Contributor Author

/cc @pacoxu

@nameYULI
Copy link

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 13, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 179d3f3697ea90bba76b24fb2f8af4bda93f72aa

@k8s-ci-robot k8s-ci-robot merged commit a66aad2 into kubernetes:master Jan 13, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.27 milestone Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants