diff options
-rw-r--r-- | .github/PULL_REQUEST_TEMPLATE.md | 30 | ||||
-rw-r--r-- | pkg/bindings/test/images_test.go | 16 | ||||
-rw-r--r-- | utils/utils.go | 13 |
3 files changed, 17 insertions, 42 deletions
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f5f0b21be..16ec09357 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,33 +9,3 @@ Finally, be sure to sign commits with your real name. Since by opening a PR you already have commits, you can add signatures if needed with something like `git commit -s --amend`. --> - -#### What this PR does / why we need it: - -<!--- -Please put your overall PR description here ---> - -#### How to verify it - -<!--- -Please specify the precise conditions and/or the specific test(s) which must pass. ---> - -#### Which issue(s) this PR fixes: - -<!-- -Please uncomment this block and include only one of the following on a -line by itself: - -None - --OR- - -Fixes #<issue number> - -*** Please also put 'Fixes #' in the commit and PR description*** - ---> - -#### Special notes for your reviewer: diff --git a/pkg/bindings/test/images_test.go b/pkg/bindings/test/images_test.go index 8489e6ff1..4ee824472 100644 --- a/pkg/bindings/test/images_test.go +++ b/pkg/bindings/test/images_test.go @@ -85,14 +85,16 @@ var _ = Describe("Podman images", func() { // Test to validate the remove image api It("remove image", func() { - // Remove invalid image should be a 404 + // NOTE that removing an image that does not exist will still + // return a 200 http status. The response, however, includes + // the exit code that podman-remote should exit with. + // + // The libpod/images/remove endpoint supports batch removal of + // images for performance reasons and for hiding the logic of + // deciding which exit code to use from the client. response, errs := images.Remove(bt.conn, []string{"foobar5000"}, nil) Expect(len(errs)).To(BeNumerically(">", 0)) - code, _ := bindings.CheckResponseCode(errs[0]) - // FIXME FIXME FIXME: #12441: THIS IS BROKEN - // FIXME FIXME FIXME: we get msg: "foobar5000: image not known" - // FIXME FIXME FIXME: ...with no ResponseCode - Expect(code).To(BeNumerically("==", -1)) + Expect(response.ExitCode).To(BeNumerically("==", 1)) // podman-remote would exit with 1 // Remove an image by name, validate image is removed and error is nil inspectData, err := images.GetImage(bt.conn, busybox.shortName, nil) @@ -102,7 +104,7 @@ var _ = Describe("Podman images", func() { Expect(inspectData.ID).To(Equal(response.Deleted[0])) inspectData, err = images.GetImage(bt.conn, busybox.shortName, nil) - code, _ = bindings.CheckResponseCode(err) + code, _ := bindings.CheckResponseCode(err) Expect(code).To(BeNumerically("==", http.StatusNotFound)) // Start a container with alpine image diff --git a/utils/utils.go b/utils/utils.go index 241e361cd..45cec2c5f 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -2,16 +2,15 @@ package utils import ( "bytes" + "crypto/rand" "fmt" "io" "io/ioutil" - "math/rand" "os" "os/exec" "strconv" "strings" "sync" - "time" "github.com/containers/common/pkg/cgroups" "github.com/containers/podman/v3/libpod/define" @@ -205,10 +204,14 @@ func moveProcessToScope(pidPath, slice, scope string) error { func MovePauseProcessToScope(pausePidPath string) { var err error - state := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < 10; i++ { - r := state.Int() - err = moveProcessToScope(pausePidPath, "user.slice", fmt.Sprintf("podman-pause-%d.scope", r)) + randBytes := make([]byte, 4) + _, err = rand.Read(randBytes) + if err != nil { + logrus.Errorf("failed to read random bytes: %v", err) + continue + } + err = moveProcessToScope(pausePidPath, "user.slice", fmt.Sprintf("podman-pause-%x.scope", randBytes)) if err == nil { return } |