diff --git a/command/taint.go b/command/taint.go index 4dc16e60c..4e0ea6a69 100644 --- a/command/taint.go +++ b/command/taint.go @@ -77,10 +77,6 @@ func (c *TaintCommand) Run(args []string) int { c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) return 1 } - if err := st.RefreshState(); err != nil { - c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) - return 1 - } if c.stateLock { stateLocker := clistate.NewLocker(context.Background(), c.stateLockTimeout, c.Ui, c.Colorize()) @@ -91,6 +87,11 @@ func (c *TaintCommand) Run(args []string) int { defer stateLocker.Unlock(nil) } + if err := st.RefreshState(); err != nil { + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) + return 1 + } + // Get the actual state structure s := st.State() if s.Empty() { diff --git a/command/untaint.go b/command/untaint.go index 39d047fd6..cc6923f08 100644 --- a/command/untaint.go +++ b/command/untaint.go @@ -65,10 +65,6 @@ func (c *UntaintCommand) Run(args []string) int { c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) return 1 } - if err := st.RefreshState(); err != nil { - c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) - return 1 - } if c.stateLock { stateLocker := clistate.NewLocker(context.Background(), c.stateLockTimeout, c.Ui, c.Colorize()) @@ -79,6 +75,11 @@ func (c *UntaintCommand) Run(args []string) int { defer stateLocker.Unlock(nil) } + if err := st.RefreshState(); err != nil { + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) + return 1 + } + // Get the actual state structure s := st.State() if s.Empty() {