Skip to content

Commit 3f25bf1

Browse files
committed
feat(health): finalizer messages for Promoter checks
1 parent 21615be commit 3f25bf1

21 files changed

Lines changed: 167 additions & 10 deletions

File tree

resource_customizations/promoter.argoproj.io/ArgoCDCommitStatus/health.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-- CRD spec: https://gitops-promoter.readthedocs.io/en/latest/crd-specs/#argocdcommitstatus
2+
13
local hs = {}
24
hs.status = "Progressing"
35
hs.message = "Initializing Argo CD commit status"

resource_customizations/promoter.argoproj.io/ChangeTransferPolicy/health.lua

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1+
-- CRD spec: https://gitops-promoter.readthedocs.io/en/latest/crd-specs/#changetransferpolicy
2+
-- Promoter finalizers: https://gitops-promoter.readthedocs.io/en/latest/debugging/finalizers/
3+
4+
local function formatDeletingWithFinalizers(base, finalizers, catalog)
5+
if not finalizers then
6+
return base
7+
end
8+
local parts = { base }
9+
for _, f in ipairs(finalizers) do
10+
local e = catalog[f]
11+
if e then
12+
table.insert(parts, f .. ": " .. e.wait .. " Risk if removed manually: " .. e.risk)
13+
end
14+
end
15+
return table.concat(parts, " ")
16+
end
17+
118
local hs = {}
219
hs.status = "Progressing"
320
hs.message = "Initializing change transfer policy"
421

522
-- Check for deletion timestamp
623
if obj.metadata.deletionTimestamp then
724
hs.status = "Progressing"
8-
hs.message = "Change transfer policy is being deleted"
25+
hs.message = formatDeletingWithFinalizers(
26+
"Change transfer policy is being deleted.",
27+
obj.metadata.finalizers,
28+
{
29+
["changetransferpolicy.promoter.argoproj.io/finalizer"] = {
30+
wait = "Waiting to clear related PullRequest finalizers and finish cleanup before this policy is removed.",
31+
risk = "the policy can disappear while related PullRequests are still terminating or inconsistent with Git.",
32+
},
33+
}
34+
)
935
return hs
1036
end
1137

resource_customizations/promoter.argoproj.io/ChangeTransferPolicy/health_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tests:
55
inputPath: testdata/no-status.yaml
66
- healthStatus:
77
status: Progressing
8-
message: Change transfer policy is being deleted
8+
message: 'Change transfer policy is being deleted. changetransferpolicy.promoter.argoproj.io/finalizer: Waiting to clear related PullRequest finalizers and finish cleanup before this policy is removed. Risk if removed manually: the policy can disappear while related PullRequests are still terminating or inconsistent with Git.'
99
inputPath: testdata/deleting.yaml
1010
- healthStatus:
1111
status: Progressing

resource_customizations/promoter.argoproj.io/ChangeTransferPolicy/testdata/deleting.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ kind: ChangeTransferPolicy
33
metadata:
44
name: test
55
deletionTimestamp: "2025-07-04T12:00:00Z"
6+
finalizers:
7+
- changetransferpolicy.promoter.argoproj.io/finalizer

resource_customizations/promoter.argoproj.io/ClusterScmProvider/health.lua

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
-- CRD spec: https://gitops-promoter.readthedocs.io/en/latest/crd-specs/#clusterscmprovider
2+
-- Promoter finalizers: https://gitops-promoter.readthedocs.io/en/latest/debugging/finalizers/
3+
4+
local function formatDeletingWithFinalizers(base, finalizers, catalog)
5+
if not finalizers then
6+
return base
7+
end
8+
local parts = { base }
9+
for _, f in ipairs(finalizers) do
10+
local e = catalog[f]
11+
if e then
12+
table.insert(parts, f .. ": " .. e.wait .. " Risk if removed manually: " .. e.risk)
13+
end
14+
end
15+
return table.concat(parts, " ")
16+
end
17+
118
local hs = {}
219
hs.status = "Progressing"
320
hs.message = "Initializing cluster SCM provider"
@@ -6,7 +23,16 @@ hs.message = "Initializing cluster SCM provider"
623

