-
Notifications
You must be signed in to change notification settings - Fork 86
[SREP-3695] feat: add a warning message if mac users run podman without rosetta #930
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
Changes from all commits
1c941f0
543da63
d3262ba
524e4c8
582a7bd
399d7dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package container | |
| import ( | ||
| "os" | ||
| "os/exec" | ||
| "runtime" | ||
| "strings" | ||
| "testing" | ||
|
|
||
|
|
@@ -100,6 +101,113 @@ var _ = Describe("console container implementation", func() { | |
| }) | ||
| }) | ||
|
|
||
| Context("when checking Rosetta on macOS Podman", func() { | ||
| It("should execute podman machine ssh command on darwin/arm64", func() { | ||
| if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" { | ||
| capturedCommands = nil | ||
| checkRosettaEnabled() | ||
| Expect(len(capturedCommands)).To(Equal(1)) | ||
| command := capturedCommands[0] | ||
| Expect(command[0]).To(Equal(PODMAN)) | ||
| Expect(command[1]).To(Equal("machine")) | ||
| Expect(command[2]).To(Equal("ssh")) | ||
| Expect(strings.Join(command[3:], " ")).To(Equal("ls /proc/sys/fs/binfmt_misc/")) | ||
| } else { | ||
| Skip("Rosetta check only runs on darwin/arm64") | ||
| } | ||
| }) | ||
|
Comment on lines
+104
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exercise the warning path, not just the These specs prove that As per coding guidelines, 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. too heavy, skip this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| It("should skip the check on non-darwin platforms", func() { | ||
| if runtime.GOOS != "darwin" { | ||
| capturedCommands = nil | ||
| checkRosettaEnabled() | ||
| Expect(len(capturedCommands)).To(Equal(0)) | ||
| } else { | ||
| Skip("This test only runs on non-darwin platforms") | ||
| } | ||
| }) | ||
| It("should skip the check on non-arm64 architectures", func() { | ||
| if runtime.GOOS == "darwin" && runtime.GOARCH != "arm64" { | ||
| capturedCommands = nil | ||
| checkRosettaEnabled() | ||
| Expect(len(capturedCommands)).To(Equal(0)) | ||
| } else { | ||
| Skip("This test only runs on darwin with non-arm64 architectures") | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| Context("when running console container on macOS", func() { | ||
| ce := podmanMac{} | ||
| It("should check Rosetta before running the container on darwin/arm64", func() { | ||
| if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" { | ||
| mockOcmInterface.EXPECT().GetPullSecret().Return(pullSecret, nil).AnyTimes() | ||
| capturedCommands = nil | ||
| args := []string{"arg1"} | ||
| envvars := []EnvVar{{Key: "testkey", Value: "testval"}} | ||
| err := ce.RunConsoleContainer("console", "8888", args, envvars) | ||
| Expect(err).To(BeNil()) | ||
| // Count Rosetta check commands | ||
| rosettaCheckCount := 0 | ||
| for _, cmd := range capturedCommands { | ||
| if len(cmd) >= 3 && cmd[0] == PODMAN && cmd[1] == "machine" && cmd[2] == "ssh" { | ||
| rosettaCheckCount++ | ||
| } | ||
| } | ||
| // Should have exactly 1 Rosetta check | ||
| Expect(rosettaCheckCount).To(Equal(1)) | ||
| // First command should be Rosetta check | ||
| rosettaCheckCmd := capturedCommands[0] | ||
| Expect(rosettaCheckCmd[0]).To(Equal(PODMAN)) | ||
| Expect(rosettaCheckCmd[1]).To(Equal("machine")) | ||
| Expect(rosettaCheckCmd[2]).To(Equal("ssh")) | ||
| // Last command should be the actual container run | ||
| runCmd := capturedCommands[len(capturedCommands)-1] | ||
| fullCommand := strings.Join(runCmd, " ") | ||
| Expect(fullCommand).To(ContainSubstring("arg1")) | ||
| Expect(fullCommand).To(ContainSubstring("--env")) | ||
| Expect(fullCommand).To(ContainSubstring("testkey=testval")) | ||
| } else { | ||
| Skip("Rosetta check only runs on darwin/arm64") | ||
| } | ||
| }) | ||
| It("should skip Rosetta check on non-darwin platforms", func() { | ||
| if runtime.GOOS != "darwin" { | ||
| mockOcmInterface.EXPECT().GetPullSecret().Return(pullSecret, nil).AnyTimes() | ||
| capturedCommands = nil | ||
| args := []string{"arg1"} | ||
| envvars := []EnvVar{{Key: "testkey", Value: "testval"}} | ||
| err := ce.RunConsoleContainer("console", "8888", args, envvars) | ||
| Expect(err).To(BeNil()) | ||
| // Should only have 1 command for running container (no Rosetta check) | ||
| Expect(len(capturedCommands)).To(Equal(1)) | ||
| fullCommand := strings.Join(capturedCommands[0], " ") | ||
| Expect(fullCommand).To(ContainSubstring("arg1")) | ||
| Expect(fullCommand).To(ContainSubstring("--env")) | ||
| Expect(fullCommand).To(ContainSubstring("testkey=testval")) | ||
| } else { | ||
| Skip("This test only runs on non-darwin platforms") | ||
| } | ||
| }) | ||
| It("should skip Rosetta check on darwin with non-arm64 architectures", func() { | ||
| if runtime.GOOS == "darwin" && runtime.GOARCH != "arm64" { | ||
| mockOcmInterface.EXPECT().GetPullSecret().Return(pullSecret, nil).AnyTimes() | ||
| capturedCommands = nil | ||
| args := []string{"arg1"} | ||
| envvars := []EnvVar{{Key: "testkey", Value: "testval"}} | ||
| err := ce.RunConsoleContainer("console", "8888", args, envvars) | ||
| Expect(err).To(BeNil()) | ||
| // Should only have 1 command for running container (no Rosetta check) | ||
| Expect(len(capturedCommands)).To(Equal(1)) | ||
| fullCommand := strings.Join(capturedCommands[0], " ") | ||
| Expect(fullCommand).To(ContainSubstring("arg1")) | ||
| Expect(fullCommand).To(ContainSubstring("--env")) | ||
| Expect(fullCommand).To(ContainSubstring("testkey=testval")) | ||
| } else { | ||
| Skip("This test only runs on darwin with non-arm64 architectures") | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| Context("when running console container", func() { | ||
| ce := podmanMac{} | ||
| It("should pass argments and environment variable if specified", func() { | ||
|
|
@@ -109,8 +217,9 @@ var _ = Describe("console container implementation", func() { | |
| envvars := []EnvVar{{Key: "testkey", Value: "testval"}} | ||
| err := ce.RunConsoleContainer("console", "8888", args, envvars) | ||
| Expect(err).To(BeNil()) | ||
| Expect(len(capturedCommands)).To(Equal(1)) | ||
| fullCommand := strings.Join(capturedCommands[0], " ") | ||
| Expect(len(capturedCommands)).To(BeNumerically(">=", 1)) | ||
| // Find the run command (should be the last one) | ||
| fullCommand := strings.Join(capturedCommands[len(capturedCommands)-1], " ") | ||
| // arg | ||
| Expect(fullCommand).To(ContainSubstring("arg1")) | ||
| // env var | ||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/backplane-cli
Length of output: 1413
Split the remote
sshcommand into separate argv tokens.podman machine sshis documented as[name] [command [arg …]], and the official examples pass the remote command and its arguments as separate tokens. Passing"ls /proc/sys/fs/binfmt_misc/"as one token will cause Podman to treat the entire string as the executable name, making this probe fail and silently skip the warning.Suggested fix
🤖 Prompt for AI Agents