-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Handle default system connection transfer properly on machine removal #23945
Handle default system connection transfer properly on machine removal #23945
Conversation
Adds the function `GetAllMachinesAndRootfulness` which creates a map of all podman machines, of any supported provider, on the system and whether it is rootful or not. Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
The `RemoveFilesAndConnections` function is not being used, so its safe to remove it and not carry unnecessary code that we need to maintain. Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
ok , LGTM (one question) |
a8d631f
to
26a5644
Compare
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.
Sorry I just realized the test is not safe/working.
pkg/machine/connection/connection.go
Outdated
logrus.Error(err) | ||
|
||
// If there is a podman-machine-default system connection, immediately set that as the new default | ||
const defaultMachineName = "podman-machine-default" |
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.
not blocking but this is already defined as DefaultMachineName in pkg/machine.
I know this will cause a import cycle but then it can be moved into pkg/machine/define to solve 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.
Fixed!
pkg/machine/e2e/rm_test.go
Outdated
bm := basicMachine{} | ||
sysConnOutput, err := mb.setCmd(bm.withPodmanCommand([]string{"system", "connection", "list", "--format", "'{{.Name}}'"})).run() | ||
Expect(err).ToNot(HaveOccurred()) | ||
names := sysConnOutput.outputToStringSlice() | ||
sysConnOutput, err = mb.setCmd(bm.withPodmanCommand([]string{"system", "connection", "list", "--format", "'{{.Default}}'"})).run() | ||
Expect(err).ToNot(HaveOccurred()) | ||
defaults := sysConnOutput.outputToStringSlice() | ||
for idx, n := range names { | ||
if n == name { | ||
Expect(defaults[idx]).To(Equal("true")) | ||
} | ||
} |
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.
I have not tried to run it but I cannot see how this can work, and if it if it is this is super risk as it can be easily be a NOP. "'{{.Name}}'"
is not correct usage because the single quote will be part of the template so it will be in the output.
As such you names loop will never match...
What you should do is something like "--format", "{{.Name}}--{{.Default}}"
And then you just match Expect(sysConnOutput.outputToString()).To(ContainSubstring(name+":true"))
Then below you do the same match again.
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.
That's much cleaner, thank you. I definitely made that more complicated than it needed to be.
Moves the `DefaultMachineName` constant out of `pkg/machine` and into `pkg/machine/define`. Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Takes the code inside the closure in the function `RemoveConnections` and makes it a separate function to increase readability. Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Modify `RemoveConnections` to verify the new default system connection's rootful state matches the rootful-ness of the podman machine it is associated with. Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
26a5644
to
5cc52c3
Compare
Ephemeral COPR build failed. @containers/packit-build please check. |
pkg/machine/e2e/rm_test.go
Outdated
bm := basicMachine{} | ||
sysConnOutput, err := mb.setCmd(bm.withPodmanCommand([]string{"system", "connection", "list", "--format", "{{.Name}}--{{.Default}}"})).run() | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(sysConnOutput.outputToString()).To(ContainSubstring(name + ":true")) |
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.
name + "--true"
Sorry that happens if I change my mind mid comment. Or you check the format to be {{.Name}}:{{.Default}}
.
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.
Sorry about that, forgot to run the test locally before pushing...
5cc52c3
to
c1e0071
Compare
|
Modifies the "Remove machine" test to verify the system connections are handled properly on removal. Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
c1e0071
to
e9b8564
Compare
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jakecorrenti, 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 |
adbb735
into
containers:main
Changes system connection removal so the following case now works as expected:
Fixes: #22577
Does this PR introduce a user-facing change?