From 23d5daf3885f63902987c2dbe07ed1f0ae8e9c71 Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Sat, 13 Jun 2026 18:04:08 +0800 Subject: [PATCH] fix: roll git mirror on config changes (#329) Co-authored-by: Codex --- scripts/src/hwlab-node-control-plane.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/src/hwlab-node-control-plane.ts b/scripts/src/hwlab-node-control-plane.ts index 45825898..a5414293 100644 --- a/scripts/src/hwlab-node-control-plane.ts +++ b/scripts/src/hwlab-node-control-plane.ts @@ -847,8 +847,8 @@ function renderInfraManifest(_node: ControlPlaneNodeSpec, target: ControlPlaneTa manifests.push( service(target.gitMirror.serviceReadName, target.gitMirror.namespace, labels, target.gitMirror.servicePort), service(target.gitMirror.serviceWriteName, target.gitMirror.namespace, labels, target.gitMirror.servicePort), - gitMirrorDeployment(target.gitMirror.serviceReadName, target.gitMirror.namespace, labels, target, "read"), - gitMirrorDeployment(target.gitMirror.serviceWriteName, target.gitMirror.namespace, labels, target, "write"), + gitMirrorDeployment(target.gitMirror.serviceReadName, target.gitMirror.namespace, labels, _node, target, "read"), + gitMirrorDeployment(target.gitMirror.serviceWriteName, target.gitMirror.namespace, labels, _node, target, "write"), { apiVersion: "tekton.dev/v1", kind: "Pipeline", @@ -886,7 +886,17 @@ function service(name: string, namespace: string, labels: Record }; } -function gitMirrorDeployment(name: string, namespace: string, labels: Record, target: ControlPlaneTargetSpec, mode: "read" | "write"): Record { +function gitMirrorConfigHash(node: ControlPlaneNodeSpec, target: ControlPlaneTargetSpec): string { + return sha256Short(JSON.stringify({ + repositories: [{ key: target.id, repository: target.source.repository, sourceBranch: target.source.branch, gitopsBranch: target.gitops.branch }], + server: gitMirrorServerJs(), + status: gitMirrorStatusShell(), + sync: gitMirrorSyncShell(node, target), + flush: gitMirrorFlushShell(node, target), + })); +} + +function gitMirrorDeployment(name: string, namespace: string, labels: Record, node: ControlPlaneNodeSpec, target: ControlPlaneTargetSpec, mode: "read" | "write"): Record { return { apiVersion: "apps/v1", kind: "Deployment", @@ -895,7 +905,10 @@ function gitMirrorDeployment(name: string, namespace: string, labels: Record