fix(v03): keep cloud api available during rollout (#2000)
This commit is contained in:
@@ -561,6 +561,7 @@ lanes:
|
|||||||
overrides: {}
|
overrides: {}
|
||||||
services:
|
services:
|
||||||
- serviceId: hwlab-cloud-api
|
- serviceId: hwlab-cloud-api
|
||||||
|
replicas: 2
|
||||||
env:
|
env:
|
||||||
HWLAB_CLOUD_DB_URL: secretRef:hwlab-cloud-api-v03-db/database-url
|
HWLAB_CLOUD_DB_URL: secretRef:hwlab-cloud-api-v03-db/database-url
|
||||||
HWLAB_CLOUD_DB_CONTRACT: v03-redacted-presence-only
|
HWLAB_CLOUD_DB_CONTRACT: v03-redacted-presence-only
|
||||||
|
|||||||
@@ -914,7 +914,7 @@ function removeV02LegacySimulatorEnv(envList) {
|
|||||||
return envList.filter((entry) => !v02RemovedServiceEnvNames.has(entry?.name));
|
return envList.filter((entry) => !v02RemovedServiceEnvNames.has(entry?.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeV02RepoOwnedCodeAgentPodConfig(podSpec) {
|
function removeV02RepoOwnedCodeAgentPodConfig(deploymentSpec, podSpec) {
|
||||||
if (!podSpec) return;
|
if (!podSpec) return;
|
||||||
podSpec.initContainers = (podSpec.initContainers ?? []).filter((entry) => entry?.name !== "hwlab-code-agent-workspace-init");
|
podSpec.initContainers = (podSpec.initContainers ?? []).filter((entry) => entry?.name !== "hwlab-code-agent-workspace-init");
|
||||||
const removedVolumeNames = new Set([
|
const removedVolumeNames = new Set([
|
||||||
@@ -927,6 +927,15 @@ function removeV02RepoOwnedCodeAgentPodConfig(podSpec) {
|
|||||||
for (const container of podSpec.containers ?? []) {
|
for (const container of podSpec.containers ?? []) {
|
||||||
container.volumeMounts = (container.volumeMounts ?? []).filter((mount) => !removedVolumeNames.has(mount?.name));
|
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) {
|
function deployServicesForProfile(deploy, profile) {
|
||||||
@@ -1280,6 +1289,7 @@ function transformWorkloads({ workloads, deploy, catalog, source, sourceBranch =
|
|||||||
const serviceId = serviceIdForWorkload(item, container);
|
const serviceId = serviceIdForWorkload(item, container);
|
||||||
const deployService = deployServices.get(serviceId);
|
const deployService = deployServices.get(serviceId);
|
||||||
if (!deployService) continue;
|
if (!deployService) continue;
|
||||||
|
applyDeployServiceReplicas(item, deployService);
|
||||||
const artifact = runtimeArtifactForService({ catalog, deploy, serviceId, source, registryPrefix, useDeployImages, digestPin, envReuseServiceIds });
|
const artifact = runtimeArtifactForService({ catalog, deploy, serviceId, source, registryPrefix, useDeployImages, digestPin, envReuseServiceIds });
|
||||||
const envReuse = runtimeLane && v02EnvReuseEnabled(catalog, serviceId, envReuseServiceIds);
|
const envReuse = runtimeLane && v02EnvReuseEnabled(catalog, serviceId, envReuseServiceIds);
|
||||||
const bootDeployService = envReuse ? deployServiceForBoot(deploy, serviceId, profile) : null;
|
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 (serviceId === "hwlab-cloud-api") {
|
||||||
if (runtimeLane) {
|
if (runtimeLane) {
|
||||||
removeV02RepoOwnedCodeAgentPodConfig(podTemplate.spec);
|
removeV02RepoOwnedCodeAgentPodConfig(item.spec, podTemplate.spec);
|
||||||
upsertEnv(container.env, "HWLAB_M3_IO_CONTROL_ENABLED", "false");
|
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_REPO_URL", gitReadUrl ?? defaultRuntimeLaneGitReadUrl);
|
||||||
upsertEnv(container.env, "HWLAB_CODE_AGENT_AGENTRUN_PROVIDER_ID", runtimeNodeIdForProfile(deploy, profile));
|
upsertEnv(container.env, "HWLAB_CODE_AGENT_AGENTRUN_PROVIDER_ID", runtimeNodeIdForProfile(deploy, profile));
|
||||||
|
|||||||
Reference in New Issue
Block a user