diff --git a/deploy/deploy.yaml b/deploy/deploy.yaml index c56194bd..53c21b34 100644 --- a/deploy/deploy.yaml +++ b/deploy/deploy.yaml @@ -561,6 +561,7 @@ lanes: overrides: {} services: - serviceId: hwlab-cloud-api + replicas: 2 env: HWLAB_CLOUD_DB_URL: secretRef:hwlab-cloud-api-v03-db/database-url HWLAB_CLOUD_DB_CONTRACT: v03-redacted-presence-only diff --git a/scripts/gitops-render.mjs b/scripts/gitops-render.mjs index 584c4128..5c1de6bd 100644 --- a/scripts/gitops-render.mjs +++ b/scripts/gitops-render.mjs @@ -914,7 +914,7 @@ function removeV02LegacySimulatorEnv(envList) { return envList.filter((entry) => !v02RemovedServiceEnvNames.has(entry?.name)); } -function removeV02RepoOwnedCodeAgentPodConfig(podSpec) { +function removeV02RepoOwnedCodeAgentPodConfig(deploymentSpec, podSpec) { if (!podSpec) return; podSpec.initContainers = (podSpec.initContainers ?? []).filter((entry) => entry?.name !== "hwlab-code-agent-workspace-init"); const removedVolumeNames = new Set([ @@ -927,6 +927,15 @@ function removeV02RepoOwnedCodeAgentPodConfig(podSpec) { for (const container of podSpec.containers ?? []) { container.volumeMounts = (container.volumeMounts ?? []).filter((mount) => !removedVolumeNames.has(mount?.name)); } + if (deploymentSpec?.strategy?.type === "Recreate") delete deploymentSpec.strategy; +} + +function applyDeployServiceReplicas(item, deployService) { + if (!(item?.kind === "Deployment" || item?.kind === "StatefulSet")) return; + const replicas = deployService?.replicas; + if (!Number.isInteger(replicas) || replicas < 0) return; + item.spec ??= {}; + item.spec.replicas = replicas; } function deployServicesForProfile(deploy, profile) { @@ -1280,6 +1289,7 @@ function transformWorkloads({ workloads, deploy, catalog, source, sourceBranch = const serviceId = serviceIdForWorkload(item, container); const deployService = deployServices.get(serviceId); if (!deployService) continue; + applyDeployServiceReplicas(item, deployService); const artifact = runtimeArtifactForService({ catalog, deploy, serviceId, source, registryPrefix, useDeployImages, digestPin, envReuseServiceIds }); const envReuse = runtimeLane && v02EnvReuseEnabled(catalog, serviceId, envReuseServiceIds); const bootDeployService = envReuse ? deployServiceForBoot(deploy, serviceId, profile) : null; @@ -1327,7 +1337,7 @@ function transformWorkloads({ workloads, deploy, catalog, source, sourceBranch = } if (serviceId === "hwlab-cloud-api") { if (runtimeLane) { - removeV02RepoOwnedCodeAgentPodConfig(podTemplate.spec); + removeV02RepoOwnedCodeAgentPodConfig(item.spec, podTemplate.spec); upsertEnv(container.env, "HWLAB_M3_IO_CONTROL_ENABLED", "false"); upsertEnv(container.env, "HWLAB_CODE_AGENT_AGENTRUN_REPO_URL", gitReadUrl ?? defaultRuntimeLaneGitReadUrl); upsertEnv(container.env, "HWLAB_CODE_AGENT_AGENTRUN_PROVIDER_ID", runtimeNodeIdForProfile(deploy, profile));