Skip to content

Conversation

bobsira
Copy link

@bobsira bobsira commented Oct 13, 2025

Summary of fix

  • Removed hard-coded /tmp usage that broke on Windows.
  • Each subtest in TestGetStoragev1 now creates its own temp directory via t.TempDir() and builds kubeconfig path with filepath.Join (cross-platform).
  • Helper setK8SConfig ensures the parent dir exists (os.MkdirAll) and writes the config, then sets KUBECONFIG.
  • Per-subtest isolation eliminates shared file/state, avoids cleanup code, and works on all OSes.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 13, 2025
@k8s-ci-robot k8s-ci-robot requested a review from medyagh October 13, 2025 11:39
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bobsira
Once this PR has been reviewed and has the lgtm label, please assign comradeprogrammer for approval. For more information see the 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

@k8s-ci-robot k8s-ci-robot requested a review from prezha October 13, 2025 11:39
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 13, 2025
@k8s-ci-robot
Copy link
Contributor

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 /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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 13, 2025
@minikube-bot
Copy link
Collaborator

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)
}
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants