mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Merge pull request #3927 from openSUSE/manager-annotations
Add `ContainerManager` annotation to created containers
This commit is contained in:
@ -21,7 +21,7 @@ import (
|
|||||||
"github.com/containernetworking/plugins/pkg/ns"
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
"github.com/containers/buildah/pkg/secrets"
|
"github.com/containers/buildah/pkg/secrets"
|
||||||
"github.com/containers/libpod/libpod/define"
|
"github.com/containers/libpod/libpod/define"
|
||||||
crioAnnotations "github.com/containers/libpod/pkg/annotations"
|
"github.com/containers/libpod/pkg/annotations"
|
||||||
"github.com/containers/libpod/pkg/apparmor"
|
"github.com/containers/libpod/pkg/apparmor"
|
||||||
"github.com/containers/libpod/pkg/cgroups"
|
"github.com/containers/libpod/pkg/cgroups"
|
||||||
"github.com/containers/libpod/pkg/criu"
|
"github.com/containers/libpod/pkg/criu"
|
||||||
@ -349,9 +349,13 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g.SetRootPath(c.state.Mountpoint)
|
g.SetRootPath(c.state.Mountpoint)
|
||||||
g.AddAnnotation(crioAnnotations.Created, c.config.CreatedTime.Format(time.RFC3339Nano))
|
g.AddAnnotation(annotations.Created, c.config.CreatedTime.Format(time.RFC3339Nano))
|
||||||
g.AddAnnotation("org.opencontainers.image.stopSignal", fmt.Sprintf("%d", c.config.StopSignal))
|
g.AddAnnotation("org.opencontainers.image.stopSignal", fmt.Sprintf("%d", c.config.StopSignal))
|
||||||
|
|
||||||
|
if _, exists := g.Config.Annotations[annotations.ContainerManager]; !exists {
|
||||||
|
g.AddAnnotation(annotations.ContainerManager, annotations.ContainerManagerLibpod)
|
||||||
|
}
|
||||||
|
|
||||||
for _, i := range c.config.Spec.Linux.Namespaces {
|
for _, i := range c.config.Spec.Linux.Namespaces {
|
||||||
if i.Type == spec.UTSNamespace {
|
if i.Type == spec.UTSNamespace {
|
||||||
hostname := c.Hostname()
|
hostname := c.Hostname()
|
||||||
|
@ -102,6 +102,10 @@ const (
|
|||||||
|
|
||||||
// CNIResult is the JSON string representation of the Result from CNI
|
// CNIResult is the JSON string representation of the Result from CNI
|
||||||
CNIResult = "io.kubernetes.cri-o.CNIResult"
|
CNIResult = "io.kubernetes.cri-o.CNIResult"
|
||||||
|
|
||||||
|
// ContainerManager is the annotation key for indicating the creator and
|
||||||
|
// manager of the container
|
||||||
|
ContainerManager = "io.container.manager"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContainerType values
|
// ContainerType values
|
||||||
@ -112,3 +116,7 @@ const (
|
|||||||
// ContainerTypeContainer represents a container running within a pod
|
// ContainerTypeContainer represents a container running within a pod
|
||||||
ContainerTypeContainer = "container"
|
ContainerTypeContainer = "container"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ContainerManagerLibpod indicates that libpod created and manages the
|
||||||
|
// container
|
||||||
|
const ContainerManagerLibpod = "libpod"
|
||||||
|
45
test/e2e/container_inspect_test.go
Normal file
45
test/e2e/container_inspect_test.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/containers/libpod/pkg/annotations"
|
||||||
|
. "github.com/containers/libpod/test/utils"
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("Podman container inspect", func() {
|
||||||
|
var (
|
||||||
|
tempdir string
|
||||||
|
err error
|
||||||
|
podmanTest *PodmanTestIntegration
|
||||||
|
)
|
||||||
|
|
||||||
|
BeforeEach(func() {
|
||||||
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
|
if err != nil {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
podmanTest = PodmanTestCreate(tempdir)
|
||||||
|
podmanTest.Setup()
|
||||||
|
podmanTest.SeedImages()
|
||||||
|
})
|
||||||
|
|
||||||
|
AfterEach(func() {
|
||||||
|
podmanTest.CleanupPod()
|
||||||
|
f := CurrentGinkgoTestDescription()
|
||||||
|
processTestResult(f)
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman inspect a container for the container manager annotation", func() {
|
||||||
|
const testContainer = "container-inspect-test-1"
|
||||||
|
setup := podmanTest.RunTopContainer(testContainer)
|
||||||
|
setup.WaitWithDefaultTimeout()
|
||||||
|
Expect(setup.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
data := podmanTest.InspectContainer(testContainer)
|
||||||
|
Expect(data[0].Config.Annotations[annotations.ContainerManager]).
|
||||||
|
To(Equal(annotations.ContainerManagerLibpod))
|
||||||
|
})
|
||||||
|
})
|
Reference in New Issue
Block a user