Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roachprod: only use cluster with positive lifetime #101434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/roachprod/cloud/cluster_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ func (c *Cluster) LifetimeRemaining() time.Duration {
return time.Until(c.GCAt())
}

// IsLive is true if last known lifetime is still greater than one minute.
// One minute is arbitrary, we just want to give roachprod some time to run
// actual command before cluster disappears.
// If lifetime was not parsed, then we don't know so pretend it is live to
// avoid making it unusable.
func (c *Cluster) IsLive() bool {
return c.Lifetime == 0 || c.LifetimeRemaining() > time.Minute
}

func (c *Cluster) String() string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "%s: %d", c.Name, len(c.VMs))
Expand Down
7 changes: 7 additions & 0 deletions pkg/roachprod/roachprod.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ func newCluster(
return nil, err
}

if !metadata.IsLive() {
err := errors.Newf(`expired cluster: %s`, name)
err = errors.WithHintf(err, "\nRemaining lifetime: %s\n ", metadata.LifetimeRemaining())
err = errors.WithHint(err, `Use "roachprod sync" to update cluster lifetime if cluster cache is out of sync.`)
return nil, err
}

if clusterSettings.DebugDir == "" {
clusterSettings.DebugDir = os.ExpandEnv(config.DefaultDebugDir)
}
Expand Down