spiegel_podman/cmd/podman/system/locks.go
Matt Heon 72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

[1] https://github.com/KSubedi/gomove

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00

54 lines
1.2 KiB
Go

package system
import (
"fmt"
"github.com/containers/podman/v5/cmd/podman/registry"
"github.com/containers/podman/v5/cmd/podman/validate"
"github.com/spf13/cobra"
)
var (
locksCommand = &cobra.Command{
Use: "locks",
Short: "Debug Libpod's use of locks, identifying any potential conflicts",
Args: validate.NoArgs,
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runLocks()
},
Example: "podman system locks",
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Command: locksCommand,
Parent: systemCmd,
})
}
func runLocks() error {
report, err := registry.ContainerEngine().Locks(registry.Context())
if err != nil {
return err
}
for lockNum, objects := range report.LockConflicts {
fmt.Printf("Lock %d is in use by the following\n:", lockNum)
for _, obj := range objects {
fmt.Printf("\t%s\n", obj)
}
}
if len(report.LockConflicts) > 0 {
fmt.Printf("\nLock conflicts have been detected. Recommend immediate use of `podman system renumber` to resolve.\n\n")
} else {
fmt.Printf("\nNo lock conflicts have been detected.\n\n")
}
for _, lockNum := range report.LocksHeld {
fmt.Printf("Lock %d is presently being held\n", lockNum)
}
return nil
}