Skip to content

Wait for HBase to be ready after wiping its PVCs - #149

Open
viliakov wants to merge 2 commits into
mainfrom
wipe-pvcs-wait-hbase
Open

viliakov wants to merge 2 commits into
mainfrom
wipe-pvcs-wait-hbase

Conversation

@viliakov

@viliakov viliakov commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

restore --wipe-pvcs failed in the verify-backup pipeline for two reasons:

  • HBase shutdown timed out. It takes longer than the generic 2-minute pod-termination limit, so the wipe timed out halfway through.
  • The restore job started too early. It was created as soon as HBase was scaled back up, and failed with NoNode for /hbase/hbaseid because HBase was still initializing.

This PR gives the HBase scale-down its own longer timeout. Before creating the restore job, it waits for every HBase workload to be ready and for /hbase/hbaseid to exist in Zookeeper. The znode check covers Mono, whose readiness probe can pass before HBase registers. If the wipe fails part-way, HBase and the StackGraph deployments are scaled back up and the restore lock is released, for both v1 and v2.

Validation: go test ./... and golangci-lint v2.15.0 pass. verify-backup run 45209648761 passed end to end with --wipe-pvcs (Distributed) on 6c3600d. The review follow-up (d1f37d4) has not had an end-to-end run, and Mono has not been tested on a live instance.

Tracking: https://github.com/StackVista/verify-backup/issues/22

🤖 Generated with Claude Code

restore --wipe-pvcs failed reliably in the verify-backup pipeline:

- Scaling HBase down used the generic 2 minute pod-termination limit.
  HDFS and HBase take longer to flush and stop, so the wipe timed out
  and left the instance half wiped for the next attempt.
- After deleting the PVCs, HBase was scaled up and the restore job was
  created immediately. The job then failed with "NoNode for
  /hbase/hbaseid" / "no region servers available"; HBase reported
  itself initialized about 24 seconds later.

Give the HBase scale-down its own longer termination timeout and wait
for every HBase workload to report its replicas ready before returning.
Scale-up is no longer deferred: it now happens explicitly before the
readiness wait, and on the error paths after scale-down.

Refs StackVista/verify-backup#22

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ai-collaboration-app ai-collaboration-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. CI is green, and verify-backup run 45209648761 passed with --wipe-pvcs on this head. Notes on lines outside the diff:

  • cmd/stackgraph/restore.go:110: WipePVCs runs before the ScaleUpAndReleaseLock defer is registered. With the new error returns below, a failure leaves the StackGraph-dependent deployments scaled down and the restore lock held. stackgraphv2/restore.go registers the defer first. Suggest doing the same in v1.
  • hbase.go:88-92: if deleteRecursive fails after the scale-down, HBase stays at 0 replicas. Wrap these with scaleUpHBaseAfterError too, like the PVC errors.

Minor: the description still says the e2e run is in progress.

logger.Println()
logger.Infof("Scaled up HBase after deleting PVCs")
if err := scale.ScaleUpFromAnnotations(k8sClient, namespace, hbaseSelector, logger); err != nil {
return fmt.Errorf("failed to scale up HBase after deleting PVCs: %w", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the readiness timeout below are new error returns. The v1 caller in cmd/stackgraph/restore.go hits them before its scale-up/unlock defer exists (see review body).

Comment thread internal/orchestration/restore/hbase.go Outdated
return fmt.Errorf("failed to scale up HBase after deleting PVCs: %w", err)
}
// The restore job needs live region servers; starting it during HBase initialization fails with NoNode for /hbase/hbaseid.
if err := scale.WaitForReady(k8sClient, namespace, hbaseSelector, hbaseReadyTimeout, logger); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Mono mode the only workload is the stackgraph statefulset, and its readiness probe is HTTP / on masterinfo. That can pass before /hbase/hbaseid exists, so this wait might not prevent the NoNode failure there. Distributed mode is fine: the RS probe checks clusterId. Has Mono been validated, or should this also check that the znode exists?

Comment thread internal/orchestration/scale/scale.go Outdated
//
//nolint:revive // Package name "scale" with function "WaitForReady" is intentionally verbose for clarity
func WaitForReady(k8sClient *k8s.Client, namespace, labelSelector string, readyTimeout time.Duration, log *logger.Logger) error {
ctx := context.Background()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: context.Background() means Ctrl-C won't cancel a wait of up to 15 minutes. WipePVCs already has ctx, so it could be passed through.

}()
}

err = WaitForReady(client, "test-ns", "app.kubernetes.io/name=hbase", 7*time.Second, logger.New(true, false))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: these tests take ~15s of real ticker and timeout waits. Making readinessCheckInterval and podTerminationCheckInterval overridable in tests would speed them up.

- Register the v1 scale-up/unlock defer before wiping PVCs, as v2 does,
  so a wipe failure no longer leaves deployments down and the lock held.
- Scale HBase back up when clearing its Zookeeper nodes fails.
- After pod readiness, wait for /hbase/hbaseid in Zookeeper. The Mono
  readiness probe only checks the master info page, which can pass
  before HBase has registered.
- Pass the command context into WaitForReady so Ctrl-C cancels it.
- Poll faster in the new tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@viliakov

Copy link
Copy Markdown
Contributor Author

Addressed in d1f37d4: v1 now registers the scale-up/unlock defer before WipePVCs; a failed Zookeeper cleanup scales HBase back up; after pod readiness the CLI also waits for /hbase/hbaseid (Mono hasn't been tested live); WaitForReady takes the command context; the new tests poll every 10ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant