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
hypershift dump: use random local port for kas port-forwarding #2625
Conversation
/area cli |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: csrwng 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 |
@@ -120,16 +123,31 @@ func dumpGuestCluster(ctx context.Context, opts *DumpOptions) error { | |||
return fmt.Errorf("failed to create tempfile for kubeconfig: %w", err) | |||
} | |||
defer func() { | |||
if err := kubeconfigFile.Close(); err != nil { | |||
opts.Log.Error(err, "Failed to close kubeconfig file") | |||
} |
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.
why move this?
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.
Because we should have closed it before invoking the oc
command to use it. It's a bug that we're waiting for the end of the function to close it.
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.
Yeah I'm with Seth.. I'd be concerned there's no guarantee of a Close() here before we call the Exec() of oc using this file. With this change you're depending on garbage collection to close the file.. not sure it's guaranteed to happen right away.
5ec381e
to
5eedc8d
Compare
cmd/cluster/core/dump.go
Outdated
if err := kubeconfigFile.Close(); err != nil { | ||
log.Error(err, "Failed to close temporary kubeconfig file") | ||
} | ||
if err := os.Remove(kubeconfigFile.Name()); err != nil { |
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.
isn't this going to remove the kubeconfig file before DumpGuestCluster()
can use it?
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.
true :(
When executing multiple 'cluster dump' within the same pod (as in the e2e case), only one run can listen on port 6443 and the others fail. This changes the dump command to use a random port locally so that different runs do not conflict.
/lgtm |
/retest-required |
@csrwng: The following test failed, say
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/test-infra repository. I understand the commands that are listed here. |
What this PR does / why we need it:
When executing multiple 'cluster dump' within the same pod (as in the e2e case), only one run can listen on port 6443 and the others fail. This changes the dump command to use a random port locally so that different runs do not conflict.
Checklist