fix: restart after reconcile

This commit is contained in:
2026-08-15 18:36:56 +07:00 Unverified
parent ed7ee7a113
commit 3f70382fd3
3 changed files with 179 additions and 9 deletions
+38
View File
@@ -11,6 +11,7 @@ import {
} from "../lib/apply";
import { buildServices } from "../lib/build";
import { composeToKubernetes, type KubernetesResource } from "../lib/convert";
import { restartDeployment, waitForDeploymentRollout } from "../lib/shared";
type UpContext = {
compose?: ComposeSpecification;
@@ -18,6 +19,13 @@ type UpContext = {
staleResources?: KubernetesResource[];
};
function getDeploymentNames(resources: KubernetesResource[]): string[] {
return resources
.filter((resource) => resource.kind === "Deployment")
.map((resource) => resource.metadata?.name)
.filter((name): name is string => Boolean(name));
}
export async function runUp(build: boolean) {
const { project, compose, cwd } = ctx();
await assertManagedNamespace(project);
@@ -83,6 +91,36 @@ export async function runUp(build: boolean) {
);
},
},
{
title: "Restart deployments",
task: (taskCtx, task) => {
const deployments = getDeploymentNames(taskCtx.resources!);
task.output = `${deployments.length} deployments queued`;
return task.newListr(
deployments.map((name) => ({
title: `Deployment ${name}`,
task: () => restartDeployment(name),
})),
{ concurrent: false, exitOnError: true },
);
},
},
{
title: "Wait for rollout",
task: (taskCtx, task) => {
const deployments = getDeploymentNames(taskCtx.resources!);
task.output = `${deployments.length} deployments queued`;
return task.newListr(
deployments.map((name) => ({
title: `Deployment ${name}`,
task: () => waitForDeploymentRollout(name),
})),
{ concurrent: false, exitOnError: true },
);
},
},
{
title: "Delete stale resources",
skip: (taskCtx) =>