psmdb.percona.com/PerconaServerMongoDB resource customization (#20628)

Signed-off-by: Niv Amitai <niv@connecteam.com>
This commit is contained in:
niv8
2024-12-10 12:44:43 +02:00
committed by GitHub
parent 9741c065d8
commit 2f51067e75
8 changed files with 178 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
local hs = {}
if obj.status ~= nil then
local state_map = {
initializing = "Progressing",
ready = "Healthy",
error = "Degraded",
stopping = "Progressing",
paused = "Suspended"
}
hs.status = state_map[obj.status.state] or "Unknown"
hs.message = obj.status.ready .. "/" .. obj.status.size .. " node(s) are ready"
return hs
end
hs.status = "Unknown"
hs.message = "Cluster status is unknown"
return hs

View File

@@ -0,0 +1,25 @@
tests:
- healthStatus:
status: Progressing
message: "0/9 node(s) are ready"
inputPath: testdata/initializing.yaml
- healthStatus:
status: Healthy
message: "9/9 node(s) are ready"
inputPath: testdata/ready.yaml
- healthStatus:
status: Suspended
message: "0/9 node(s) are ready"
inputPath: testdata/paused.yaml
- healthStatus:
status: Progressing
message: "6/9 node(s) are ready"
inputPath: testdata/stopping.yaml
- healthStatus:
status: Degraded
message: "0/9 node(s) are ready"
inputPath: testdata/error.yaml
- healthStatus:
status: Unknown
message: "0/0 node(s) are ready"
inputPath: testdata/unknown.yaml

View File

@@ -0,0 +1,25 @@
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
name: cluster
spec: {}
status:
mongos:
ready: 0
size: 3
status: error
observedGeneration: 1
ready: 0
replsets:
cfg:
initialized: true
ready: 0
size: 3
status: error
rs0:
initialized: true
ready: 0
size: 3
status: error
size: 9
state: error

View File

@@ -0,0 +1,25 @@
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
name: cluster
spec: {}
status:
mongos:
ready: 0
size: 3
status: initializing
observedGeneration: 1
ready: 0
replsets:
cfg:
initialized: false
ready: 0
size: 3
status: initializing
rs0:
initialized: false
ready: 0
size: 3
status: initializing
size: 9
state: initializing

View File

@@ -0,0 +1,25 @@
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
name: cluster
spec: {}
status:
mongos:
ready: 0
size: 3
status: paused
observedGeneration: 1
ready: 0
replsets:
cfg:
initialized: true
ready: 0
size: 3
status: paused
rs0:
initialized: true
ready: 0
size: 3
status: paused
size: 9
state: paused

View File

@@ -0,0 +1,25 @@
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
name: cluster
spec: {}
status:
mongos:
ready: 3
size: 3
status: ready
observedGeneration: 1
ready: 9
replsets:
cfg:
initialized: true
ready: 3
size: 3
status: ready
rs0:
initialized: true
ready: 3
size: 3
status: ready
size: 9
state: ready

View File

@@ -0,0 +1,25 @@
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
name: cluster
spec: {}
status:
mongos:
ready: 2
size: 3
status: stopping
observedGeneration: 1
ready: 6
replsets:
cfg:
initialized: true
ready: 2
size: 3
status: stopping
rs0:
initialized: true
ready: 2
size: 3
status: stopping
size: 9
state: stopping

View File

@@ -0,0 +1,10 @@
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
name: cluster
spec: {}
status:
observedGeneration: 1
ready: 0
size: 0
state: ""