Skip to content

Use gvproxy notify socket instead of polling for readiness#29048

Open
Honny1 wants to merge 1 commit into
podman-container-tools:mainfrom
Honny1:gvproxy-notify
Open

Use gvproxy notify socket instead of polling for readiness#29048
Honny1 wants to merge 1 commit into
podman-container-tools:mainfrom
Honny1:gvproxy-notify

Conversation

@Honny1

@Honny1 Honny1 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Replace backoff-based polling for gvproxy socket existence with the new --notification flag from gvisor-tap-vsock#566. Podman creates a Unix listener and gvproxy sends a JSON ready message when its listeners are up. Faster, no race conditions.

Fixes: https://redhat.atlassian.net/browse/RUN-4471

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

Machine start uses gvproxy notification socket for readiness instead of polling.

@Honny1 Honny1 marked this pull request as ready for review June 25, 2026 17:49
@Honny1 Honny1 force-pushed the gvproxy-notify branch 5 times, most recently from 4e07dbd to dba750e Compare June 29, 2026 17:11
Comment thread pkg/machine/shim/host.go Outdated
gvProxyReadyCtx, gvProxyReadyCancel := context.WithTimeout(context.Background(), machine.GvProxyReadyTimeout)
defer gvProxyReadyCancel()
if err := gvProxyNotifier.WaitReady(gvProxyReadyCtx); err != nil {
logrus.Warnf("gvproxy readiness notification not received: %v; continuing without it", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be a hard error instead?

Comment thread pkg/machine/shim/networking.go Outdated
}
c.Args = append(c.Args, "-notification", "unix://"+socketPath)

logrus.Debugf("gvproxy command-line: %s %s", binary, strings.Join(cmd.ToCmdline(), " "))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this will not catch c.Args in the debug log so it will miss -notification.... is it intended?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

addressed, thanks. LGTM

@Honny1 Honny1 requested review from ashley-cui and inknos July 1, 2026 16:08

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems like a good improvement, just some comments one the implementation

Comment thread pkg/machine/gvproxy_notify.go Outdated
Comment on lines +53 to +61
listener, err := net.Listen("unix", socketPath)
if err != nil {
return nil, fmt.Errorf("creating notification listener: %w", err)
}

// Prevent Close() from removing the socket file. gvproxy may still
// dial it for notifications after the listener is closed. The file is
// removed by CleanupGvProxyNotifySocket during machine stop.
listener.(*net.UnixListener).SetUnlinkOnClose(false)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you can avoid the type cast by calling net.ListenUnix() instead which returns net.UnixListener

Comment thread pkg/machine/gvproxy_notify.go Outdated
select {
case n.connectedCh <- msg.MacAddress:
default:
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unless I am missing something nothing ever consumes connectedCh so why bother with a extra channel. I would just not do anything here

Comment thread pkg/machine/gvproxy_notify.go Outdated
Comment on lines +149 to +150
case gvProxyTypes.ConnectionClosed:
logrus.Debugf("gvproxy: VM disconnected (mac=%s)", msg.MacAddress)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

would this make sense to report as error in the error channel, if we see a disconnect even nothing good happened and it likely makes not sense to keep waiting until timeout

return nil, nil, err
}
// Wait on gvproxy to be running and aware
if err := sockets.WaitForSocketWithBackoffs(gvProxyMaxBackoffAttempts, gvProxyWaitBackoff, gvproxySocket.GetPath(), "gvproxy"); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there are just two callers of this function which you removed so WaitForSocketWithBackoffs should be removed as well IMO

Comment thread pkg/machine/gvproxy_notify.go Outdated
logrus.Debugf("notification listener accept error: %v", err)
return
}
go n.handleConnection(ctx, conn)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we ever want to deal with more than one connection at a time? the parsing of the json message seems fast enough that we would not need to spawn another goroutine for it

Comment thread pkg/machine/gvproxy_notify.go Outdated
if errors.Is(err, net.ErrClosed) {
return
}
logrus.Debugf("notification listener accept error: %v", err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be a visible error log, if we fail to accept a gvproxy conn we should see it as otherwsie we just timeout on for the event later and then have no way to know why we timed out.

@Honny1 Honny1 requested a review from Luap99 July 7, 2026 12:38
@Honny1

Honny1 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

/packit retest-failed

@Luap99

Luap99 commented Jul 7, 2026

Copy link
Copy Markdown
Member

@Honny1 Don't blindly rerun machine tests on PRs like that.

hyperV seems hard broken

Error: waiting for gvproxy readiness: timeout waiting for gvproxy ready notification: context deadline exceeded

@Honny1

Honny1 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Blocked by containers/gvisor-tap-vsock#693
And with the release of gvproxy.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants