-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
locks.go
54 lines (46 loc) · 1.24 KB
/
locks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
}