-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Fixed TestGetStoragev1 failure in windows #21738
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
base: master
Are you sure you want to change the base?
Fixed TestGetStoragev1 failure in windows #21738
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bobsira 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 |
Hi @bobsira. 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 Once the patch is verified, the new status will be reflected by the 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-sigs/prow repository. |
Can one of the admins verify this patch? |
return fmt.Errorf("Unexpected error when writing to file %v. Error: %v", kubeconfigPath, err) | ||
if err := os.MkdirAll(filepath.Dir(kubeconfigPath), 0o755); err != nil { | ||
return fmt.Errorf("failed to create kubeconfig directory: %w", 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.
We don't need to create a directory since we use t.TempDir(), which creates a new directory on every call.
return fmt.Errorf("unexpected error when writing to %v: %w", kubeconfigPath, err) | ||
} | ||
t.Setenv("KUBECONFIG", mockK8sConfigPath) | ||
t.Setenv("KUBECONFIG", kubeconfigPath) |
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.
This is really bad and not thread safe. We should never set the env since it is process level value and we may have several tests running in the same time that may use the wrong KUBECONFIG. Since this issue was not introduced by your change we can improve it later.
return fmt.Errorf("failed to create kubeconfig directory: %w", err) | ||
} | ||
if err := os.WriteFile(kubeconfigPath, []byte(config), 0o644); err != nil { | ||
return fmt.Errorf("unexpected error when writing to %v: %w", kubeconfigPath, 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.
We should really call t.Fatalf() here instead of returning an error, but since this issue was not introduced by your change we can improve it later.
Summary of fix