Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Continue operation in case gravity-site or etcd is down (#2166)
Browse files Browse the repository at this point in the history
* Continue operation in case gravity-site or etcd is down
  • Loading branch information
bernardjkim authored Sep 30, 2020
1 parent 95cf592 commit 763beed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion tool/gravity/cli/clusterupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ func executeUpdatePhaseForOperation(env *localenv.LocalEnvironment, environ Loca
func executeOrForkPhase(env *localenv.LocalEnvironment, updater updater, params PhaseParams, operation ops.SiteOperation) error {
if params.isResume() {
if err := verifyOrDeployAgents(env); err != nil {
return trace.Wrap(err)
// Continue operation in case gravity-site or etcd is down. In these
// cases the agent status may not be retrievable.
log.WithError(err).Warn("Failed to verify or deploy agents.")
}
}

Expand Down
4 changes: 3 additions & 1 deletion tool/gravity/cli/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ func rollbackPlan(localEnv *localenv.LocalEnvironment, environ LocalEnvironmentF
}

if err := verifyOrDeployAgents(localEnv); err != nil {
return trace.Wrap(err)
// Continue operation in case gravity-site or etcd is down. In these
// cases the agent status may not be retrievable.
log.WithError(err).Warn("Failed to verify or deploy agents.")
}

if !confirmed && !params.DryRun {
Expand Down
6 changes: 4 additions & 2 deletions tool/gravity/cli/rpcagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/gravitational/gravity/lib/utils"

"github.com/cenkalti/backoff"
"github.com/fatih/color"
teleclient "github.com/gravitational/teleport/lib/client"
"github.com/gravitational/trace"
"github.com/gravitational/version"
Expand Down Expand Up @@ -500,15 +501,16 @@ func collectAgentStatus(env *localenv.LocalEnvironment) (statusList rpc.StatusLi
func verifyOrDeployAgents(env *localenv.LocalEnvironment) error {
statusList, err := collectAgentStatus(env)
if err != nil {
env.Println(color.YellowString("Couldn't verify upgrade agents status. If some are offline, they won't be redeployed automatically"))
return trace.Wrap(err, "failed to collect agent status")
}
if statusList.AgentsActive() {
return nil
}
if err := rpcAgentDeploy(env, deployOptions{}); err != nil {
log.WithError(err).Error("Failed to deploy agents.")
env.Println(statusList.String())
return trace.BadParameter("some agents are offline; ensure all agents are deployed with `./gravity agent deploy`")
env.Println(color.YellowString("Some agents are offline. Ensure all agents are deployed with `./gravity agent deploy`"))
return trace.Wrap(err, "failed to deploy agents")
}
return nil
}
Expand Down

0 comments on commit 763beed

Please sign in to comment.