-
Notifications
You must be signed in to change notification settings - Fork 38
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
bugfix: make sure ns exsit when create velero secret #426
Conversation
Signed-off-by: Xieql <xieqianglong@huawei.com>
✅ Deploy Preview for kurator-dev canceled.
|
@@ -210,9 +212,28 @@ func createNewSecretInFleetCluster(cluster *fleetCluster, newSecret *corev1.Secr | |||
// Get the namespace of the secret | |||
namespace := newSecret.Namespace | |||
|
|||
// Check if namespace exists | |||
_, err := kubeClient.CoreV1().Namespaces().Get(context.TODO(), namespace, metav1.GetOptions{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: reuse karmadautil.EnsureNamespaceExist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we should add plugin name in the logs, this can be in following pr
return fmt.Errorf("failed to check for namespace %s: %w", namespace, err) | ||
} | ||
} | ||
|
||
// Create the new secret | ||
if _, err := kubeClient.CoreV1().Secrets(namespace).Create(context.TODO(), newSecret, metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate creating secret, though you have checked alkready exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hzxuzhonghu 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 |
In response to a cherrypick label: new pull request created: #429 |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Ensures namespace exists in the target cluster before creating secrets, preventing potential failures.
Adds logic to check for namespace existence and creates it if missing, prior to secret creation.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: