mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
feat(health-check): Add resource_customizations for game.kruise.io (new) (#23558)
Signed-off-by: shiqisong <1355703321@qq.com>
This commit is contained in:
32
resource_customizations/game.kruise.io/GameServer/health.lua
Normal file
32
resource_customizations/game.kruise.io/GameServer/health.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
hs = {status="Unknown", message="Waiting for GameServer to be ready"}
|
||||
|
||||
if obj.status then
|
||||
local cur = obj.status.currentState
|
||||
local dest = obj.status.desiredState
|
||||
|
||||
-- 1) Check cur and dest status: Progressing
|
||||
if cur ~= dest then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "State change: " .. (cur or "Unknown") .. " → " .. (dest or "Unknown")
|
||||
return hs
|
||||
end
|
||||
|
||||
-- 2) Check pod: KruisePodReady
|
||||
local podCond = obj.status.podStatus or {}
|
||||
for _, c in ipairs(podCond.conditions or {}) do
|
||||
if c.type == "KruisePodReady" and c.status ~= "True" then
|
||||
hs.status = "Degraded"
|
||||
hs.message = "Pod is not ready: " .. c.type
|
||||
return hs
|
||||
end
|
||||
end
|
||||
|
||||
-- 3) Both ready: Healthy
|
||||
if cur == "Ready" and dest == "Ready" then
|
||||
hs.status = "Healthy"
|
||||
hs.message = "GameServer is Ready"
|
||||
return hs
|
||||
end
|
||||
end
|
||||
|
||||
return hs
|
||||
@@ -0,0 +1,20 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: GameServer is Ready
|
||||
inputPath: testdata/healthy.yaml
|
||||
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'State change: Creating → Ready'
|
||||
inputPath: testdata/progressing.yaml
|
||||
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: 'Pod is not ready: KruisePodReady'
|
||||
inputPath: testdata/degraded.yaml
|
||||
|
||||
- healthStatus:
|
||||
status: Unknown
|
||||
message: Waiting for GameServer to be ready
|
||||
inputPath: testdata/unknown.yaml
|
||||
13
resource_customizations/game.kruise.io/GameServer/testdata/degraded.yaml
vendored
Normal file
13
resource_customizations/game.kruise.io/GameServer/testdata/degraded.yaml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: game.kruise.io/v1alpha1
|
||||
kind: GameServer
|
||||
metadata:
|
||||
name: gs-degraded
|
||||
status:
|
||||
currentState: "Ready"
|
||||
desiredState: "Ready"
|
||||
podStatus:
|
||||
conditions:
|
||||
- type: "Ready"
|
||||
status: "True"
|
||||
- type: "KruisePodReady"
|
||||
status: "False"
|
||||
12
resource_customizations/game.kruise.io/GameServer/testdata/healthy.yaml
vendored
Normal file
12
resource_customizations/game.kruise.io/GameServer/testdata/healthy.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: game.kruise.io/v1alpha1
|
||||
kind: GameServer
|
||||
metadata:
|
||||
name: gs-healthy
|
||||
status:
|
||||
currentState: Ready
|
||||
desiredState: Ready
|
||||
conditions:
|
||||
- type: PodNormal
|
||||
status: "True"
|
||||
- type: NodeNormal
|
||||
status: "True"
|
||||
7
resource_customizations/game.kruise.io/GameServer/testdata/progressing.yaml
vendored
Normal file
7
resource_customizations/game.kruise.io/GameServer/testdata/progressing.yaml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: game.kruise.io/v1alpha1
|
||||
kind: GameServer
|
||||
metadata:
|
||||
name: gs-progressing
|
||||
status:
|
||||
currentState: "Creating"
|
||||
desiredState: "Ready"
|
||||
5
resource_customizations/game.kruise.io/GameServer/testdata/unknown.yaml
vendored
Normal file
5
resource_customizations/game.kruise.io/GameServer/testdata/unknown.yaml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
apiVersion: game.kruise.io/v1alpha1
|
||||
kind: GameServer
|
||||
metadata:
|
||||
name: gs-unknown
|
||||
spec: {}
|
||||
@@ -0,0 +1,38 @@
|
||||
hs = {status="Progressing", message="Waiting for GameServerSet initialization"}
|
||||
|
||||
if obj.status and obj.metadata.generation == obj.status.observedGeneration then
|
||||
local ru = obj.spec.updateStrategy and obj.spec.updateStrategy.rollingUpdate or {}
|
||||
|
||||
-- 1) Pause
|
||||
if ru.paused == true then
|
||||
hs.status = "Suspended"
|
||||
hs.message = "GameServerSet is paused"
|
||||
return hs
|
||||
end
|
||||
|
||||
-- 2) Partition
|
||||
local partition = ru.partition or 0
|
||||
if partition ~= 0 and (obj.status.updatedReplicas or 0) >= (obj.status.replicas or 0) - partition then
|
||||
hs.status = "Suspended"
|
||||
hs.message = "Partition=" .. partition .. ", waiting for manual intervention"
|
||||
return hs
|
||||
end
|
||||
|
||||
-- 3) All updated and ready
|
||||
if (obj.status.updatedReadyReplicas or 0) == (obj.status.replicas or 0) then
|
||||
hs.status = "Healthy"
|
||||
hs.message = "All GameServerSet replicas are updated and ready"
|
||||
return hs
|
||||
end
|
||||
|
||||
-- 4) ReadyRelicas not enough
|
||||
if (obj.status.readyReplicas or 0) < (obj.status.replicas or 0) then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "ReadyReplicas " ..
|
||||
(obj.status.readyReplicas or 0) .. "/" ..
|
||||
(obj.status.replicas or 0) .. ", still progressing"
|
||||
return hs
|
||||
end
|
||||
end
|
||||
|
||||
return hs
|
||||
@@ -0,0 +1,25 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: All GameServerSet replicas are updated and ready
|
||||
inputPath: testdata/healthy.yaml
|
||||
|
||||
- healthStatus:
|
||||
status: Suspended
|
||||
message: GameServerSet is paused
|
||||
inputPath: testdata/suspended-paused.yaml
|
||||
|
||||
- healthStatus:
|
||||
status: Suspended
|
||||
message: Partition=2, waiting for manual intervention
|
||||
inputPath: testdata/suspended-partition.yaml
|
||||
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'ReadyReplicas 2/3, still progressing'
|
||||
inputPath: testdata/progressing.yaml
|
||||
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: Waiting for GameServerSet initialization
|
||||
inputPath: testdata/progressing-init.yaml
|
||||
11
resource_customizations/game.kruise.io/GameServerSet/testdata/healthy.yaml
vendored
Normal file
11
resource_customizations/game.kruise.io/GameServerSet/testdata/healthy.yaml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: game.kruise.io/v1alpha1
|
||||
kind: GameServerSet
|
||||
metadata:
|
||||
generation: 1
|
||||
spec:
|
||||
replicas: 3
|
||||
status:
|
||||
observedGeneration: 1
|
||||
replicas: 3
|
||||
readyReplicas: 3
|
||||
updatedReadyReplicas: 3
|
||||
9
resource_customizations/game.kruise.io/GameServerSet/testdata/progressing-init.yaml
vendored
Normal file
9
resource_customizations/game.kruise.io/GameServerSet/testdata/progressing-init.yaml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
apiVersion: game.kruise.io/v1alpha1
|
||||
kind: GameServerSet
|
||||
metadata:
|
||||
generation: 2
|
||||
spec:
|
||||
replicas: 3
|
||||
status:
|
||||
observedGeneration: 1
|
||||
replicas: 3
|
||||
11
resource_customizations/game.kruise.io/GameServerSet/testdata/progressing.yaml
vendored
Normal file
11
resource_customizations/game.kruise.io/GameServerSet/testdata/progressing.yaml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: game.kruise.io/v1alpha1
|
||||
kind: GameServerSet
|
||||
metadata:
|
||||
generation: 1
|
||||
spec:
|
||||
replicas: 3
|
||||
status:
|
||||
observedGeneration: 1
|
||||
replicas: 3
|
||||
readyReplicas: 2
|
||||
updatedReadyReplicas: 2
|
||||
13
resource_customizations/game.kruise.io/GameServerSet/testdata/suspended-partition.yaml
vendored
Normal file
13
resource_customizations/game.kruise.io/GameServerSet/testdata/suspended-partition.yaml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: game.kruise.io/v1alpha1
|
||||
kind: GameServerSet
|
||||
metadata:
|
||||
generation: 1
|
||||
spec:
|
||||
replicas: 5
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 2
|
||||
status:
|
||||
observedGeneration: 1
|
||||
replicas: 5
|
||||
updatedReplicas: 3
|
||||
12
resource_customizations/game.kruise.io/GameServerSet/testdata/suspended-paused.yaml
vendored
Normal file
12
resource_customizations/game.kruise.io/GameServerSet/testdata/suspended-paused.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: game.kruise.io/v1alpha1
|
||||
kind: GameServerSet
|
||||
metadata:
|
||||
generation: 1
|
||||
spec:
|
||||
replicas: 3
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
paused: true
|
||||
status:
|
||||
observedGeneration: 1
|
||||
replicas: 3
|
||||
Reference in New Issue
Block a user