fix: 修复外部 PostgreSQL 迁移 Job 不可变漂移
This commit is contained in:
@@ -754,6 +754,7 @@ function externalPostgresManifest({ profile = "v03", config, source, deploy = nu
|
||||
const migrationData = Object.fromEntries(migrationSources.map((migration) => [path.basename(migration.path), migration.sql]));
|
||||
const migrationSha256 = createHash("sha256").update(migrationSources.map((migration) => migration.sql).join("\n")).digest("hex");
|
||||
const migrationRunner = externalPostgresMigrationRunner();
|
||||
const migrationContractVersion = "external-postgres-migration-v2";
|
||||
const migrationImage = runtimeImageForService({
|
||||
catalog,
|
||||
deploy,
|
||||
@@ -764,18 +765,24 @@ function externalPostgresManifest({ profile = "v03", config, source, deploy = nu
|
||||
digestPin: true,
|
||||
envReuseServiceIds: envReuseServiceIdsForLane(deploy, profile)
|
||||
});
|
||||
const executionSha256 = createHash("sha256").update(`${migrationSha256}\n${migrationImage}\n${migrationRunner}`).digest("hex");
|
||||
const executionSha256 = createHash("sha256").update(`${migrationContractVersion}\n${migrationSha256}\n${migrationImage}\n${migrationRunner}`).digest("hex");
|
||||
const migrationName = `${namespace}-external-postgres-migrate-${executionSha256.slice(0, 12)}`;
|
||||
const labels = {
|
||||
const stableLabels = {
|
||||
"app.kubernetes.io/name": config.serviceName,
|
||||
"app.kubernetes.io/part-of": "hwlab",
|
||||
"hwlab.pikastech.local/component": "platform-db-bridge",
|
||||
"hwlab.pikastech.local/environment": profile,
|
||||
"hwlab.pikastech.local/gitops-target": profile,
|
||||
"hwlab.pikastech.local/profile": profile,
|
||||
"hwlab.pikastech.local/profile": profile
|
||||
};
|
||||
const labels = {
|
||||
...stableLabels,
|
||||
"hwlab.pikastech.local/source-commit": source.full
|
||||
};
|
||||
const annotations = { "hwlab.pikastech.local/rendered-by": "scripts/gitops-render.mjs" };
|
||||
const annotations = {
|
||||
"hwlab.pikastech.local/rendered-by": "scripts/gitops-render.mjs",
|
||||
"hwlab.pikastech.local/migration-contract-version": migrationContractVersion
|
||||
};
|
||||
return {
|
||||
apiVersion: "v1",
|
||||
kind: "List",
|
||||
@@ -807,14 +814,14 @@ function externalPostgresManifest({ profile = "v03", config, source, deploy = nu
|
||||
labels,
|
||||
annotations: {
|
||||
...annotations,
|
||||
"argocd.argoproj.io/sync-wave": "-1",
|
||||
"argocd.argoproj.io/sync-wave": "1",
|
||||
"hwlab.pikastech.local/migration-sha256": migrationSha256
|
||||
}
|
||||
},
|
||||
spec: {
|
||||
backoffLimit: 2,
|
||||
template: {
|
||||
metadata: { labels: { ...labels, "app.kubernetes.io/name": migrationName } },
|
||||
metadata: { labels: { ...stableLabels, "app.kubernetes.io/name": migrationName } },
|
||||
spec: {
|
||||
restartPolicy: "Never",
|
||||
containers: [{
|
||||
|
||||
Reference in New Issue
Block a user