From 1a439f9fcbbc6a2b509c1ca7e23207a07a652399 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 31 Jul 2018 09:26:06 -0400 Subject: Ensure container and pod refresh picks up a State refresh() is the only major command we had that did not perform a sync before running, and thus was not guaranteed to pick up a good copy of the state. Fix this by updating the state before a refresh(). Signed-off-by: Matthew Heon Closes: #1186 Approved by: rhatdan --- libpod/container_internal.go | 6 ++++++ libpod/pod.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 2f258d007..66d1e44ad 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -329,6 +329,12 @@ func resetState(state *containerState) error { // Refresh refreshes the container's state after a restart func (c *Container) refresh() error { + // Don't need a full sync, but we do need to update from the database to + // pick up potentially-missing container state + if err := c.runtime.state.UpdateContainer(c); err != nil { + return err + } + if !c.valid { return errors.Wrapf(ErrCtrRemoved, "container %s is not valid - may have been removed", c.ID()) } diff --git a/libpod/pod.go b/libpod/pod.go index 9ea1f058b..2ad4f7d0e 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -154,6 +154,11 @@ func (p *Pod) save() error { // Refresh a pod's state after restart func (p *Pod) refresh() error { + // Need to to an update from the DB to pull potentially-missing state + if err := p.runtime.state.UpdatePod(p); err != nil { + return err + } + if !p.valid { return ErrPodRemoved } -- cgit v1.2.3-54-g00ecf