724
if obj.metadata.deletionTimestamp then
825
hs.status = "Progressing"
9-
hs.message = "ClusterScmProvider is being deleted"
26+
hs.message = formatDeletingWithFinalizers(
27+
"ClusterScmProvider is being deleted.",
28+
obj.metadata.finalizers,
29+
{
30+
["clusterscmprovider.promoter.argoproj.io/finalizer"] = {
31+
wait = "Waiting until no GitRepository still references this cluster-wide SCM provider.",
32+
risk = "GitRepository objects can reference a provider that no longer exists.",
33+
},
34+
}
35+
)
1036
return hs
1137
end
1238

resource_customizations/promoter.argoproj.io/ClusterScmProvider/health_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tests:
55
inputPath: testdata/no-status.yaml
66
- healthStatus:
77
status: Progressing
8-
message: ClusterScmProvider is being deleted
8+
message: 'ClusterScmProvider is being deleted. clusterscmprovider.promoter.argoproj.io/finalizer: Waiting until no GitRepository still references this cluster-wide SCM provider. Risk if removed manually: GitRepository objects can reference a provider that no longer exists.'
99
inputPath: testdata/deleting.yaml
1010
- healthStatus:
1111
status: Progressing

resource_customizations/promoter.argoproj.io/ClusterScmProvider/testdata/deleting.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ kind: ClusterScmProvider
33
metadata:
44
name: github-enterprise
55
deletionTimestamp: "2025-07-04T12:00:00Z"
6+
finalizers:
7+
- clusterscmprovider.promoter.argoproj.io/finalizer
68
spec:
79
secretRef:
810
name: github-app-secret

resource_customizations/promoter.argoproj.io/CommitStatus/health.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-- CRD spec: https://gitops-promoter.readthedocs.io/en/latest/crd-specs/#commitstatus
2+
13
local hs = {}
24
hs.status = "Progressing"
35
hs.message = "Initializing commit status"

resource_customizations/promoter.argoproj.io/GitCommitStatus/health.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-- CRD spec: https://gitops-promoter.readthedocs.io/en/latest/crd-specs/
2+
13
local hs = {}
24
hs.status = "Progressing"
35
hs.message = "Initializing git commit validation"

resource_customizations/promoter.argoproj.io/GitRepository/health.lua

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
-- CRD spec: https://gitops-promoter.readthedocs.io/en/latest/crd-specs/#gitrepository
2+
-- Promoter finalizers: https://gitops-promoter.readthedocs.io/en/latest/debugging/finalizers/
3+
4+
local function formatDeletingWithFinalizers(base, finalizers, catalog)
5+
if not finalizers then
6+
return base
7+
end
8+
local parts = { base }
9+
for _, f in ipairs(finalizers) do
10+
local e = catalog[f]
11+
if e then
12+
table.insert(parts, f .. ": " .. e.wait .. " Risk if removed manually: " .. e.risk)
13+
end
14+
end
15+
return table.concat(parts, " ")
16+
end
17+
118
local hs = {}
219
hs.status = "Progressing"
320
hs.message = "Initializing Git repository"
@@ -6,7 +23,16 @@ hs.message = "Initializing Git repository"
623

724
if obj.metadata.deletionTimestamp then
825
hs.status = "Progressing"
9-
hs.message = "GitRepository is being deleted"
26+
hs.message = formatDeletingWithFinalizers(
27+
"GitRepository is being deleted.",
28+
obj.metadata.finalizers,
29+
{
30+
["gitrepository.promoter.argoproj.io/finalizer"] = {
31+
wait = "Waiting until no non-deleting PullRequests still reference this repository.",
32+
risk = "repository metadata may be removed while promotions still depend on it.",
33+
},
34+
}
35+
)
1036
return hs
1137
end
1238

0 commit comments

Comments
 (0)