Merge pull request #25828 from IAmJSD/patch-1

Make Go not panic on a partial update
This commit is contained in:
openshift-merge-bot[bot]
2025-04-08 13:45:06 +00:00
committed by GitHub
2 changed files with 25 additions and 5 deletions

View File

@ -26,13 +26,21 @@ func Update(ctx context.Context, options *types.ContainerUpdateOptions) (string,
params.Set("restartRetries", strconv.Itoa(int(*options.RestartRetries)))
}
}
updateEntities := &handlers.UpdateEntities{
LinuxResources: *options.Resources,
UpdateHealthCheckConfig: *options.ChangedHealthCheckConfiguration,
UpdateContainerDevicesLimits: *options.DevicesLimits,
Env: options.Env,
UnsetEnv: options.UnsetEnv,
}
if options.Resources != nil {
updateEntities.LinuxResources = *options.Resources
}
if options.ChangedHealthCheckConfiguration != nil {
updateEntities.UpdateHealthCheckConfig = *options.ChangedHealthCheckConfiguration
}
if options.DevicesLimits != nil {
updateEntities.UpdateContainerDevicesLimits = *options.DevicesLimits
}
requestData, err := jsoniter.MarshalToString(updateEntities)
if err != nil {
return "", err

View File

@ -9,6 +9,7 @@ import (
"github.com/containers/podman/v5/pkg/bindings"
"github.com/containers/podman/v5/pkg/bindings/containers"
"github.com/containers/podman/v5/pkg/domain/entities/reports"
"github.com/containers/podman/v5/pkg/domain/entities/types"
"github.com/containers/podman/v5/pkg/specgen"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@ -802,4 +803,15 @@ var _ = Describe("Podman containers ", func() {
Expect(c).To(HaveLen(1))
Expect(c[0].PodName).To(Equal(podName))
})
It("Update container allows for partial updates", func() {
var name = "top"
_, err := bt.RunTopContainer(&name, nil)
Expect(err).ToNot(HaveOccurred())
_, err = containers.Update(bt.conn, &types.ContainerUpdateOptions{
NameOrID: name,
})
Expect(err).ToNot(HaveOccurred())
})
})