diff options
-rw-r--r-- | .cirrus.yml | 6 | ||||
-rw-r--r-- | cmd/podman/common/create.go | 2 | ||||
-rw-r--r-- | cmd/podman/containers/stop.go | 3 | ||||
-rw-r--r-- | cmd/podman/containers/wait.go | 2 | ||||
-rw-r--r-- | cmd/podman/main.go | 9 | ||||
-rw-r--r-- | cmd/podman/registry/config.go | 16 | ||||
-rw-r--r-- | cmd/podman/registry/registry.go | 10 | ||||
-rw-r--r-- | cmd/podman/registry/remote.go | 2 | ||||
-rw-r--r-- | cmd/podman/root.go | 27 | ||||
-rwxr-xr-x | contrib/cirrus/logformatter | 47 | ||||
-rwxr-xr-x | contrib/cirrus/logformatter.t | 189 | ||||
-rw-r--r-- | libpod/networking_linux.go | 14 | ||||
-rw-r--r-- | pkg/domain/infra/runtime_abi.go | 4 | ||||
-rw-r--r-- | pkg/domain/infra/runtime_image_proxy.go | 2 | ||||
-rw-r--r-- | pkg/domain/infra/runtime_libpod.go | 14 | ||||
-rw-r--r-- | pkg/domain/infra/runtime_proxy.go | 2 | ||||
-rw-r--r-- | pkg/domain/infra/runtime_tunnel.go | 4 |
17 files changed, 294 insertions, 59 deletions
diff --git a/.cirrus.yml b/.cirrus.yml index d8b0a3bf9..e96994cfe 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -382,7 +382,6 @@ image_prune_task: # This task does the unit and integration testing for every platform testing_task: - skip: $CI == 'true' alias: "testing" depends_on: - "gating" @@ -391,6 +390,8 @@ testing_task: - "build_each_commit" - "build_without_cgo" + allow_failures: $CI == 'true' + # Only test build cache-images, if that's what's requested only_if: >- $CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' && @@ -427,7 +428,8 @@ testing_task: networking_script: '${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/networking.sh' setup_environment_script: '$SCRIPT_BASE/setup_environment.sh |& ${TIMESTAMP}' unit_test_script: '$SCRIPT_BASE/unit_test.sh |& ${TIMESTAMP}' - integration_test_script: '$SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} | ${LOGFORMAT} integration_test' + # FIXME + #integration_test_script: '$SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} | ${LOGFORMAT} integration_test' system_test_script: '$SCRIPT_BASE/system_test.sh |& ${TIMESTAMP} | ${LOGFORMAT} system_test' apiv2_test_script: '$SCRIPT_BASE/apiv2_test.sh |& ${TIMESTAMP} | ${LOGFORMAT} apiv2_test' diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index a7c8435c9..49a40dfa0 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -10,7 +10,7 @@ import ( const sizeWithUnitFormat = "(format: `<number>[<unit>]`, where unit = b (bytes), k (kilobytes), m (megabytes), or g (gigabytes))" -var containerConfig = registry.NewPodmanConfig() +var containerConfig = registry.PodmanConfig() func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet { createFlags := pflag.FlagSet{} diff --git a/cmd/podman/containers/stop.go b/cmd/podman/containers/stop.go index 1ee9186a7..c1560be08 100644 --- a/cmd/podman/containers/stop.go +++ b/cmd/podman/containers/stop.go @@ -45,7 +45,8 @@ func init() { flags.StringArrayVarP(&stopOptions.CIDFiles, "cidfile", "", nil, "Read the container ID from the file") flags.BoolVarP(&stopOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of") flags.UintVarP(&stopTimeout, "time", "t", defaultContainerConfig.Engine.StopTimeout, "Seconds to wait for stop before killing the container") - if registry.PodmanOptions.EngineMode == entities.ABIMode { + + if registry.IsRemote() { _ = flags.MarkHidden("latest") _ = flags.MarkHidden("cidfile") _ = flags.MarkHidden("ignore") diff --git a/cmd/podman/containers/wait.go b/cmd/podman/containers/wait.go index 83c164e16..47f28f4c6 100644 --- a/cmd/podman/containers/wait.go +++ b/cmd/podman/containers/wait.go @@ -43,7 +43,7 @@ func init() { flags.DurationVarP(&waitOptions.Interval, "interval", "i", time.Duration(250), "Milliseconds to wait before polling for completion") flags.BoolVarP(&waitOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of") flags.StringVar(&waitCondition, "condition", "stopped", "Condition to wait on") - if registry.PodmanOptions.EngineMode == entities.ABIMode { + if registry.IsRemote() { // TODO: This is the same as V1. We could skip creating the flag altogether in V2... _ = flags.MarkHidden("latest") } diff --git a/cmd/podman/main.go b/cmd/podman/main.go index 5f7bfe3c9..2d9e45177 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -14,12 +14,6 @@ import ( "github.com/containers/storage/pkg/reexec" ) -func init() { - // This is the bootstrap configuration, if user gives - // CLI flags parts of this configuration may be overwritten - registry.PodmanOptions = registry.NewPodmanConfig() -} - func main() { if reexec.Init() { // We were invoked with a different argv[0] indicating that we @@ -27,9 +21,10 @@ func main() { return } + cfg := registry.PodmanConfig() for _, c := range registry.Commands { for _, m := range c.Mode { - if registry.PodmanOptions.EngineMode == m { + if cfg.EngineMode == m { parent := rootCmd if c.Parent != nil { parent = c.Parent diff --git a/cmd/podman/registry/config.go b/cmd/podman/registry/config.go index 358f9172e..fc6eb538e 100644 --- a/cmd/podman/registry/config.go +++ b/cmd/podman/registry/config.go @@ -6,6 +6,7 @@ import ( "path/filepath" "runtime" "strings" + "sync" "github.com/containers/common/pkg/config" "github.com/containers/libpod/pkg/domain/entities" @@ -19,11 +20,18 @@ const ( ) var ( - PodmanOptions entities.PodmanConfig + podmanOptions entities.PodmanConfig + podmanSync sync.Once ) -// NewPodmanConfig creates a PodmanConfig from the environment -func NewPodmanConfig() entities.PodmanConfig { +// PodmanConfig returns an entities.PodmanConfig built up from +// environment and CLI +func PodmanConfig() *entities.PodmanConfig { + podmanSync.Do(newPodmanConfig) + return &podmanOptions +} + +func newPodmanConfig() { if err := setXdgDirs(); err != nil { fmt.Fprintf(os.Stderr, err.Error()) os.Exit(1) @@ -63,7 +71,7 @@ func NewPodmanConfig() entities.PodmanConfig { cfg.Network.NetworkConfigDir = "" } - return entities.PodmanConfig{Config: cfg, EngineMode: mode} + podmanOptions = entities.PodmanConfig{Config: cfg, EngineMode: mode} } // SetXdgDirs ensures the XDG_RUNTIME_DIR env and XDG_CONFIG_HOME variables are set. diff --git a/cmd/podman/registry/registry.go b/cmd/podman/registry/registry.go index 1c5e5d21b..2e9d59d10 100644 --- a/cmd/podman/registry/registry.go +++ b/cmd/podman/registry/registry.go @@ -49,8 +49,8 @@ func ImageEngine() entities.ImageEngine { // NewImageEngine is a wrapper for building an ImageEngine to be used for PreRunE functions func NewImageEngine(cmd *cobra.Command, args []string) (entities.ImageEngine, error) { if imageEngine == nil { - PodmanOptions.FlagSet = cmd.Flags() - engine, err := infra.NewImageEngine(PodmanOptions) + podmanOptions.FlagSet = cmd.Flags() + engine, err := infra.NewImageEngine(&podmanOptions) if err != nil { return nil, err } @@ -66,8 +66,8 @@ func ContainerEngine() entities.ContainerEngine { // NewContainerEngine is a wrapper for building an ContainerEngine to be used for PreRunE functions func NewContainerEngine(cmd *cobra.Command, args []string) (entities.ContainerEngine, error) { if containerEngine == nil { - PodmanOptions.FlagSet = cmd.Flags() - engine, err := infra.NewContainerEngine(PodmanOptions) + podmanOptions.FlagSet = cmd.Flags() + engine, err := infra.NewContainerEngine(&podmanOptions) if err != nil { return nil, err } @@ -101,7 +101,7 @@ func Context() context.Context { } func ContextWithOptions(ctx context.Context) context.Context { - cliCtx = context.WithValue(ctx, PodmanOptionsKey{}, PodmanOptions) + cliCtx = context.WithValue(ctx, PodmanOptionsKey{}, podmanOptions) return cliCtx } diff --git a/cmd/podman/registry/remote.go b/cmd/podman/registry/remote.go index 5378701e7..95870750e 100644 --- a/cmd/podman/registry/remote.go +++ b/cmd/podman/registry/remote.go @@ -5,5 +5,5 @@ import ( ) func IsRemote() bool { - return PodmanOptions.EngineMode == entities.TunnelMode + return podmanOptions.EngineMode == entities.TunnelMode } diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 259e10c55..667f7e588 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -77,12 +77,12 @@ func init() { syslogHook, ) - rootFlags(registry.PodmanOptions, rootCmd.PersistentFlags()) + rootFlags(registry.PodmanConfig(), rootCmd.PersistentFlags()) } func Execute() { if err := rootCmd.ExecuteContext(registry.GetContextWithOptions()); err != nil { - logrus.Error(err) + fmt.Fprintln(os.Stderr, "Error:", err.Error()) } else if registry.GetExitCode() == registry.ExecErrorCodeGeneric { // The exitCode modified from registry.ExecErrorCodeGeneric, // indicates an application @@ -98,9 +98,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error { // TODO: Remove trace statement in podman V2.1 logrus.Debugf("Called %s.PersistentPreRunE()", cmd.Name()) - // Update PodmanOptions now that we "know" more - // TODO: pass in path overriding configuration file - registry.PodmanOptions = registry.NewPodmanConfig() + cfg := registry.PodmanConfig() // Prep the engines if _, err := registry.NewImageEngine(cmd, args); err != nil { @@ -111,10 +109,10 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error { } if cmd.Flag("cpu-profile").Changed { - f, err := os.Create(registry.PodmanOptions.CpuProfile) + f, err := os.Create(cfg.CpuProfile) if err != nil { return errors.Wrapf(err, "unable to create cpu profiling file %s", - registry.PodmanOptions.CpuProfile) + cfg.CpuProfile) } if err := pprof.StartCPUProfile(f); err != nil { return err @@ -124,11 +122,11 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error { if cmd.Flag("trace").Changed { tracer, closer := tracing.Init("podman") opentracing.SetGlobalTracer(tracer) - registry.PodmanOptions.SpanCloser = closer + cfg.SpanCloser = closer - registry.PodmanOptions.Span = tracer.StartSpan("before-context") - registry.PodmanOptions.SpanCtx = opentracing.ContextWithSpan(registry.Context(), registry.PodmanOptions.Span) - opentracing.StartSpanFromContext(registry.PodmanOptions.SpanCtx, cmd.Name()) + cfg.Span = tracer.StartSpan("before-context") + cfg.SpanCtx = opentracing.ContextWithSpan(registry.Context(), cfg.Span) + opentracing.StartSpanFromContext(cfg.SpanCtx, cmd.Name()) } // Setup Rootless environment, IFF: @@ -149,12 +147,13 @@ func persistentPostRunE(cmd *cobra.Command, args []string) error { // TODO: Remove trace statement in podman V2.1 logrus.Debugf("Called %s.PersistentPostRunE()", cmd.Name()) + cfg := registry.PodmanConfig() if cmd.Flag("cpu-profile").Changed { pprof.StopCPUProfile() } if cmd.Flag("trace").Changed { - registry.PodmanOptions.Span.Finish() - registry.PodmanOptions.SpanCloser.Close() + cfg.Span.Finish() + cfg.SpanCloser.Close() } return nil } @@ -199,7 +198,7 @@ func syslogHook() { } } -func rootFlags(opts entities.PodmanConfig, flags *pflag.FlagSet) { +func rootFlags(opts *entities.PodmanConfig, flags *pflag.FlagSet) { // V2 flags flags.StringVarP(&opts.Uri, "remote", "r", "", "URL to access Podman service") flags.StringSliceVar(&opts.Identities, "identity", []string{}, "path to SSH identity file") diff --git a/contrib/cirrus/logformatter b/contrib/cirrus/logformatter index 738d2e19d..4bfe7b97f 100755 --- a/contrib/cirrus/logformatter +++ b/contrib/cirrus/logformatter @@ -52,12 +52,14 @@ a.codelink:hover { background: #000; color: #999; } a.timing { text-decoration: none; } /* BATS styles */ -.bats-ok { color: #393; } -.bats-notok { color: #F00; font-weight: bold; } -.bats-skip { color: #F90; } +.bats-passed { color: #393; } +.bats-failed { color: #F00; font-weight: bold; } +.bats-skipped { color: #F90; } .bats-log { color: #900; } .bats-log-esm { color: #b00; font-weight: bold; } +.bats-summary { font-size: 150%; } + /* error titles: display next to timestamp, not on separate line */ h2 { display: inline; } END_CSS @@ -169,7 +171,7 @@ window.addEventListener("load", scrollToBottom, false); </script> </head> <body> -<pre> +<pre> <!-- begin processed output --> END_HTML # State variables @@ -181,6 +183,7 @@ END_HTML my $after_divider = 0; # Count of lines after seeing '-----' my $current_output; # for removing duplication my $looks_like_bats; # binary flag: for detecting BATS results + my %bats_count; # For summary line: count of pass/fail/skip # Main loop: read input, one line at a time, and write out reformatted LINE: @@ -221,15 +224,16 @@ END_HTML } # BATS handling (used also for apiv2 tests, which emit TAP output) - if ($line =~ /^1\.\.\d+$/ || $line =~ m!/test-apiv2!) { + if ($line =~ /^1\.\.(\d+)$/ || $line =~ m!/test-apiv2!) { $looks_like_bats = 1; + $bats_count{expected_total} = $1; } if ($looks_like_bats) { my $css; - if ($line =~ /^ok\s.*\s# skip/) { $css = 'skip' } - elsif ($line =~ /^ok\s/) { $css = 'ok' } - elsif ($line =~ /^not\s+ok\s/) { $css = 'notok' } + if ($line =~ /^ok\s.*\s# skip/) { $css = 'skipped' } + elsif ($line =~ /^ok\s/) { $css = 'passed' } + elsif ($line =~ /^not\s+ok\s/) { $css = 'failed' } elsif ($line =~ /^#\s#\|\s/) { $css = 'log-esm' } elsif ($line =~ /^#\s/) { $css = 'log' } @@ -239,6 +243,8 @@ END_HTML $line = sprintf("<a name='t--%05d'>%s</a>", $2, $line); } $line = "<span class='bats-$css'>$line</span>"; + + $bats_count{$css}++; } print { $out_fh } "<span class=\"timestamp\">$timestamp</span>" @@ -354,7 +360,30 @@ END_HTML my $have_formatted_log; # Set on success if ($out_fh) { - print { $out_fh } "</pre>\n"; + # Summary line for BATS tests + if (keys %bats_count) { + print { $out_fh } "<hr/><span class='bats-summary'>Summary:"; + my $total = 0; + my $comma = ''; + for my $class (qw(passed failed skipped)) { + if (my $n = $bats_count{$class}) { + printf { $out_fh } "%s <span class='bats-%s'>%d %s</span>", + $comma, $class, $n, ucfirst($class); + $total += $n; + $comma = ','; + } + } + + printf { $out_fh } ". Total tests: $total"; + if (my $expected_total = $bats_count{expected_total}) { + if ($total != $expected_total) { + print { $out_fh } " <span class='bats-failed'>(WARNING: expected $expected_total)</span>"; + } + } + print { $out_fh } "</span>\n"; + } + + print { $out_fh } "</pre> <!-- end processed output -->\n"; # Did we find a cirrus task? Link back. if ($cirrus_task) { diff --git a/contrib/cirrus/logformatter.t b/contrib/cirrus/logformatter.t new file mode 100755 index 000000000..79c4563c2 --- /dev/null +++ b/contrib/cirrus/logformatter.t @@ -0,0 +1,189 @@ +#!/usr/bin/perl +# +# tests for logformatter +# +(our $ME = $0) =~ s|^.*/||; + +use v5.14; +use strict; +use warnings; + +use FindBin; +use File::Temp qw(tempdir); +use Test::More; + +# +# Read the test cases (see __END__ section below) +# +my @tests; +my $context = ''; +while (my $line = <DATA>) { + chomp $line; + + if ($line =~ /^==\s+(.*)/) { + push @tests, { name => $1, input => [], expect => [] }; + $context = ''; + } + elsif ($line =~ /^<<</) { + $context = 'input'; + } + elsif ($line =~ /^>>>/) { + $context = 'expect'; + } + elsif (@tests && $line) { + push @{ $tests[-1]{$context} }, $line; + } +} + +plan tests => scalar(@tests); + +my $tempdir = tempdir("logformatter-test.XXXXXX", TMPDIR => 1, CLEANUP => !$ENV{DEBUG}); + +chdir $tempdir + or die "$ME: Could not cd $tempdir: $!\n"; + +for my $t (@tests) { + my $name = $t->{name}; + (my $fname = $name) =~ s/\s+/_/g; + + open my $fh_out, '>', "$fname.txt" + or die "$ME: Cannot create $tempdir/$fname.txt: $!\n"; + print { $fh_out } "$_\n" for @{$t->{input}}; + close $fh_out + or die "$ME: Error writing $tempdir/$fname.txt: $!\n"; + + system("$FindBin::Bin/logformatter $fname <$fname.txt >/dev/null"); + open my $fh_in, '<', "$fname.log.html" + or die "$ME: Fatal: $fname: logformatter did not create .log.html\n"; + my @actual; + while (my $line = <$fh_in>) { + chomp $line; + push @actual, $line if $line =~ / begin processed output / .. $line =~ / end processed output /; + } + close $fh_in; + + # Strip off leading and trailing "<pre>" + shift @actual; pop @actual; + + # For debugging: preserve expected results + if ($ENV{DEBUG}) { + open my $fh_out, '>', "$fname.expect"; + print { $fh_out } "$_\n" for @{$t->{expect}}; + close $fh_out; + } + + is_deeply \@actual, $t->{expect}, $name; +} + +chdir '/'; + + + +__END__ + +== simple bats + +<<< +1..4 +ok 1 hi +ok 2 bye # skip no reason +not ok 3 fail +ok 4 blah +>>> +1..4 +<span class='bats-passed'><a name='t--00001'>ok 1 hi</a></span> +<span class='bats-skipped'><a name='t--00002'>ok 2 bye # skip no reason</a></span> +<span class='bats-failed'><a name='t--00003'>not ok 3 fail</a></span> +<span class='bats-passed'><a name='t--00004'>ok 4 blah</a></span> +<hr/><span class='bats-summary'>Summary: <span class='bats-passed'>2 Passed</span>, <span class='bats-failed'>1 Failed</span>, <span class='bats-skipped'>1 Skipped</span>. Total tests: 4</span> + + + + + + + +== simple ginkgo + +<<< +$SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} +[08:26:19] START - All [+xxxx] lines that follow are relative to right now. +[+0002s] GO111MODULE=on go build -mod=vendor -gcflags 'all=-trimpath=/var/tmp/go/src/github.com/containers/libpod' -asmflags 'all=-trimpath=/var/tmp/go/src/github.com/containers/libpod' -ldflags '-X github.com/containers/libpod/libpod/define.gitCommit=40f5d8b1becd381c4e8283ed3940d09193e4fe06 -X github.com/containers/libpod/libpod/define.buildInfo=1582809981 -X github.com/containers/libpod/libpod/config._installPrefix=/usr/local -X github.com/containers/libpod/libpod/config._etcDir=/etc -extldflags ""' -tags " selinux systemd exclude_graphdriver_devicemapper seccomp varlink" -o bin/podman github.com/containers/libpod/cmd/podman +[+0103s] • +[+0103s] ------------------------------ +[+0103s] Podman pod restart +[+0103s] podman pod restart single empty pod +[+0103s] /var/tmp/go/src/github.com/containers/libpod/test/e2e/pod_restart_test.go:41 +[+0103s] [BeforeEach] Podman pod restart +[+0103s] /var/tmp/go/src/github.com/containers/libpod/test/e2e/pod_restart_test.go:18 +[+0103s] [It] podman pod restart single empty pod +[+0103s] /var/tmp/go/src/github.com/containers/libpod/test/e2e/pod_restart_test.go:41 +[+0103s] Running: /var/tmp/go/src/github.com/containers/libpod/bin/podman --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --cni-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs pod create --infra=false --share +[+0103s] 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 +[+0103s] output: 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 +[+0103s] Running: /var/tmp/go/src/github.com/containers/libpod/bin/podman --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --cni-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs pod restart 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 +[+0103s] Error: no containers in pod 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 have no dependencies, cannot start pod: no such container +[+0103s] output: +[+0103s] [AfterEach] Podman pod restart +[+0103s] /var/tmp/go/src/github.com/containers/libpod/test/e2e/pod_restart_test.go:28 +[+0103s] Running: /var/tmp/go/src/github.com/containers/libpod/bin/podman --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --cni-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs pod rm -fa +[+0103s] 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 +[+0107s] • +[+0107s] ------------------------------ +[+0107s] podman system reset +>>> +$SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} +[08:26:19] START - All [+xxxx] lines that follow are relative to right now. +<span class="timestamp">[+0002s] </span>GO111MODULE=on go build -mod=vendor -gcflags 'all=-trimpath=/var/tmp/go/src/github.com/containers/libpod' -asmflags 'all=-trimpath=/var/tmp/go/src/github.com/containers/libpod' -ldflags '-X github.com/containers/libpod/libpod/define.gitCommit=40f5d8b1becd381c4e8283ed3940d09193e4fe06 -X github.com/containers/libpod/libpod/define.buildInfo=1582809981 -X github.com/containers/libpod/libpod/config._installPrefix=/usr/local -X github.com/containers/libpod/libpod/config._etcDir=/etc -extldflags ""' -tags " selinux systemd exclude_graphdriver_devicemapper seccomp varlink" -o bin/podman github.com/containers/libpod/cmd/podman +<span class="timestamp">[+0103s] </span>• +</pre> +<hr /> +<pre> +<span class="timestamp">[+0103s] </span>Podman pod restart +<span class="timestamp"> </span><a name='t--podman-pod-restart-single-empty-pod--1'><h2> podman pod restart single empty pod</h2></a> +<span class="timestamp"> </span> /var/tmp/go/src/github.com<a class="codelink" href='https://github.com/containers/libpod/blob/40f5d8b1becd381c4e8283ed3940d09193e4fe06/test/e2e/pod_restart_test.go#L41'>/containers/libpod/test/e2e/pod_restart_test.go:41</a> +<span class="timestamp"> </span>[BeforeEach] Podman pod restart +<span class="timestamp"> </span> /var/tmp/go/src/github.com<a class="codelink" href='https://github.com/containers/libpod/blob/40f5d8b1becd381c4e8283ed3940d09193e4fe06/test/e2e/pod_restart_test.go#L18'>/containers/libpod/test/e2e/pod_restart_test.go:18</a> +<span class="timestamp"> </span>[It] podman pod restart single empty pod +<span class="timestamp"> </span> /var/tmp/go/src/github.com<a class="codelink" href='https://github.com/containers/libpod/blob/40f5d8b1becd381c4e8283ed3940d09193e4fe06/test/e2e/pod_restart_test.go#L41'>/containers/libpod/test/e2e/pod_restart_test.go:41</a> +<span class="timestamp"> </span>Running: <span title="/var/tmp/go/src/github.com/containers/libpod/bin/podman"><b>podman</b></span> <span class="boring" title="--storage-opt vfs.imagestore=/tmp/podman/imagecachedir +--root /tmp/podman_test553496330/crio +--runroot /tmp/podman_test553496330/crio-run +--runtime /usr/bin/runc +--conmon /usr/bin/conmon +--cni-config-dir /etc/cni/net.d +--cgroup-manager systemd +--tmpdir /tmp/podman_test553496330 +--events-backend file +--storage-driver vfs">[options]</span><b> pod create --infra=false --share</b> +<span class="timestamp"> </span>4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 +<span class="timestamp"> </span>Running: <span title="/var/tmp/go/src/github.com/containers/libpod/bin/podman"><b>podman</b></span> <span class="boring" title="--storage-opt vfs.imagestore=/tmp/podman/imagecachedir +--root /tmp/podman_test553496330/crio +--runroot /tmp/podman_test553496330/crio-run +--runtime /usr/bin/runc +--conmon /usr/bin/conmon +--cni-config-dir /etc/cni/net.d +--cgroup-manager systemd +--tmpdir /tmp/podman_test553496330 +--events-backend file +--storage-driver vfs">[options]</span><b> pod restart 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89</b> +<span class="timestamp"> </span><span class='log-warn'>Error: no containers in pod 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 have no dependencies, cannot start pod: no such container</span> +<span class="timestamp"> </span>output: +<span class="timestamp"> </span>[AfterEach] Podman pod restart +<span class="timestamp"> </span> /var/tmp/go/src/github.com<a class="codelink" href='https://github.com/containers/libpod/blob/40f5d8b1becd381c4e8283ed3940d09193e4fe06/test/e2e/pod_restart_test.go#L28'>/containers/libpod/test/e2e/pod_restart_test.go:28</a> +<span class="timestamp"> </span>Running: <span title="/var/tmp/go/src/github.com/containers/libpod/bin/podman"><b>podman</b></span> <span class="boring" title="--storage-opt vfs.imagestore=/tmp/podman/imagecachedir +--root /tmp/podman_test553496330/crio +--runroot /tmp/podman_test553496330/crio-run +--runtime /usr/bin/runc +--conmon /usr/bin/conmon +--cni-config-dir /etc/cni/net.d +--cgroup-manager systemd +--tmpdir /tmp/podman_test553496330 +--events-backend file +--storage-driver vfs">[options]</span><b> pod rm -fa</b> +<span class="timestamp"> </span>4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 +<span class="timestamp">[+0107s] </span>• +</pre> +<hr /> +<pre> +<span class="timestamp">[+0107s] </span>podman system reset diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index c3a90f481..83344ebbe 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -101,7 +101,19 @@ func (r *Runtime) configureNetNS(ctr *Container, ctrNS ns.NetNS) ([]*cnitypes.Re requestedMAC = ctr.config.StaticMAC } - podNetwork := r.getPodNetwork(ctr.ID(), ctr.Name(), ctrNS.Path(), ctr.config.Networks, ctr.config.PortMappings, requestedIP, requestedMAC) + // If we are in a pod use the pod name for the network, otherwise the container name + var podName string + if ctr.PodID() != "" { + pod, err := r.GetPod(ctr.PodID()) + if err == nil { + podName = pod.Name() + } + } + if podName == "" { + podName = ctr.Name() + } + + podNetwork := r.getPodNetwork(ctr.ID(), podName, ctrNS.Path(), ctr.config.Networks, ctr.config.PortMappings, requestedIP, requestedMAC) results, err := r.netPlugin.SetUpPod(podNetwork) if err != nil { diff --git a/pkg/domain/infra/runtime_abi.go b/pkg/domain/infra/runtime_abi.go index 0dbcf2ad2..7aa6986a7 100644 --- a/pkg/domain/infra/runtime_abi.go +++ b/pkg/domain/infra/runtime_abi.go @@ -12,7 +12,7 @@ import ( ) // NewContainerEngine factory provides a libpod runtime for container-related operations -func NewContainerEngine(facts entities.PodmanConfig) (entities.ContainerEngine, error) { +func NewContainerEngine(facts *entities.PodmanConfig) (entities.ContainerEngine, error) { switch facts.EngineMode { case entities.ABIMode: r, err := NewLibpodRuntime(facts.FlagSet, facts) @@ -25,7 +25,7 @@ func NewContainerEngine(facts entities.PodmanConfig) (entities.ContainerEngine, } // NewContainerEngine factory provides a libpod runtime for image-related operations -func NewImageEngine(facts entities.PodmanConfig) (entities.ImageEngine, error) { +func NewImageEngine(facts *entities.PodmanConfig) (entities.ImageEngine, error) { switch facts.EngineMode { case entities.ABIMode: r, err := NewLibpodImageRuntime(facts.FlagSet, facts) diff --git a/pkg/domain/infra/runtime_image_proxy.go b/pkg/domain/infra/runtime_image_proxy.go index 535fba858..ea5d0e6f2 100644 --- a/pkg/domain/infra/runtime_image_proxy.go +++ b/pkg/domain/infra/runtime_image_proxy.go @@ -12,7 +12,7 @@ import ( // ContainerEngine Image Proxy will be EOL'ed after podman is separated from libpod repo -func NewLibpodImageRuntime(flags *pflag.FlagSet, opts entities.PodmanConfig) (entities.ImageEngine, error) { +func NewLibpodImageRuntime(flags *pflag.FlagSet, opts *entities.PodmanConfig) (entities.ImageEngine, error) { r, err := GetRuntime(context.Background(), flags, opts) if err != nil { return nil, err diff --git a/pkg/domain/infra/runtime_libpod.go b/pkg/domain/infra/runtime_libpod.go index e335dd560..dc59fec3d 100644 --- a/pkg/domain/infra/runtime_libpod.go +++ b/pkg/domain/infra/runtime_libpod.go @@ -24,11 +24,11 @@ type engineOpts struct { migrate bool noStore bool withFDS bool - config entities.PodmanConfig + config *entities.PodmanConfig } // GetRuntimeMigrate gets a libpod runtime that will perform a migration of existing containers -func GetRuntimeMigrate(ctx context.Context, fs *flag.FlagSet, cfg entities.PodmanConfig, newRuntime string) (*libpod.Runtime, error) { +func GetRuntimeMigrate(ctx context.Context, fs *flag.FlagSet, cfg *entities.PodmanConfig, newRuntime string) (*libpod.Runtime, error) { return getRuntime(ctx, fs, &engineOpts{ name: newRuntime, renumber: false, @@ -40,7 +40,7 @@ func GetRuntimeMigrate(ctx context.Context, fs *flag.FlagSet, cfg entities.Podma } // GetRuntimeDisableFDs gets a libpod runtime that will disable sd notify -func GetRuntimeDisableFDs(ctx context.Context, fs *flag.FlagSet, cfg entities.PodmanConfig) (*libpod.Runtime, error) { +func GetRuntimeDisableFDs(ctx context.Context, fs *flag.FlagSet, cfg *entities.PodmanConfig) (*libpod.Runtime, error) { return getRuntime(ctx, fs, &engineOpts{ renumber: false, migrate: false, @@ -51,7 +51,7 @@ func GetRuntimeDisableFDs(ctx context.Context, fs *flag.FlagSet, cfg entities.Po } // GetRuntimeRenumber gets a libpod runtime that will perform a lock renumber -func GetRuntimeRenumber(ctx context.Context, fs *flag.FlagSet, cfg entities.PodmanConfig) (*libpod.Runtime, error) { +func GetRuntimeRenumber(ctx context.Context, fs *flag.FlagSet, cfg *entities.PodmanConfig) (*libpod.Runtime, error) { return getRuntime(ctx, fs, &engineOpts{ renumber: true, migrate: false, @@ -62,7 +62,7 @@ func GetRuntimeRenumber(ctx context.Context, fs *flag.FlagSet, cfg entities.Podm } // GetRuntime generates a new libpod runtime configured by command line options -func GetRuntime(ctx context.Context, flags *flag.FlagSet, cfg entities.PodmanConfig) (*libpod.Runtime, error) { +func GetRuntime(ctx context.Context, flags *flag.FlagSet, cfg *entities.PodmanConfig) (*libpod.Runtime, error) { return getRuntime(ctx, flags, &engineOpts{ renumber: false, migrate: false, @@ -73,7 +73,7 @@ func GetRuntime(ctx context.Context, flags *flag.FlagSet, cfg entities.PodmanCon } // GetRuntimeNoStore generates a new libpod runtime configured by command line options -func GetRuntimeNoStore(ctx context.Context, fs *flag.FlagSet, cfg entities.PodmanConfig) (*libpod.Runtime, error) { +func GetRuntimeNoStore(ctx context.Context, fs *flag.FlagSet, cfg *entities.PodmanConfig) (*libpod.Runtime, error) { return getRuntime(ctx, fs, &engineOpts{ renumber: false, migrate: false, @@ -160,7 +160,7 @@ func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpo } if fs.Changed("runtime") { - options = append(options, libpod.WithOCIRuntime(cfg.Engine.OCIRuntime)) + options = append(options, libpod.WithOCIRuntime(cfg.RuntimePath)) } if fs.Changed("conmon") { diff --git a/pkg/domain/infra/runtime_proxy.go b/pkg/domain/infra/runtime_proxy.go index fbe45ea8f..41193fd89 100644 --- a/pkg/domain/infra/runtime_proxy.go +++ b/pkg/domain/infra/runtime_proxy.go @@ -12,7 +12,7 @@ import ( // ContainerEngine Proxy will be EOL'ed after podman is separated from libpod repo -func NewLibpodRuntime(flags *flag.FlagSet, opts entities.PodmanConfig) (entities.ContainerEngine, error) { +func NewLibpodRuntime(flags *flag.FlagSet, opts *entities.PodmanConfig) (entities.ContainerEngine, error) { r, err := GetRuntime(context.Background(), flags, opts) if err != nil { return nil, err diff --git a/pkg/domain/infra/runtime_tunnel.go b/pkg/domain/infra/runtime_tunnel.go index 129fdeb2c..752218aaf 100644 --- a/pkg/domain/infra/runtime_tunnel.go +++ b/pkg/domain/infra/runtime_tunnel.go @@ -11,7 +11,7 @@ import ( "github.com/containers/libpod/pkg/domain/infra/tunnel" ) -func NewContainerEngine(facts entities.PodmanConfig) (entities.ContainerEngine, error) { +func NewContainerEngine(facts *entities.PodmanConfig) (entities.ContainerEngine, error) { switch facts.EngineMode { case entities.ABIMode: return nil, fmt.Errorf("direct runtime not supported") @@ -23,7 +23,7 @@ func NewContainerEngine(facts entities.PodmanConfig) (entities.ContainerEngine, } // NewImageEngine factory provides a libpod runtime for image-related operations -func NewImageEngine(facts entities.PodmanConfig) (entities.ImageEngine, error) { +func NewImageEngine(facts *entities.PodmanConfig) (entities.ImageEngine, error) { switch facts.EngineMode { case entities.ABIMode: return nil, fmt.Errorf("direct image runtime not supported") |