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

hypershift dump: use random local port for kas port-forwarding #2625

Merged
merged 1 commit into from Jun 1, 2023

Conversation

csrwng
Copy link
Contributor

@csrwng csrwng commented May 30, 2023

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

  • Subject and description added to both, commit and PR.

@csrwng
Copy link
Contributor Author

csrwng commented May 30, 2023

/area cli

@openshift-ci openshift-ci bot added area/cli Indicates the PR includes changes for CLI and removed do-not-merge/needs-area labels May 30, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 30, 2023

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 30, 2023
@@ -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")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

why move this?

Copy link
Contributor Author

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.

Copy link
Contributor

@imain imain May 30, 2023

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.

@csrwng csrwng force-pushed the fix_cluster_dump branch 2 times, most recently from 5ec381e to 5eedc8d Compare May 31, 2023 14:17
if err := kubeconfigFile.Close(); err != nil {
log.Error(err, "Failed to close temporary kubeconfig file")
}
if err := os.Remove(kubeconfigFile.Name()); err != nil {
Copy link
Contributor

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?

Copy link
Contributor Author

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.
@sjenning
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 31, 2023
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 1f65d64 and 2 for PR HEAD 95ab72f in total

@csrwng
Copy link
Contributor Author

csrwng commented May 31, 2023

/retest-required

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 1, 2023

@csrwng: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-kubevirt-aws-ovn 95ab72f link false /test e2e-kubevirt-aws-ovn

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.

@openshift-merge-robot openshift-merge-robot merged commit c5ea887 into openshift:main Jun 1, 2023
10 of 11 checks passed
@csrwng csrwng deleted the fix_cluster_dump branch July 14, 2023 19:34
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/cli Indicates the PR includes changes for CLI lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants