Add --cleanup CLI flag with idempotent deploy#156
Open
szachovy wants to merge 12 commits into
Open
Conversation
Replace blanket '|| true' error suppression in teardown with proper conditional logic: if/then guards for swarm leave, directory removal, and VIP cleanup; xargs -r for container, volume, and network removal. Exit codes are checked via _run_ssh_command() and real failures raise RuntimeError. Deploy action (default) always tears down existing state first, making it idempotent and safe for both fresh installs and redeployments. Add redeploy and cleanup test stages to the test suite: - redeploy.yml: restarts stopped nodes from disaster tests, runs a fresh deploy, and verifies the cluster is fully functional again. - cleanup.yml: runs --cleanup and verifies no containers, volumes, deployment directories, .pyc files, or VIP addresses remain. Closes #49 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
efd3cb3 to
3fee28a
Compare
9c80160 to
4f4c363
Compare
Make deploy idempotent by checking component health before acting: - start_mysql_servers() skips nodes where mysql is already healthy - start_mysql_mgmt() skips nodes where mysql-mgmt is already healthy - start_superset() skips nodes where superset service already exists - credentials() handles idempotent directory creation Cleanup via --cleanup tears down all containers, volumes, networks, routes, deployed files, and VIP addresses. Teardown commands use conditional logic (if/then guards, xargs -r) instead of || true, with all commands per node executed in a single SSH call and exit status checked. Test suite extended with redeploy and cleanup stages: - redeploy.yml: restarts disaster-stopped nodes, runs cleanup then fresh deploy, verifies cluster fully functional - cleanup.yml: runs --cleanup, verifies no containers, volumes, directories, .pyc files, or VIP addresses remain Closes #49 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4f4c363 to
478acfe
Compare
…flags # Conflicts: # CHANGELOG.md # src/remote.py
- Replace && chaining in teardown_node() with independent command execution so VIP and directory cleanup are not skipped when an intermediate command fails - Remove redundant try/except IOError around create_directory() since it is already idempotent via mkdir -p Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Simplify test suite to 7 stages: sanity, deploy, functional_pre, disaster, recover, redeploy, functional_post. The test focus is on verifying idempotent redeploy recovers a partially failed cluster, not on full cleanup verification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add retry logic (3 attempts with 5s delay) to InnoDB cluster detection
in the initcontainer. Fixes race condition where the second mgmt node
cannot find the cluster just created by the first mgmt node.
- Use explicit cluster name in dba.getCluster('superset') for more
reliable detection vs the parameterless dba.getCluster() which depends
on instance metadata availability.
- Increase mysql-mgmt healthcheck_retries from 3 to 24 in container.py
to give Docker enough time to report the maincontainer as healthy
(the maincontainer sleeps 25s before starting mysqlrouter, and Docker's
own healthcheck needs additional time to pass).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…up test - Escape shell-only variables (node, attempt, CLUSTER_NODE, CLUSTER_STATUS) with $$ in docker_compose.yml to prevent Docker Compose from interpolating them as empty strings - Fix mypy type errors in crypto.py and initialize.py by adding assert isinstance checks for RSAPrivateKey deserialization - Add cleanup test stage at the end of deploy.yml that runs --cleanup flag and verifies all containers, volumes, directories, and VIPs are removed Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix recover.yml SSH command to connect as 'superset' user (matching the authorized_keys in the container image and the pattern used in sanity.yml) - Revert mysql-mgmt healthcheck_retries to original value of 3 since the Docker Compose variable interpolation fix ensures containers start correctly without needing extended polling Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The post-redeploy functional test incorrectly used after_disaster=True which expects degraded cluster status (OK_NO_TOLERANCE_PARTIAL). After the redeploy step fully restores the cluster, the correct assertion is after_disaster=False which validates the cluster is back to OK status with Single-Primary topology. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
After a full cluster redeploy, Superset may report a query as successful before results are fully propagated to Redis. Add retries (3 attempts, 20s delay) to the superset post-disaster functional test, matching the retry pattern already used by the mgmt post-disaster test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
After disaster recovery and redeploy, node-1's Superset has stale Celery/Redis state from surviving the disaster without restart. Node-0 was freshly redeployed with clean state and properly validates that the redeploy produced a working cluster. This matches the pre-disaster test which also runs on node-0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run failover verification on surviving node (node-1) after disaster simulation but before node recovery. Tests verify: - MySQL InnoDB cluster entered OK_NO_TOLERANCE_PARTIAL state - A secondary node was promoted to new MySQL primary - Superset remains accessible via the VIP through surviving nodes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #49
Changes
CLI
--cleanupflag tosuperset-clustershell scriptdeployorcleanupaction as 6th argument to PythonSource (
src/initialize.py)start_*method checks container health before deploying. If healthy → skip; if any other state → remove and redeploy from scratch_recover_existing_credentials()reads CA key/cert, root password, superset password, and secret key from healthy nodes. Enables partial redeploy with consistent credentialscleanup()runsteardown_node()per node, gracefully handling unreachable nodesteardown_node()uses guarded commands (if/then/fi,xargs -r) joined by&&Source (
src/crypto.py)serialization()static method for PEM string → RSAPrivateKey/Certificate conversionSource (
services/mysql-mgmt/docker_compose.yml)addInstance()with incremental recoveryTerraform (
tests/setup/main.tf)always_run = timestamp()triggers from all resourcesterraform applynow only recreates missing containers; running nodes are untouchedTests (
tests/testsuite/)10-stage test flow:
terraform applyrecreates them with full provisioning--cleanupto teardown all nodesOther
.pycfiles moved from/optto/opt/superset-cluster