Skip to content

Commit

Permalink
Merge branch 'modified-test' into graphLock-test
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrmac committed Dec 1, 2022
2 parents e7eb19c + c83efd0 commit bced439
Show file tree
Hide file tree
Showing 23 changed files with 531 additions and 210 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/containers/image/v5 v5.23.1-0.20221130170538-333c50e3eac8
github.com/containers/ocicrypt v1.1.6
github.com/containers/psgo v1.8.0
github.com/containers/storage v1.44.1-0.20221121144727-71fd3e87df7a
github.com/containers/storage v1.44.1-0.20221201083122-c5a80ad65f42
github.com/coreos/go-systemd/v22 v22.5.0
github.com/coreos/stream-metadata-go v0.0.0-20210225230131-70edb9eb47b3
github.com/cyphar/filepath-securejoin v0.2.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ github.com/containers/psgo v1.8.0 h1:2loGekmGAxM9ir5OsXWEfGwFxorMPYnc6gEDsGFQvhY
github.com/containers/psgo v1.8.0/go.mod h1:T8ZxnX3Ur4RvnhxFJ7t8xJ1F48RhiZB4rSrOaR/qGHc=
github.com/containers/storage v1.37.0/go.mod h1:kqeJeS0b7DO2ZT1nVWs0XufrmPFbgV3c+Q/45RlH6r4=
github.com/containers/storage v1.43.0/go.mod h1:uZ147thiIFGdVTjMmIw19knttQnUCl3y9zjreHrg11s=
github.com/containers/storage v1.44.1-0.20221121144727-71fd3e87df7a h1:Kds8yAenoKQ7d95T+2oOfnLJpxPAwG9grUf0lIA4JJs=
github.com/containers/storage v1.44.1-0.20221121144727-71fd3e87df7a/go.mod h1:pYkSXaKIGAuEQmIf/melI5wbS/JBM++6Xp4JuVTqY7U=
github.com/containers/storage v1.44.1-0.20221201083122-c5a80ad65f42 h1:lba+h0VcMGvO/C4Q+oMhGxpgajzyQifbcedOYQNVRx8=
github.com/containers/storage v1.44.1-0.20221201083122-c5a80ad65f42/go.mod h1:pYkSXaKIGAuEQmIf/melI5wbS/JBM++6Xp4JuVTqY7U=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
Expand Down
2 changes: 1 addition & 1 deletion libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,7 @@ func (c *Container) cleanup(ctx context.Context) error {
if hoststFile, ok := c.state.BindMounts[config.DefaultHostsFile]; ok {
if _, err := os.Stat(hoststFile); err == nil {
// we cannot use the dependency container lock due ABBA deadlocks
if lock, err := lockfile.GetLockfile(hoststFile); err == nil {
if lock, err := lockfile.GetLockFile(hoststFile); err == nil {
lock.Lock()
// make sure to ignore ENOENT error in case the netns container was cleaned up before this one
if err := etchosts.Remove(hoststFile, getLocalhostHostEntry(c)); err != nil && !errors.Is(err, os.ErrNotExist) {
Expand Down
2 changes: 1 addition & 1 deletion libpod/container_internal_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ func (c *Container) makeBindMounts() error {
hostsPath, exists := bindMounts[config.DefaultHostsFile]
if !c.config.UseImageHosts && exists {
// we cannot use the dependency container lock due ABBA deadlocks in cleanup()
lock, err := lockfile.GetLockfile(hostsPath)
lock, err := lockfile.GetLockFile(hostsPath)
if err != nil {
return fmt.Errorf("failed to lock hosts file: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion libpod/events/logfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newLogFileEventer(options EventerOptions) (*EventLogFile, error) {
// Writes to the log file
func (e EventLogFile) Write(ee Event) error {
// We need to lock events file
lock, err := lockfile.GetLockfile(e.options.LogFilePath + ".lock")
lock, err := lockfile.GetLockFile(e.options.LogFilePath + ".lock")
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions libpod/lock/file/file_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"syscall"

"github.com/containers/storage"
"github.com/containers/storage/pkg/lockfile"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -150,7 +150,7 @@ func (locks *FileLocks) LockFileLock(lck uint32) error {
return fmt.Errorf("locks have already been closed: %w", syscall.EINVAL)
}

l, err := storage.GetLockfile(locks.getLockPath(lck))
l, err := lockfile.GetLockFile(locks.getLockPath(lck))
if err != nil {
return fmt.Errorf("acquiring lock: %w", err)
}
Expand All @@ -164,7 +164,7 @@ func (locks *FileLocks) UnlockFileLock(lck uint32) error {
if !locks.valid {
return fmt.Errorf("locks have already been closed: %w", syscall.EINVAL)
}
l, err := storage.GetLockfile(locks.getLockPath(lck))
l, err := lockfile.GetLockFile(locks.getLockPath(lck))
if err != nil {
return fmt.Errorf("acquiring lock: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions libpod/networking_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func (c *Container) NetworkDisconnect(nameOrID, netName string, force bool) erro
if len(rm) > 0 {
// make sure to lock this file to prevent concurrent writes when
// this is used a net dependency container
lock, err := lockfile.GetLockfile(file)
lock, err := lockfile.GetLockFile(file)
if err != nil {
return fmt.Errorf("failed to lock hosts file: %w", err)
}
Expand Down Expand Up @@ -591,7 +591,7 @@ func (c *Container) NetworkConnect(nameOrID, netName string, netOpts types.PerNe
if file, ok := c.state.BindMounts[config.DefaultHostsFile]; ok {
// make sure to lock this file to prevent concurrent writes when
// this is used a net dependency container
lock, err := lockfile.GetLockfile(file)
lock, err := lockfile.GetLockFile(file)
if err != nil {
return fmt.Errorf("failed to lock hosts file: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion libpod/networking_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type LinkStatistics64 struct {

type RootlessNetNS struct {
dir string
Lock lockfile.Locker
Lock *lockfile.LockFile
}

// getPath will join the given path to the rootless netns dir
Expand Down
4 changes: 2 additions & 2 deletions libpod/networking_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
type RootlessNetNS struct {
ns ns.NetNS
dir string
Lock lockfile.Locker
Lock *lockfile.LockFile
}

// getPath will join the given path to the rootless netns dir
Expand Down Expand Up @@ -333,7 +333,7 @@ func (r *Runtime) GetRootlessNetNs(new bool) (*RootlessNetNS, error) {
runDir := r.config.Engine.TmpDir

lfile := filepath.Join(runDir, "rootless-netns.lock")
lock, err := lockfile.GetLockfile(lfile)
lock, err := lockfile.GetLockFile(lfile)
if err != nil {
return nil, fmt.Errorf("failed to get rootless-netns lockfile: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion libpod/networking_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

type RootlessNetNS struct {
dir string
Lock lockfile.Locker
Lock *lockfile.LockFile
}

// ocicniPortsToNetTypesPorts convert the old port format to the new one
Expand Down
3 changes: 2 additions & 1 deletion libpod/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/containers/podman/v4/pkg/rootless"
"github.com/containers/podman/v4/pkg/util"
"github.com/containers/storage"
"github.com/containers/storage/pkg/lockfile"
stypes "github.com/containers/storage/types"
"github.com/sirupsen/logrus"
)
Expand All @@ -35,7 +36,7 @@ func (r *Runtime) removeAllDirs() error {
// TODO: maybe want a helper for getting the path? This is duped from
// runtime.go
runtimeAliveLock := filepath.Join(r.config.Engine.TmpDir, "alive.lck")
aliveLock, err := storage.GetLockfile(runtimeAliveLock)
aliveLock, err := lockfile.GetLockFile(runtimeAliveLock)
if err != nil {
logrus.Errorf("Lock runtime alive lock %s: %v", runtimeAliveLock, err)
} else {
Expand Down
3 changes: 2 additions & 1 deletion libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/containers/podman/v4/pkg/util"
"github.com/containers/podman/v4/utils"
"github.com/containers/storage"
"github.com/containers/storage/pkg/lockfile"
"github.com/containers/storage/pkg/unshare"
"github.com/docker/docker/pkg/namesgenerator"
spec "github.com/opencontainers/runtime-spec/specs-go"
Expand Down Expand Up @@ -539,7 +540,7 @@ func makeRuntime(runtime *Runtime) (retErr error) {
// This check must be locked to prevent races
runtimeAliveLock := filepath.Join(runtime.config.Engine.TmpDir, "alive.lck")
runtimeAliveFile := filepath.Join(runtime.config.Engine.TmpDir, "alive")
aliveLock, err := storage.GetLockfile(runtimeAliveLock)
aliveLock, err := lockfile.GetLockFile(runtimeAliveLock)
if err != nil {
return fmt.Errorf("acquiring runtime init lock: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/rootless/rootless.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TryJoinPauseProcess(pausePidPath string) (bool, int, error) {
}

// It could not join the pause process, let's lock the file before trying to delete it.
pidFileLock, err := lockfile.GetLockfile(pausePidPath)
pidFileLock, err := lockfile.GetLockFile(pausePidPath)
if err != nil {
// The file was deleted by another process.
if os.IsNotExist(err) {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/containers/podman/v4/pkg/rootless"
"github.com/containers/podman/v4/pkg/util"
. "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage"
"github.com/containers/storage/pkg/lockfile"
"github.com/containers/storage/pkg/reexec"
"github.com/containers/storage/pkg/stringid"
jsoniter "github.com/json-iterator/go"
Expand Down Expand Up @@ -402,9 +402,9 @@ func processTestResult(f GinkgoTestDescription) {
testResultsMutex.Unlock()
}

func GetPortLock(port string) storage.Locker {
func GetPortLock(port string) *lockfile.LockFile {
lockFile := filepath.Join(LockTmpDir, port)
lock, err := storage.GetLockfile(lockFile)
lock, err := lockfile.GetLockFile(lockFile)
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
33 changes: 24 additions & 9 deletions vendor/github.com/containers/storage/containers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bced439

Please sign in to comment.