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

Extract waitForGvProxy into shared utility function #21694

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

arixmkii
Copy link
Contributor

Making waitForGvProxy available for use in other providers as it has no applehv specifics. New location would be within sockets package, where other socket related utilities could be found.

This could be then used with other providers like proposed change here #21594 where right now there is need to duplicate this code.

Does this PR introduce a user-facing change?

None

[NO NEW TESTS NEEDED]

@arixmkii
Copy link
Contributor Author

arixmkii commented Feb 16, 2024

Need to fix logs, to make it truly generic, missed this. Will update.

Fixed now.

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

backoffWait := backoff
logrus.Debugf("checking that %q is ready", name)
for i := 0; i < maxBackoffs; i++ {
_, err := os.Stat(socketPath)
Copy link
Member

Choose a reason for hiding this comment

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

Why split this out? There is really no big reason to use unix.Access() over os.Stat() here so I rather have one function for everything. The duplication is always incredibly hard to work with.

Copy link
Contributor Author

@arixmkii arixmkii Feb 16, 2024

Choose a reason for hiding this comment

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

I can use os.Stat version for all platforms. I didn't want to change the original implementation, my assumption was that the unix.Access with syscall inside was an intentional optimization (I know this is not a hot path, so, it should not be as critical). I also saw that in some other projects there was a need to use os.Lstat for checking socket on Windows https://github.com/lima-vm/lima/blob/e9105bd92211bc25029d2c4b87dff404e043f65e/pkg/httpclientutil/httpclientutil_windows.go#L14, but I could not reproduce the error on recent Windows builds using latest golang. I can't say if this will have to be addressed additionally or not in the future.

If using os.Stat for all platforms will be accepted I will change into unified version.

Copy link
Member

Choose a reason for hiding this comment

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

im ok with where this is going ... the timing is bad, but generally this is the direction we were headed. I would prefer paths remain typed as vmfiles.

in the future, i want a vmsocket type, so that we can check socket len(apple) and do various forms of open, listen, etc. but i had envisioned more of an interface type than by OS.

lets review this with scrutiny given we are nearing a release and if it looks like any form of improvement, then im ok to merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer paths remain typed as vmfiles.

sockets.go was using VMFile only as an output parameter, I believed this as a design choice and that was the reason to change to plain paths. I can return VMFile, if this is desired.

in the future, i want a vmsocket type

Then if this or similar change would be introduced it will be easier to find everything what is desired to be changed in one place (or close to each other at least).

@mheon
Copy link
Member

mheon commented Feb 19, 2024

Moving to an OS-agnostic implementation SGTM

@arixmkii
Copy link
Contributor Author

Changed to a single OS agnostic version. Manually checked on M1 macOS: happy case and debug logging verified.

@rhatdan
Copy link
Member

rhatdan commented Feb 19, 2024

LGTM

@TomSweeneyRedHat
Copy link
Member

LGTM
and happy green test buttons.

@arixmkii arixmkii requested a review from baude February 20, 2024 13:36
@rhatdan
Copy link
Member

rhatdan commented Feb 20, 2024

/lgtm
Thanks @arixmkii

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2024
@Luap99
Copy link
Member

Luap99 commented Feb 20, 2024

/approve

Copy link
Contributor

openshift-ci bot commented Feb 20, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arixmkii, Luap99

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 Feb 20, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit d9c706e into containers:main Feb 20, 2024
92 checks passed
@arixmkii arixmkii deleted the wait-for-gvproxy branch March 1, 2024 13:58
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label May 31, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators May 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants