summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podmanV2/system/events.go104
-rwxr-xr-xcontrib/cirrus/logformatter8
-rw-r--r--go.mod2
-rw-r--r--go.sum2
-rw-r--r--pkg/api/handlers/types.go25
-rw-r--r--pkg/domain/entities/engine_container.go1
-rw-r--r--pkg/domain/entities/types.go10
-rw-r--r--pkg/domain/infra/abi/events.go18
-rw-r--r--pkg/domain/infra/tunnel/events.go31
-rwxr-xr-xtest/apiv2/test-apiv22
-rw-r--r--vendor/github.com/containers/common/pkg/config/config.go4
-rw-r--r--vendor/github.com/containers/common/pkg/config/containers.conf10
-rw-r--r--vendor/github.com/containers/common/pkg/config/default.go3
-rw-r--r--vendor/modules.txt2
14 files changed, 217 insertions, 5 deletions
diff --git a/cmd/podmanV2/system/events.go b/cmd/podmanV2/system/events.go
new file mode 100644
index 000000000..9fd27e2c1
--- /dev/null
+++ b/cmd/podmanV2/system/events.go
@@ -0,0 +1,104 @@
+package system
+
+import (
+ "bufio"
+ "context"
+ "html/template"
+ "os"
+
+ "github.com/containers/buildah/pkg/formats"
+ "github.com/containers/libpod/cmd/podmanV2/registry"
+ "github.com/containers/libpod/libpod/events"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+)
+
+var (
+ eventsDescription = "Monitor podman events"
+ eventsCommand = &cobra.Command{
+ Use: "events",
+ Args: cobra.NoArgs,
+ Short: "Show podman events",
+ Long: eventsDescription,
+ PersistentPreRunE: preRunE,
+ RunE: eventsCmd,
+ Example: `podman events
+ podman events --filter event=create
+ podman events --since 1h30s`,
+ }
+)
+
+var (
+ eventOptions entities.EventsOptions
+ eventFormat string
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: eventsCommand,
+ })
+ flags := eventsCommand.Flags()
+ flags.StringArrayVar(&eventOptions.Filter, "filter", []string{}, "filter output")
+ flags.StringVar(&eventFormat, "format", "", "format the output using a Go template")
+ flags.BoolVar(&eventOptions.Stream, "stream", true, "stream new events; for testing only")
+ flags.StringVar(&eventOptions.Since, "since", "", "show all events created since timestamp")
+ flags.StringVar(&eventOptions.Until, "until", "", "show all events until timestamp")
+ _ = flags.MarkHidden("stream")
+}
+
+func eventsCmd(cmd *cobra.Command, args []string) error {
+ var (
+ err error
+ eventsError error
+ tmpl *template.Template
+ )
+ if eventFormat != formats.JSONString {
+ tmpl, err = template.New("events").Parse(eventFormat)
+ if err != nil {
+ return err
+ }
+ }
+ if len(eventOptions.Since) > 0 || len(eventOptions.Until) > 0 {
+ eventOptions.FromStart = true
+ }
+ eventChannel := make(chan *events.Event)
+ eventOptions.EventChan = eventChannel
+
+ go func() {
+ eventsError = registry.ContainerEngine().Events(context.Background(), eventOptions)
+ }()
+ if eventsError != nil {
+ return eventsError
+ }
+
+ w := bufio.NewWriter(os.Stdout)
+ for event := range eventChannel {
+ switch {
+ case eventFormat == formats.JSONString:
+ jsonStr, err := event.ToJSONString()
+ if err != nil {
+ return errors.Wrapf(err, "unable to format json")
+ }
+ if _, err := w.Write([]byte(jsonStr)); err != nil {
+ return err
+ }
+ case len(eventFormat) > 0:
+ if err := tmpl.Execute(w, event); err != nil {
+ return err
+ }
+ default:
+ if _, err := w.Write([]byte(event.ToHumanReadable())); err != nil {
+ return err
+ }
+ }
+ if _, err := w.Write([]byte("\n")); err != nil {
+ return err
+ }
+ if err := w.Flush(); err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/contrib/cirrus/logformatter b/contrib/cirrus/logformatter
index 6a86f6a49..738d2e19d 100755
--- a/contrib/cirrus/logformatter
+++ b/contrib/cirrus/logformatter
@@ -220,8 +220,8 @@ END_HTML
$cirrus_task = $1;
}
- # BATS handling
- if ($line =~ /^1\.\.\d+$/) {
+ # BATS handling (used also for apiv2 tests, which emit TAP output)
+ if ($line =~ /^1\.\.\d+$/ || $line =~ m!/test-apiv2!) {
$looks_like_bats = 1;
}
if ($looks_like_bats) {
@@ -234,6 +234,10 @@ END_HTML
elsif ($line =~ /^#\s/) { $css = 'log' }
if ($css) {
+ # Make it linkable, e.g. foo.html#t--00001
+ if ($line =~ /^(not\s+)?ok\s+(\d+)/) {
+ $line = sprintf("<a name='t--%05d'>%s</a>", $2, $line);
+ }
$line = "<span class='bats-$css'>$line</span>";
}
diff --git a/go.mod b/go.mod
index 08e52e83b..bfc30b198 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
github.com/containernetworking/cni v0.7.2-0.20200304161608-4fae32b84921
github.com/containernetworking/plugins v0.8.5
github.com/containers/buildah v1.14.8
- github.com/containers/common v0.8.1
+ github.com/containers/common v0.9.0
github.com/containers/conmon v2.0.14+incompatible
github.com/containers/image/v5 v5.4.3
github.com/containers/psgo v1.4.0
diff --git a/go.sum b/go.sum
index 2ca41f042..9940f4119 100644
--- a/go.sum
+++ b/go.sum
@@ -67,6 +67,8 @@ github.com/containers/buildah v1.14.8 h1:JbMI0QSOmyZ30Mr2633uCXAj+Fajgh/EFS9xX/Y
github.com/containers/buildah v1.14.8/go.mod h1:ytEjHJQnRXC1ygXMyc0FqYkjcoCydqBQkOdxbH563QU=
github.com/containers/common v0.8.1 h1:1IUwAtZ4mC7GYRr4AC23cHf2oXCuoLzTUoSzIkSgnYw=
github.com/containers/common v0.8.1/go.mod h1:VxDJbaA1k6N1TNv9Rt6bQEF4hyKVHNfOfGA5L91ADEs=
+github.com/containers/common v0.9.0 h1:mN4P8VK6e7lqQSl7oywfEnhMtSzi8DhkE2QaJHJp88w=
+github.com/containers/common v0.9.0/go.mod h1:9YGKPwu6NFYQG2NtSP9bRhNGA8mgd1mUCCkOU2tr+Pc=
github.com/containers/conmon v2.0.14+incompatible h1:knU1O1QxXy5YxtjMQVKEyCajROaehizK9FHaICl+P5Y=
github.com/containers/conmon v2.0.14+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
github.com/containers/image/v5 v5.4.3 h1:zn2HR7uu4hpvT5QQHgjqonOzKDuM1I1UHUEmzZT5sbs=
diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go
index f1c932ebc..0fe6ae6a7 100644
--- a/pkg/api/handlers/types.go
+++ b/pkg/api/handlers/types.go
@@ -180,6 +180,31 @@ type ExecCreateResponse struct {
docker.IDResponse
}
+func (e *Event) ToLibpodEvent() *events.Event {
+ exitCode, err := strconv.Atoi(e.Actor.Attributes["containerExitCode"])
+ if err != nil {
+ return nil
+ }
+ status, err := events.StringToStatus(e.Action)
+ if err != nil {
+ return nil
+ }
+ t, err := events.StringToType(e.Type)
+ if err != nil {
+ return nil
+ }
+ lp := events.Event{
+ ContainerExitCode: exitCode,
+ ID: e.Actor.ID,
+ Image: e.Actor.Attributes["image"],
+ Name: e.Actor.Attributes["name"],
+ Status: status,
+ Time: time.Unix(e.Time, e.TimeNano),
+ Type: t,
+ }
+ return &lp
+}
+
func EventToApiEvent(e *events.Event) *Event {
return &Event{dockerEvents.Message{
Type: e.Type.String(),
diff --git a/pkg/domain/entities/engine_container.go b/pkg/domain/entities/engine_container.go
index 2001ab49c..5fdb9a8a6 100644
--- a/pkg/domain/entities/engine_container.go
+++ b/pkg/domain/entities/engine_container.go
@@ -36,6 +36,7 @@ type ContainerEngine interface {
ContainerUnmount(ctx context.Context, nameOrIds []string, options ContainerUnmountOptions) ([]*ContainerUnmountReport, error)
ContainerUnpause(ctx context.Context, namesOrIds []string, options PauseUnPauseOptions) ([]*PauseUnpauseReport, error)
ContainerWait(ctx context.Context, namesOrIds []string, options WaitOptions) ([]WaitReport, error)
+ Events(ctx context.Context, opts EventsOptions) error
HealthCheckRun(ctx context.Context, nameOrId string, options HealthCheckOptions) (*define.HealthCheckResults, error)
Info(ctx context.Context) (*define.Info, error)
PodCreate(ctx context.Context, opts PodCreateOptions) (*PodCreateReport, error)
diff --git a/pkg/domain/entities/types.go b/pkg/domain/entities/types.go
index 7e35957f4..91ae00764 100644
--- a/pkg/domain/entities/types.go
+++ b/pkg/domain/entities/types.go
@@ -3,6 +3,7 @@ package entities
import (
"net"
+ "github.com/containers/libpod/libpod/events"
"github.com/containers/libpod/pkg/specgen"
"github.com/containers/storage/pkg/archive"
"github.com/cri-o/ocicni/pkg/ocicni"
@@ -62,3 +63,12 @@ type DiffOptions struct {
type DiffReport struct {
Changes []archive.Change
}
+
+type EventsOptions struct {
+ FromStart bool
+ EventChan chan *events.Event
+ Filter []string
+ Stream bool
+ Since string
+ Until string
+}
diff --git a/pkg/domain/infra/abi/events.go b/pkg/domain/infra/abi/events.go
new file mode 100644
index 000000000..9540a5b96
--- /dev/null
+++ b/pkg/domain/infra/abi/events.go
@@ -0,0 +1,18 @@
+//+build ABISupport
+
+package abi
+
+import (
+ "context"
+
+ "github.com/containers/libpod/libpod/events"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/sirupsen/logrus"
+)
+
+func (ic *ContainerEngine) Events(ctx context.Context, opts entities.EventsOptions) error {
+ readOpts := events.ReadOptions{FromStart: opts.FromStart, Stream: opts.Stream, Filters: opts.Filter, EventChannel: opts.EventChan, Since: opts.Since, Until: opts.Until}
+ err := ic.Libpod.Events(readOpts)
+ logrus.Error(err)
+ return err
+}
diff --git a/pkg/domain/infra/tunnel/events.go b/pkg/domain/infra/tunnel/events.go
new file mode 100644
index 000000000..46d88341a
--- /dev/null
+++ b/pkg/domain/infra/tunnel/events.go
@@ -0,0 +1,31 @@
+package tunnel
+
+import (
+ "context"
+ "strings"
+
+ "github.com/containers/libpod/pkg/api/handlers"
+ "github.com/containers/libpod/pkg/bindings/system"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/pkg/errors"
+)
+
+func (ic *ContainerEngine) Events(ctx context.Context, opts entities.EventsOptions) error {
+ filters := make(map[string][]string)
+ if len(opts.Filter) > 0 {
+ for _, filter := range opts.Filter {
+ split := strings.Split(filter, "=")
+ if len(split) < 2 {
+ return errors.Errorf("invalid filter %q", filter)
+ }
+ filters[split[0]] = append(filters[split[0]], strings.Join(split[1:], "="))
+ }
+ }
+ binChan := make(chan handlers.Event)
+ go func() {
+ for e := range binChan {
+ opts.EventChan <- e.ToLibpodEvent()
+ }
+ }()
+ return system.Events(ic.ClientCxt, binChan, nil, &opts.Since, &opts.Until, filters)
+}
diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2
index b101be012..1af76b4be 100755
--- a/test/apiv2/test-apiv2
+++ b/test/apiv2/test-apiv2
@@ -355,7 +355,7 @@ done
if [ -n "$service_pid" ]; then
kill $service_pid
- wait -f $service_pid
+ wait $service_pid
fi
test_count=$(<$testcounter_file)
diff --git a/vendor/github.com/containers/common/pkg/config/config.go b/vendor/github.com/containers/common/pkg/config/config.go
index b65db2722..ef21f1d9f 100644
--- a/vendor/github.com/containers/common/pkg/config/config.go
+++ b/vendor/github.com/containers/common/pkg/config/config.go
@@ -271,6 +271,10 @@ type EngineConfig struct {
// running containers without CGroups.
RuntimeSupportsNoCgroups []string `toml:"runtime_supports_nocgroupv2"`
+ // RuntimeSupportsKVM is a list of OCI runtimes that support
+ // KVM separation for conatainers.
+ RuntimeSupportsKVM []string `toml:"runtime_supports_kvm"`
+
// SetOptions contains a subset of config options. It's used to indicate if
// a given option has either been set by the user or by the parsed
// configuration file. If not, the corresponding option might be
diff --git a/vendor/github.com/containers/common/pkg/config/containers.conf b/vendor/github.com/containers/common/pkg/config/containers.conf
index 067be429e..fbc691f1d 100644
--- a/vendor/github.com/containers/common/pkg/config/containers.conf
+++ b/vendor/github.com/containers/common/pkg/config/containers.conf
@@ -347,6 +347,14 @@
#
# runtime_supports_json = ["crun", "runc", "kata"]
+# List of the OCI runtimes that supports running containers without cgroups.
+#
+# runtime_supports_nocgroups = ["crun"]
+
+# List of the OCI runtimes that supports running containers with KVM Separation.
+#
+# runtime_supports_kvm = ["kata"]
+
# Paths to look for a valid OCI runtime (runc, runv, kata, etc)
[engine.runtimes]
# runc = [
@@ -376,6 +384,8 @@
# "/usr/local/sbin/kata-runtime",
# "/sbin/kata-runtime",
# "/bin/kata-runtime",
+# "/usr/bin/kata-qemu",
+# "/usr/bin/kata-fc",
# ]
# Number of seconds to wait for container to exit before sending kill signal.
diff --git a/vendor/github.com/containers/common/pkg/config/default.go b/vendor/github.com/containers/common/pkg/config/default.go
index 78bfd8a28..5f3af1f8d 100644
--- a/vendor/github.com/containers/common/pkg/config/default.go
+++ b/vendor/github.com/containers/common/pkg/config/default.go
@@ -246,6 +246,8 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
"/usr/local/sbin/kata-runtime",
"/sbin/kata-runtime",
"/bin/kata-runtime",
+ "/usr/bin/kata-qemu",
+ "/usr/bin/kata-fc",
},
}
c.ConmonEnvVars = []string{
@@ -267,6 +269,7 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
"runc",
}
c.RuntimeSupportsNoCgroups = []string{"crun"}
+ c.RuntimeSupportsKVM = []string{"kata", "kata-runtime", "kata-qemu", "kata-fc"}
c.InitPath = DefaultInitPath
c.NoPivotRoot = false
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 535090e81..9aa167530 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -82,7 +82,7 @@ github.com/containers/buildah/pkg/secrets
github.com/containers/buildah/pkg/supplemented
github.com/containers/buildah/pkg/umask
github.com/containers/buildah/util
-# github.com/containers/common v0.8.1
+# github.com/containers/common v0.9.0
github.com/containers/common/pkg/apparmor
github.com/containers/common/pkg/capabilities
github.com/containers/common/pkg/cgroupv2