mirror of https://github.com/containers/podman.git
Fix various integration test issues with SQLite state
Two main changes: - The transient state tests relied on BoltDB paths, change to make them agnostic - The volume code in SQLite wasn't retrieving and setting the volume plugin for volumes that used one. Signed-off-by: Matt Heon <mheon@redhat.com>
This commit is contained in:
parent
0f8530b1ee
commit
2ec11b16ab
|
@ -2745,7 +2745,7 @@ func (c *Container) fixVolumePermissions(v *ContainerNamedVolume) error {
|
||||||
|
|
||||||
// Volumes owned by a volume driver are not chowned - we don't want to
|
// Volumes owned by a volume driver are not chowned - we don't want to
|
||||||
// mess with a mount not managed by us.
|
// mess with a mount not managed by us.
|
||||||
if vol.state.NeedsChown && !vol.UsesVolumeDriver() {
|
if vol.state.NeedsChown && (!vol.UsesVolumeDriver() && vol.config.Driver != "image") {
|
||||||
vol.state.NeedsChown = false
|
vol.state.NeedsChown = false
|
||||||
|
|
||||||
uid := int(c.config.Spec.Process.User.UID)
|
uid := int(c.config.Spec.Process.User.UID)
|
||||||
|
|
|
@ -120,7 +120,9 @@ func (r *Runtime) newVolume(ctx context.Context, noCreatePluginVolume bool, opti
|
||||||
volume.config.StorageImageID = image.ID()
|
volume.config.StorageImageID = image.ID()
|
||||||
|
|
||||||
// Create a backing container in c/storage.
|
// Create a backing container in c/storage.
|
||||||
storageConfig := storage.ContainerOptions{}
|
storageConfig := storage.ContainerOptions{
|
||||||
|
LabelOpts: []string{"filetype:container_file_t", "level:s0"},
|
||||||
|
}
|
||||||
if len(volume.config.MountLabel) > 0 {
|
if len(volume.config.MountLabel) > 0 {
|
||||||
context, err := selinux.NewContext(volume.config.MountLabel)
|
context, err := selinux.NewContext(volume.config.MountLabel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -295,6 +295,21 @@ func finalizeVolumeSqlite(vol *Volume) error {
|
||||||
}
|
}
|
||||||
vol.lock = lock
|
vol.lock = lock
|
||||||
|
|
||||||
|
// Retrieve volume driver
|
||||||
|
if vol.UsesVolumeDriver() {
|
||||||
|
plugin, err := vol.runtime.getVolumePlugin(vol.config)
|
||||||
|
if err != nil {
|
||||||
|
// We want to fail gracefully here, to ensure that we
|
||||||
|
// can still remove volumes even if their plugin is
|
||||||
|
// missing. Otherwise, we end up with volumes that
|
||||||
|
// cannot even be retrieved from the database and will
|
||||||
|
// cause things like `volume ls` to fail.
|
||||||
|
logrus.Errorf("Volume %s uses volume plugin %s, but it cannot be accessed - some functionality may not be available: %v", vol.Name(), vol.config.Driver, err)
|
||||||
|
} else {
|
||||||
|
vol.plugin = plugin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vol.valid = true
|
vol.valid = true
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -513,7 +528,7 @@ func (s *SQLiteState) networkModify(ctr *Container, network string, opts types.P
|
||||||
|
|
||||||
_, ok := newCfg.Networks[network]
|
_, ok := newCfg.Networks[network]
|
||||||
if new && ok {
|
if new && ok {
|
||||||
return fmt.Errorf("container %s is already connected to network %s: %w", ctr.ID(), network, define.ErrNoSuchNetwork)
|
return fmt.Errorf("container %s is already connected to network %s: %w", ctr.ID(), network, define.ErrNetworkConnected)
|
||||||
}
|
}
|
||||||
if !ok && (!new || disconnect) {
|
if !ok && (!new || disconnect) {
|
||||||
return fmt.Errorf("container %s is not connected to network %s: %w", ctr.ID(), network, define.ErrNoSuchNetwork)
|
return fmt.Errorf("container %s is not connected to network %s: %w", ctr.ID(), network, define.ErrNoSuchNetwork)
|
||||||
|
|
|
@ -136,7 +136,7 @@ func (v *Volume) Labels() map[string]string {
|
||||||
// MountPoint returns the volume's mountpoint on the host
|
// MountPoint returns the volume's mountpoint on the host
|
||||||
func (v *Volume) MountPoint() (string, error) {
|
func (v *Volume) MountPoint() (string, error) {
|
||||||
// For the sake of performance, avoid locking unless we have to.
|
// For the sake of performance, avoid locking unless we have to.
|
||||||
if v.UsesVolumeDriver() {
|
if v.UsesVolumeDriver() || v.config.Driver == define.VolumeDriverImage {
|
||||||
v.lock.Lock()
|
v.lock.Lock()
|
||||||
defer v.lock.Unlock()
|
defer v.lock.Unlock()
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,14 @@ var _ = Describe("Podman run with volumes", func() {
|
||||||
Expect(filepath.Join(containerStorageDir, "volatile-containers.json")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(containerStorageDir, "volatile-containers.json")).Should(Not(BeAnExistingFile()))
|
||||||
Expect(filepath.Join(runContainerStorageDir, "containers.json")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(runContainerStorageDir, "containers.json")).Should(Not(BeAnExistingFile()))
|
||||||
Expect(filepath.Join(runContainerStorageDir, "volatile-containers.json")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(runContainerStorageDir, "volatile-containers.json")).Should(Not(BeAnExistingFile()))
|
||||||
|
|
||||||
|
if podmanTest.DatabaseBackend == "sqlite" {
|
||||||
|
Expect(filepath.Join(containerStorageDir, "db.sql")).Should(BeARegularFile())
|
||||||
|
Expect(filepath.Join(runContainerStorageDir, "db.sql")).Should(Not(BeAnExistingFile()))
|
||||||
|
} else {
|
||||||
Expect(filepath.Join(dbDir, "bolt_state.db")).Should(BeARegularFile())
|
Expect(filepath.Join(dbDir, "bolt_state.db")).Should(BeARegularFile())
|
||||||
Expect(filepath.Join(runDBDir, "bolt_state.db")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(runDBDir, "bolt_state.db")).Should(Not(BeAnExistingFile()))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run --rm with no transient-store", func() {
|
It("podman run --rm with no transient-store", func() {
|
||||||
|
@ -68,8 +74,14 @@ var _ = Describe("Podman run with volumes", func() {
|
||||||
Expect(filepath.Join(containerStorageDir, "volatile-containers.json")).Should(BeARegularFile())
|
Expect(filepath.Join(containerStorageDir, "volatile-containers.json")).Should(BeARegularFile())
|
||||||
Expect(filepath.Join(runContainerStorageDir, "containers.json")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(runContainerStorageDir, "containers.json")).Should(Not(BeAnExistingFile()))
|
||||||
Expect(filepath.Join(runContainerStorageDir, "volatile-containers.json")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(runContainerStorageDir, "volatile-containers.json")).Should(Not(BeAnExistingFile()))
|
||||||
|
|
||||||
|
if podmanTest.DatabaseBackend == "sqlite" {
|
||||||
|
Expect(filepath.Join(containerStorageDir, "db.sql")).Should(BeARegularFile())
|
||||||
|
Expect(filepath.Join(runContainerStorageDir, "db.sql")).Should(Not(BeAnExistingFile()))
|
||||||
|
} else {
|
||||||
Expect(filepath.Join(dbDir, "bolt_state.db")).Should(BeARegularFile())
|
Expect(filepath.Join(dbDir, "bolt_state.db")).Should(BeARegularFile())
|
||||||
Expect(filepath.Join(runDBDir, "bolt_state.db")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(runDBDir, "bolt_state.db")).Should(Not(BeAnExistingFile()))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run --transient-store", func() {
|
It("podman run --transient-store", func() {
|
||||||
|
@ -83,8 +95,14 @@ var _ = Describe("Podman run with volumes", func() {
|
||||||
Expect(filepath.Join(containerStorageDir, "volatile-containers.json")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(containerStorageDir, "volatile-containers.json")).Should(Not(BeAnExistingFile()))
|
||||||
Expect(filepath.Join(runContainerStorageDir, "containers.json")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(runContainerStorageDir, "containers.json")).Should(Not(BeAnExistingFile()))
|
||||||
Expect(filepath.Join(runContainerStorageDir, "volatile-containers.json")).Should(BeARegularFile())
|
Expect(filepath.Join(runContainerStorageDir, "volatile-containers.json")).Should(BeARegularFile())
|
||||||
|
|
||||||
|
if podmanTest.DatabaseBackend == "sqlite" {
|
||||||
|
Expect(filepath.Join(containerStorageDir, "db.sql")).Should(Not(BeAnExistingFile()))
|
||||||
|
Expect(filepath.Join(runContainerStorageDir, "db.sql")).Should(BeARegularFile())
|
||||||
|
} else {
|
||||||
Expect(filepath.Join(dbDir, "bolt_state.db")).Should(Not(BeAnExistingFile()))
|
Expect(filepath.Join(dbDir, "bolt_state.db")).Should(Not(BeAnExistingFile()))
|
||||||
Expect(filepath.Join(runDBDir, "bolt_state.db")).Should(BeARegularFile())
|
Expect(filepath.Join(runDBDir, "bolt_state.db")).Should(BeARegularFile())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue