diff options
author | Fabricio Voznika <fvoznika@google.com> | 2020-11-05 18:16:11 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-11-05 18:18:21 -0800 |
commit | 62b0e845b7301da7d0c75eb812e9cd75ade05b74 (patch) | |
tree | 98fef994113d5887930d94b5b0947572a8204e81 /runsc/cmd/events.go | |
parent | f27edcc708e412b5c5bbeb0c274837af94c625cc (diff) |
Return failure when `runsc events` queries a stopped container
This was causing gvisor-containerd-shim to crash because the command
suceeded, but there was no stat present.
PiperOrigin-RevId: 340964921
Diffstat (limited to 'runsc/cmd/events.go')
-rw-r--r-- | runsc/cmd/events.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/runsc/cmd/events.go b/runsc/cmd/events.go index 5211ad4ce..3836b7b4e 100644 --- a/runsc/cmd/events.go +++ b/runsc/cmd/events.go @@ -85,7 +85,12 @@ func (evs *Events) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa ev, err := c.Event() if err != nil { log.Warningf("Error getting events for container: %v", err) + if evs.stats { + return subcommands.ExitFailure + } } + log.Debugf("Events: %+v", ev) + // err must be preserved because it is used below when breaking // out of the loop. b, err := json.Marshal(ev) @@ -101,11 +106,9 @@ func (evs *Events) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa if err != nil { return subcommands.ExitFailure } - break + return subcommands.ExitSuccess } time.Sleep(time.Duration(evs.intervalSec) * time.Second) } - - return subcommands.ExitSuccess } |