Skip to content

Conversation

@baude
Copy link
Member

@baude baude commented Oct 29, 2025

This allows users to set the associated machine's system connection to the system default when running podman machine init --now or podman machine start. It also changes the default bbehavior of these commands in that the user will be prompted and asked if they would like to switch the system connection. It also introduces a command line switch called --update-connection. If the switch is unset, then the user will be prmpted. If the command value is explicitly set to false, the user will not be prompted and the system connection will not be altered. If the value is set to true, the system connection will be made the default and the user will not be prompted.

Does this PR introduce a user-facing change?

Users are now prompted when a machine starts to change the default system connection

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 29, 2025
@baude baude marked this pull request as draft October 29, 2025 20:18
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 29, 2025
Copy link
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

LGTM, I like the new feature.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

There are big TOCTOU races here, I think this logic must be moved into the shim Start() call where we hold the startLock to prevent simultaneous starts from overwriting each other.

Because technically what can happen is you start machine 1, then you prompt (can take forever), then the machine 1 gets stopped, machine 2 is started prompts again, answered yes., then go back to the prompt of machine 1 and answer yes there as well.

Sure easy to say user problem and not our thing but I think it costs us nothing doing this under the start lock. Maybe it makes more sense to prompt before we actually start the machine and then we only have to rewrite the connection under the start lock.

Comment on lines 300 to 301
// Set DefaultProvider
return checkAndSetDefConnection(cmd, initOpts.Name, initOpts.Rootful, setDefaultSystemConn)
Copy link
Member

Choose a reason for hiding this comment

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

aren't you calling this twice on init then? start already called it and now you call it again?

Copy link
Member Author

Choose a reason for hiding this comment

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

you are right! how the hell did that get by me.

@baude baude force-pushed the setdefaultconnection branch 2 times, most recently from c0e2585 to c80e009 Compare October 30, 2025 19:39
@baude baude marked this pull request as ready for review October 30, 2025 20:04
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 30, 2025
@packit-as-a-service
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@baude baude force-pushed the setdefaultconnection branch 2 times, most recently from b010c0e to 2786cab Compare October 31, 2025 19:33
@TomSweeneyRedHat
Copy link
Member

Changes LGTM
A test is failing so far, looks to be a flake.

@baude baude force-pushed the setdefaultconnection branch from 2786cab to dd3a6c9 Compare November 3, 2025 14:31
Comment on lines 300 to 302
if err := start(cmd, args); err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

This is incorrect and must be reverted, no need to touch this at all.

Right now you only return on error not always. This means that a --now still prints the

To start your machine run:\n\n\tpodman machine start%s\n\n

message below which is obviously not what we want.

Copy link
Member Author

Choose a reason for hiding this comment

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

got it

if !conn.Default {
// Prompt for system connection update
if updateSystemConn == nil {
response, err := promptUpdateSystemConn()
Copy link
Member

Choose a reason for hiding this comment

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

What I was trying to tell you is that this part should still be in cmd/. Only the EditConnectionConfig() can be here. But I guess it doesn't matter to much either way so if you want to leave this as is fine with me.

Copy link
Member Author

Choose a reason for hiding this comment

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

I know what you were saying but I hit a problem, for which I cannot remember now, and was forced to combine them.

@baude baude force-pushed the setdefaultconnection branch 2 times, most recently from bbfc065 to 9b27541 Compare November 3, 2025 15:18
@mheon
Copy link
Member

mheon commented Nov 3, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 3, 2025
@Luap99 Luap99 removed the lgtm Indicates that a PR is ready to be merged. label Nov 3, 2025
@Luap99
Copy link
Member

Luap99 commented Nov 3, 2025

Removing lgtm, wsl is not passing

Summarizing 2 Failures:
  [FAIL] podman machine start [It] machine start with --update-connection
  C:/Users/Administrator/AppData/Local/cirrus-ci-build/repo/pkg/machine/e2e/start_test.go:266
  [FAIL] podman machine start [It] machine init --now with --update-connection
  C:/Users/Administrator/AppData/Local/cirrus-ci-build/repo/pkg/machine/e2e/start_test.go:304

https://cirrus-ci.com/task/6459874357280768

@baude baude force-pushed the setdefaultconnection branch 3 times, most recently from fcf427b to 45743b5 Compare November 4, 2025 16:13
baude added 2 commits November 4, 2025 10:35
This allows users to set the associated machine's system connection to the system default when running `podman machine init --now` or `podman machine start`.  It also changes the default bbehavior of these commands in that the user will be prompted and asked if they would like to switch the system connection.  It also introduces a command line switch called `--update-connection`.  If the switch is unset, then the user will be prmpted.  If the command value is explicitly set to `false`, the user will not be prompted and the system connection will not be altered.  If the value is set to `true`, the system connection will be made the default and the user will not be prompted.

Fixes: https://issues.redhat.com/browse/RUN-3632

Signed-off-by: Brent Baude <[email protected]>
Bumping the timeout for aarch64 machine tests as I am getting a
consistent timeout where the tests are not completing in the given time.

Signed-off-by: Brent Baude <[email protected]>
@baude baude force-pushed the setdefaultconnection branch from 45743b5 to 623cb5f Compare November 4, 2025 16:36
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 4, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baude, 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

@mheon
Copy link
Member

mheon commented Nov 4, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 4, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 17beac1 into containers:main Nov 4, 2025
86 checks passed
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. lgtm Indicates that a PR is ready to be merged. machine release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants