mirror of
https://github.com/containers/podman.git
synced 2025-05-20 00:27:03 +08:00
libpod: do not call (*container).Spec()
Access the container's spec field directly inside of libpod instead of calling Spec() which in turn creates expensive JSON deep copies. Accessing the field directly drops memory consumption of a simple podman run --rm busybox true from ~700kB to ~600kB. [NO TESTS NEEDED] Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -1095,7 +1095,7 @@ func (c *Container) AutoRemove() bool {
|
||||
if spec.Annotations == nil {
|
||||
return false
|
||||
}
|
||||
return c.Spec().Annotations[define.InspectAnnotationAutoremove] == define.InspectResponseTrue
|
||||
return spec.Annotations[define.InspectAnnotationAutoremove] == define.InspectResponseTrue
|
||||
}
|
||||
|
||||
// Timezone returns the timezone configured inside the container.
|
||||
|
@ -2004,7 +2004,7 @@ func (c *Container) setupOCIHooks(ctx context.Context, config *spec.Spec) (map[s
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
ociHooks, err := manager.Hooks(config, c.Spec().Annotations, len(c.config.UserVolumes) > 0)
|
||||
ociHooks, err := manager.Hooks(config, c.config.Spec.Annotations, len(c.config.UserVolumes) > 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -2021,7 +2021,7 @@ func (c *Container) setupOCIHooks(ctx context.Context, config *spec.Spec) (map[s
|
||||
return nil, err
|
||||
}
|
||||
|
||||
allHooks, err = manager.Hooks(config, c.Spec().Annotations, len(c.config.UserVolumes) > 0)
|
||||
allHooks, err = manager.Hooks(config, c.config.Spec.Annotations, len(c.config.UserVolumes) > 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ func containerToV1Container(ctx context.Context, c *Container) (v1.Container, []
|
||||
// NOTE: a privileged container mounts all of /dev/*.
|
||||
if !c.Privileged() && len(c.config.Spec.Linux.Devices) > 0 {
|
||||
// TODO Enable when we can support devices and their names
|
||||
kubeContainer.VolumeDevices = generateKubeVolumeDeviceFromLinuxDevice(c.Spec().Linux.Devices)
|
||||
kubeContainer.VolumeDevices = generateKubeVolumeDeviceFromLinuxDevice(c.config.Spec.Linux.Devices)
|
||||
return kubeContainer, kubeVolumes, nil, errors.Wrapf(define.ErrNotImplemented, "linux devices")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user