Skip to content
Closed
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
1 change: 0 additions & 1 deletion docs/multi-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ For multi-database mode:
- `CHARTREUSE_ENABLE_STOP_PODS`: Whether to stop pods during migration (optional, default: true)
- `CHARTREUSE_RELEASE_NAME`: Kubernetes release name
- `CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT`: Whether to upgrade before deployment (optional, default: false)
- `HELM_IS_INSTALL`: Whether this is a Helm install operation (optional, default: false)

## Usage

Expand Down
6 changes: 4 additions & 2 deletions src/chartreuse/chartreuse_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ def main() -> None:
"false",
"0",
)
HELM_IS_INSTALL: bool = os.environ.get("HELM_IS_INSTALL", "false").lower() not in ("", "false", "0")
# HELM_IS_INSTALL removed: under ArgoCD the env var is always empty, and under
# pure Helm flow with upgradeBeforeDeployment=true the existing pattern was to
# let the orchestrator restart pods after the hook. Always honour that.

deployment_manager = KubernetesDeploymentManager(release_name=RELEASE_NAME, use_kubeconfig=None)
chartreuse = Chartreuse(
Expand All @@ -102,7 +104,7 @@ def main() -> None:

if not ENABLE_STOP_PODS:
return
if UPGRADE_BEFORE_DEPLOYMENT and not HELM_IS_INSTALL:
if UPGRADE_BEFORE_DEPLOYMENT:
return

try:
Expand Down
1 change: 0 additions & 1 deletion src/chartreuse/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def configure_os_environ_mock(mocker: MockerFixture, additional_environment: dic
"CHARTREUSE_RELEASE_NAME": "foo",
"RUN_TEST_IN_KIND": os.environ.get("RUN_TEST_IN_KIND", ""),
"CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT": "",
"HELM_IS_INSTALL": "",
"CHARTREUSE_MULTI_CONFIG_PATH": "/mock/config.yaml",
# Add Kubernetes environment variables to prevent config loading
"KUBERNETES_SERVICE_HOST": "localhost",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def test_main_multi_database_success(self, mocker: MockerFixture) -> None:
"CHARTREUSE_ENABLE_STOP_PODS": "true",
"CHARTREUSE_RELEASE_NAME": "test-release",
"CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT": "false",
"HELM_IS_INSTALL": "false",
},
)

Expand Down Expand Up @@ -166,7 +165,6 @@ def test_main_multi_database_no_migration_needed(self, mocker: MockerFixture) ->
"CHARTREUSE_ENABLE_STOP_PODS": "true",
"CHARTREUSE_RELEASE_NAME": "test-release",
"CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT": "false",
"HELM_IS_INSTALL": "false",
},
)

Expand Down Expand Up @@ -234,7 +232,6 @@ def test_main_multi_database_stop_pods_disabled(self, mocker: MockerFixture) ->
"CHARTREUSE_ENABLE_STOP_PODS": "false",
"CHARTREUSE_RELEASE_NAME": "test-release",
"CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT": "false",
"HELM_IS_INSTALL": "false",
},
)

Expand All @@ -246,7 +243,7 @@ def test_main_multi_database_stop_pods_disabled(self, mocker: MockerFixture) ->
mock_k8s_instance.start_pods.assert_not_called()

def test_main_multi_database_upgrade_before_deployment(self, mocker: MockerFixture) -> None:
"""Test main function with UPGRADE_BEFORE_DEPLOYMENT and not HELM_IS_INSTALL."""
"""Test main function with UPGRADE_BEFORE_DEPLOYMENT enabled: start_pods should be skipped."""
mocker.patch("chartreuse.chartreuse_upgrade.ensure_safe_run")

# Mock file existence for config validation
Expand Down Expand Up @@ -282,7 +279,6 @@ def test_main_multi_database_upgrade_before_deployment(self, mocker: MockerFixtu
"CHARTREUSE_ENABLE_STOP_PODS": "true",
"CHARTREUSE_RELEASE_NAME": "test-release",
"CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT": "true",
"HELM_IS_INSTALL": "false",
},
)

Expand Down Expand Up @@ -334,7 +330,6 @@ def test_main_multi_database_start_pods_failure(self, mocker: MockerFixture) ->
"CHARTREUSE_ENABLE_STOP_PODS": "true",
"CHARTREUSE_RELEASE_NAME": "test-release",
"CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT": "false",
"HELM_IS_INSTALL": "false",
},
)

Expand Down Expand Up @@ -390,7 +385,6 @@ def test_main_single_database_success(self, mocker: MockerFixture) -> None:
"CHARTREUSE_ENABLE_STOP_PODS": "true",
"CHARTREUSE_RELEASE_NAME": "test-release",
"CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT": "false",
"HELM_IS_INSTALL": "false",
},
clear=True,
)
Expand Down Expand Up @@ -450,7 +444,6 @@ def test_main_single_database_default_values(self, mocker: MockerFixture) -> Non
"CHARTREUSE_ENABLE_STOP_PODS": "false",
"CHARTREUSE_RELEASE_NAME": "test-release",
"CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT": "false",
"HELM_IS_INSTALL": "false",
},
clear=True,
)
Expand Down Expand Up @@ -523,7 +516,6 @@ def test_boolean_parsing_variations(self, mocker: MockerFixture, bool_str: str,
"CHARTREUSE_ENABLE_STOP_PODS": bool_str, # Test this boolean parsing
"CHARTREUSE_RELEASE_NAME": "test-release",
"CHARTREUSE_UPGRADE_BEFORE_DEPLOYMENT": "false",
"HELM_IS_INSTALL": "false",
},
clear=True,
)
Expand Down
Loading