Skip to content

Commit d5b1eb1

Browse files
Merge pull request #25841 from baude/initunits
Correct units in init error message
2 parents 526aa3a + 521b245 commit d5b1eb1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

cmd/podman/machine/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func checkMaxMemory(newMem strongunits.MiB) error {
249249
return err
250250
}
251251
if total := strongunits.B(memStat.Total); strongunits.B(memStat.Total) < newMem.ToBytes() {
252-
return fmt.Errorf("requested amount of memory (%d MB) greater than total system memory (%d MB)", newMem, total)
252+
return fmt.Errorf("requested amount of memory (%d MB) greater than total system memory (%d MB)", newMem, strongunits.ToMib(total))
253253
}
254254
return nil
255255
}

pkg/machine/e2e/init_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ var _ = Describe("podman machine init", func() {
7171
// this comes in bytes
7272
memStat, err := mem.VirtualMemory()
7373
Expect(err).ToNot(HaveOccurred())
74-
total := strongunits.ToMib(strongunits.B(memStat.Total)) + 1024
74+
systemMem := strongunits.ToMib(strongunits.B(memStat.Total))
7575

7676
badMem := initMachine{}
77-
badMemSession, err := mb.setCmd(badMem.withMemory(uint(total))).run()
77+
badMemSession, err := mb.setCmd(badMem.withMemory(uint(systemMem + 1024))).run()
7878
Expect(err).ToNot(HaveOccurred())
79+
Expect(badMemSession.errorToString()).To(ContainSubstring(fmt.Sprintf("greater than total system memory (%d MB)", systemMem)))
7980
Expect(badMemSession).To(Exit(125))
8081
})
8182

0 commit comments

Comments
 (0)