Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Copy Markdown
Collaborator

@leoluz leoluz Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General question: What do you think if we add a comment to those health checks with at link to the Go type that they are based on? It could serve as a reference to CRD version that used to base the check. WDYT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I'm gonna open a follow up PR to add some nicer messages for finalizers, I'll add some comments with links in that PR.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
local hs = {}
hs.status = "Progressing"
hs.message = "Initializing cluster SCM provider"

-- ClusterScmProvider (gitops-promoter v1alpha1): cluster-scoped SCM provider; same Ready semantics as ScmProvider.

if obj.metadata.deletionTimestamp then
hs.status = "Progressing"
hs.message = "ClusterScmProvider is being deleted"
return hs
end

if not obj.status then
return hs
end

local hasReadyCondition = false
if obj.status.conditions then
for _, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" then
hasReadyCondition = true
if condition.observedGeneration and obj.metadata.generation and condition.observedGeneration ~= obj.metadata.generation then
hs.status = "Progressing"
hs.message = "Waiting for ClusterScmProvider spec update to be observed"
return hs
end
if condition.status == "False" then
hs.status = "Degraded"
local msg = condition.message or "Unknown error"
local reason = condition.reason or "Unknown"
if reason == "ReconciliationError" then
hs.message = "Cluster SCM provider validation failed: " .. msg
else
hs.message = "Cluster SCM provider not ready (" .. reason .. "): " .. msg
end
return hs
end
if condition.status == "Unknown" then
hs.status = "Progressing"
local msg = condition.message or "Unknown"
local reason = condition.reason or "Unknown"
hs.message = "Cluster SCM provider readiness unknown (" .. reason .. "): " .. msg
return hs
end
end
end
end

if not hasReadyCondition then
hs.status = "Progressing"
hs.message = "ClusterScmProvider Ready condition is missing"
return hs
end

hs.status = "Healthy"
hs.message = "Cluster SCM provider is ready"
return hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
tests:
- healthStatus:
status: Progressing
message: Initializing cluster SCM provider
inputPath: testdata/no-status.yaml
- healthStatus:
status: Progressing
message: ClusterScmProvider is being deleted
inputPath: testdata/deleting.yaml
- healthStatus:
status: Progressing
message: Waiting for ClusterScmProvider spec update to be observed
inputPath: testdata/observed-generation-outdated.yaml
- healthStatus:
status: Degraded
message: "Cluster SCM provider validation failed: Reconciliation failed: invalid credentials"
inputPath: testdata/reconcile-error.yaml
- healthStatus:
status: Progressing
message: ClusterScmProvider Ready condition is missing
inputPath: testdata/no-ready-condition.yaml
- healthStatus:
status: Progressing
message: "Cluster SCM provider readiness unknown (ValidationPending): Probing SCM endpoint"
inputPath: testdata/ready-unknown.yaml
- healthStatus:
status: Healthy
message: Cluster SCM provider is ready
inputPath: testdata/healthy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: promoter.argoproj.io/v1alpha1
kind: ClusterScmProvider
metadata:
name: github-enterprise
deletionTimestamp: "2025-07-04T12:00:00Z"
spec:
secretRef:
name: github-app-secret
github:
appID: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: promoter.argoproj.io/v1alpha1
kind: ClusterScmProvider
metadata:
name: github-enterprise
generation: 1
spec:
secretRef:
name: github-app-secret
github:
appID: 1
status:
conditions:
- type: Ready
status: "True"
reason: ReconciliationSuccess
message: Reconciliation successful
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: promoter.argoproj.io/v1alpha1
kind: ClusterScmProvider
metadata:
name: github-enterprise
generation: 1
spec:
secretRef:
name: github-app-secret
github:
appID: 1
status:
conditions:
- type: Example
status: "True"
reason: Example
message: ok
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: promoter.argoproj.io/v1alpha1
kind: ClusterScmProvider
metadata:
name: github-enterprise
spec:
secretRef:
name: github-app-secret
github:
appID: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: promoter.argoproj.io/v1alpha1
kind: ClusterScmProvider
metadata:
name: github-enterprise
generation: 2
spec:
secretRef:
name: github-app-secret
github:
appID: 1
status:
conditions:
- type: Ready
status: "True"
reason: ReconciliationSuccess
message: Reconciliation successful
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: promoter.argoproj.io/v1alpha1
kind: ClusterScmProvider
metadata:
name: github-enterprise
generation: 1
spec:
secretRef:
name: github-app-secret
github:
appID: 1
status:
conditions:
- type: Ready
status: Unknown
reason: ValidationPending
message: Probing SCM endpoint
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: promoter.argoproj.io/v1alpha1
kind: ClusterScmProvider
metadata:
name: github-enterprise
generation: 1
spec:
secretRef:
name: github-app-secret
github:
appID: 1
status:
conditions:
- type: Ready
status: "False"
reason: ReconciliationError
message: "Reconciliation failed: invalid credentials"
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
local hs = {}
hs.status = "Progressing"
hs.message = "Initializing git commit validation"

-- GitCommitStatus (gitops-promoter) reports per-environment validation in status.environments
-- (branch, phase, proposedHydratedSha, targetedSha, expressionResult). It is not CommitStatus:
-- there is no top-level status.sha / status.phase.

if obj.metadata.deletionTimestamp then
hs.status = "Progressing"
hs.message = "GitCommitStatus is being deleted"
return hs
end

