diff --git a/infra/deploy-runner/nodedc-deploy b/infra/deploy-runner/nodedc-deploy index aa30271..b83f288 100755 --- a/infra/deploy-runner/nodedc-deploy +++ b/infra/deploy-runner/nodedc-deploy @@ -8124,6 +8124,14 @@ def preflight_device_plane_postgres_bootstrap(): return "absent" +def device_plane_postgres_plan_selection(postgres_preflight): + if postgres_preflight is None: + return "preserved-prerequisite:not-selected" + if postgres_preflight != "absent": + die("Device Plane PostgreSQL plan preflight state is invalid") + return "bootstrap-selected:create-if-absent" + + def component_compose_root(component): return COMPONENTS[component].get("compose_root", component_root(component)) @@ -13492,7 +13500,10 @@ def plan_artifact(artifact): print(f"runtime_secret=runner-managed:{DEVICE_PLANE_POSTGRES_PASSWORD_FILE}") print(f"runtime_secret=runner-managed:{DEVICE_PLANE_GATEWAY_CORE_TOKEN_FILE}") print(f"runtime_secret=runner-managed:{DEVICE_PLANE_IDENTIFIER_PEPPER_FILE}") - print("device_postgres=preserved-prerequisite:not-selected") + print( + "device_postgres=" + f"{device_plane_postgres_plan_selection(device_plane_postgres_preflight)}" + ) print("device_postgres_volume=preserved:nodedc-device-plane-postgres-data") print("device_gateway_public_ingress=disabled") print("device_gateway_command_transport=disabled") diff --git a/infra/deploy-runner/test_device_plane_postgres_bootstrap.py b/infra/deploy-runner/test_device_plane_postgres_bootstrap.py index d420e80..3899cc1 100644 --- a/infra/deploy-runner/test_device_plane_postgres_bootstrap.py +++ b/infra/deploy-runner/test_device_plane_postgres_bootstrap.py @@ -165,6 +165,21 @@ class DevicePlanePostgresBootstrapTest(unittest.TestCase): ): RUNNER.preflight_device_plane_postgres_bootstrap() + def test_plan_selection_is_unambiguous_for_bootstrap_and_application(self): + self.assertEqual( + RUNNER.device_plane_postgres_plan_selection(None), + "preserved-prerequisite:not-selected", + ) + self.assertEqual( + RUNNER.device_plane_postgres_plan_selection("absent"), + "bootstrap-selected:create-if-absent", + ) + with self.assertRaisesRegex( + RUNNER.DeployError, + "plan preflight state is invalid", + ): + RUNNER.device_plane_postgres_plan_selection("unknown") + def test_bootstrap_health_acceptance_is_database_service_only(self): with mock.patch.object( RUNNER,