Include lock number in pod/container/volume inspect

Being able to easily identify what lock has been allocated to a
given Libpod object is only somewhat useful for debugging lock
issues, but it's trivial to expose and I don't see any harm in
doing so.

Signed-off-by: Matt Heon <mheon@redhat.com>
This commit is contained in:
Matt Heon
2023-06-05 12:28:50 -04:00
parent e143a0ff8e
commit 3b39eb1333
6 changed files with 8 additions and 0 deletions

View File

@ -166,6 +166,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver
IsInfra: c.IsInfra(),
IsService: c.IsService(),
KubeExitCodePropagation: config.KubeExitCodePropagation.String(),
LockNumber: c.lock.ID(),
}
if config.RootfsImageID != "" { // May not be set if the container was created with --rootfs

View File

@ -691,6 +691,7 @@ type InspectContainerData struct {
IsInfra bool `json:"IsInfra"`
IsService bool `json:"IsService"`
KubeExitCodePropagation string `json:"KubeExitCodePropagation"`
LockNumber uint32 `json:"lockNumber"`
Config *InspectContainerConfig `json:"Config"`
HostConfig *InspectContainerHostConfig `json:"HostConfig"`
}

View File

@ -85,6 +85,8 @@ type InspectPodData struct {
BlkioWeightDevice []InspectBlkioWeightDevice `json:"blkio_weight_device,omitempty"`
// RestartPolicy of the pod.
RestartPolicy string `json:"RestartPolicy,omitempty"`
// Number of the pod's Libpod lock.
LockNumber uint32
}
// InspectPodInfraConfig contains the configuration of the pod's infra

View File

@ -61,6 +61,8 @@ type InspectVolumeData struct {
// StorageID is the ID of the container backing the volume in c/storage.
// Only used with Image Volumes.
StorageID string `json:"StorageID,omitempty"`
// LockNumber is the number of the volume's Libpod lock.
LockNumber uint32
}
type VolumeReload struct {

View File

@ -742,6 +742,7 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) {
BlkioDeviceWriteBps: p.BlkiThrottleWriteBps(),
CPUShares: p.CPUShares(),
RestartPolicy: p.config.RestartPolicy,
LockNumber: p.lock.ID(),
}
return &inspectData, nil

View File

@ -65,6 +65,7 @@ func (v *Volume) Inspect() (*define.InspectVolumeData, error) {
data.NeedsCopyUp = v.state.NeedsCopyUp
data.NeedsChown = v.state.NeedsChown
data.StorageID = v.config.StorageID
data.LockNumber = v.lock.ID()
if v.config.Timeout != nil {
data.Timeout = *v.config.Timeout