if not obj.status then
return hs
end

local hasReadyCondition = false
if obj.status.conditions then
for _, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" then
hasReadyCondition = true
if condition.observedGeneration and obj.metadata.generation and condition.observedGeneration ~= obj.metadata.generation then
hs.status = "Progressing"
hs.message = "Waiting for GitCommitStatus spec update to be observed"
return hs
end
if condition.status == "False" then
hs.status = "Degraded"
local msg = condition.message or "Unknown error"
local reason = condition.reason or "Unknown"
if reason == "ReconciliationError" then
hs.message = "Git commit validation failed: " .. msg
else
hs.message = "Git commit validation not ready (" .. reason .. "): " .. msg
end
return hs
end
if condition.status == "Unknown" then
hs.status = "Progressing"
local msg = condition.message or "Unknown"
local reason = condition.reason or "Unknown"
hs.message = "Git commit validation status unknown (" .. reason .. "): " .. msg
return hs
end
end
end
end

if not hasReadyCondition then
hs.status = "Progressing"
hs.message = "GitCommitStatus Ready condition is missing"
return hs
end

local envs = obj.status.environments
if not envs or #envs == 0 then
hs.status = "Healthy"
hs.message = "Git commit validation reconciled"
return hs
end

local pendingBranches = {}
local failureBranches = {}
local successCount = 0

for _, env in ipairs(envs) do
local branch = env.branch or "?"
local phase = env.phase or "pending"
if phase == "failure" then
table.insert(failureBranches, branch)
elseif phase == "pending" then
table.insert(pendingBranches, branch)
elseif phase == "success" then
successCount = successCount + 1
else
table.insert(pendingBranches, branch)
end
end

if #failureBranches > 0 then
hs.status = "Degraded"
hs.message = "Git commit validation failed for branch(es): " .. table.concat(failureBranches, ", ")
return hs
end

if #pendingBranches > 0 then
hs.status = "Progressing"
hs.message = "Git commit validation pending for branch(es): " .. table.concat(pendingBranches, ", ")
return hs
end

hs.status = "Healthy"
hs.message = "Git commit validation passed for " .. tostring(successCount) .. " environment(s)"
return hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
tests:
- healthStatus:
status: Progressing
message: Initializing git commit validation
inputPath: testdata/no-status.yaml
- healthStatus:
status: Progressing
message: GitCommitStatus is being deleted
inputPath: testdata/deleting.yaml
- healthStatus:
status: Progressing
message: Waiting for GitCommitStatus spec update to be observed
inputPath: testdata/observed-generation-outdated.yaml
- healthStatus:
status: Degraded
message: "Git commit validation failed: Something went wrong"
inputPath: testdata/reconcile-error.yaml
- healthStatus:
status: Degraded
message: "Git commit validation not ready (CommitStatusesNotReady): CommitStatus \"git-commit-check-env-dev-git-commit-check\" is not Ready because \"ReconciliationError\": Failed to sync to SCM"
inputPath: testdata/commit-statuses-not-ready.yaml
- healthStatus:
status: Progressing
message: GitCommitStatus Ready condition is missing
inputPath: testdata/no-ready-condition.yaml
- healthStatus:
status: Progressing
message: "Git commit validation status unknown (CommitStatusesNotReady): CommitStatus \"child\" Ready condition is missing"
inputPath: testdata/ready-unknown.yaml
- healthStatus:
status: Healthy
message: Git commit validation reconciled
inputPath: testdata/empty-environments.yaml
- healthStatus:
status: Healthy
message: Git commit validation passed for 2 environment(s)
inputPath: testdata/all-success.yaml
- healthStatus:
status: Progressing
message: "Git commit validation pending for branch(es): env/dev"
inputPath: testdata/environment-pending.yaml
- healthStatus:
status: Degraded
message: "Git commit validation failed for branch(es): env/dev"
inputPath: testdata/environment-failure.yaml
- healthStatus:
status: Degraded
message: "Git commit validation failed: Reconciliation failed: failed to process environments: failed to evaluate expression for branch \"env/dev\": failed to compile expression: failed to compile expression: type string has no method startsWith (1:16)\n | Commit.Subject.startsWith(\"chore:\")\n | ...............^"
inputPath: testdata/expression-compile-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: promoter.argoproj.io/v1alpha1
kind: GitCommitStatus
metadata:
name: gitcommitstatus-proposed-mode
generation: 1
spec:
promotionStrategyRef:
name: promotion-strategy-sample
key: commit-format-check
description: Commit message format validation
target: proposed
expression: 'Commit.Subject matches "^(feat|fix|docs|chore)(\\(.+\\))?: .+"'
status:
conditions:
- type: Ready
status: "True"
reason: ReconciliationSuccess
message: Reconciliation successful
observedGeneration: 1
environments:
- branch: env/dev
proposedHydratedSha: "0123456789abcdef0123456789abcdef01234567"
targetedSha: "0123456789abcdef0123456789abcdef01234567"
activeHydratedSha: "fedcba0987654321fedcba0987654321fedcba09"
phase: success
expressionResult: true
- branch: env/staging
proposedHydratedSha: "abcdef0123456789abcdef0123456789abcdef01"
targetedSha: "abcdef0123456789abcdef0123456789abcdef01"
activeHydratedSha: "0123456789abcdef0123456789abcdef01234567"
phase: success
expressionResult: true
Loading
Loading