mirror of https://github.com/fluxcd/cli-utils.git
Status for dep, sts and rs should be InProgress if extra replicas
This commit is contained in:
parent
bf15fe7252
commit
bd0e6cb28e
|
|
@ -41,6 +41,7 @@ const (
|
||||||
tooFewAvailable = "LessAvailable"
|
tooFewAvailable = "LessAvailable"
|
||||||
tooFewUpdated = "LessUpdated"
|
tooFewUpdated = "LessUpdated"
|
||||||
tooFewReplicas = "LessReplicas"
|
tooFewReplicas = "LessReplicas"
|
||||||
|
extraPods = "ExtraPods"
|
||||||
|
|
||||||
onDeleteUpdateStrategy = "OnDelete"
|
onDeleteUpdateStrategy = "OnDelete"
|
||||||
)
|
)
|
||||||
|
|
@ -104,6 +105,11 @@ func stsConditions(u *unstructured.Unstructured) (*Result, error) {
|
||||||
return newInProgressStatus(tooFewReady, message), nil
|
return newInProgressStatus(tooFewReady, message), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if statusReplicas > specReplicas {
|
||||||
|
message := fmt.Sprintf("Pending termination: %d", statusReplicas-specReplicas)
|
||||||
|
return newInProgressStatus(extraPods, message), nil
|
||||||
|
}
|
||||||
|
|
||||||
// https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#partitions
|
// https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#partitions
|
||||||
if partition != -1 {
|
if partition != -1 {
|
||||||
if updatedReplicas < (specReplicas - partition) {
|
if updatedReplicas < (specReplicas - partition) {
|
||||||
|
|
@ -205,9 +211,9 @@ func deploymentConditions(u *unstructured.Unstructured) (*Result, error) {
|
||||||
return newInProgressStatus(tooFewUpdated, message), nil
|
return newInProgressStatus(tooFewUpdated, message), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if statusReplicas > updatedReplicas {
|
if statusReplicas > specReplicas {
|
||||||
message := fmt.Sprintf("Pending termination: %d", statusReplicas-updatedReplicas)
|
message := fmt.Sprintf("Pending termination: %d", statusReplicas-specReplicas)
|
||||||
return newInProgressStatus("ExtraPods", message), nil
|
return newInProgressStatus(extraPods, message), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if updatedReplicas > availableReplicas {
|
if updatedReplicas > availableReplicas {
|
||||||
|
|
@ -277,9 +283,9 @@ func replicasetConditions(u *unstructured.Unstructured) (*Result, error) {
|
||||||
return newInProgressStatus(tooFewReady, message), nil
|
return newInProgressStatus(tooFewReady, message), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if specReplicas < statusReplicas {
|
if statusReplicas > specReplicas {
|
||||||
message := fmt.Sprintf("replicas: %d/%d", statusReplicas, specReplicas)
|
message := fmt.Sprintf("Pending termination: %d", statusReplicas-specReplicas)
|
||||||
return newInProgressStatus("ExtraPods", message), nil
|
return newInProgressStatus(extraPods, message), nil
|
||||||
}
|
}
|
||||||
// All ok
|
// All ok
|
||||||
return &Result{
|
return &Result{
|
||||||
|
|
|
||||||
|
|
@ -340,6 +340,21 @@ status:
|
||||||
readyReplicas: 4
|
readyReplicas: 4
|
||||||
replicas: 4
|
replicas: 4
|
||||||
`
|
`
|
||||||
|
var stsExtraPods = `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
generation: 1
|
||||||
|
name: test
|
||||||
|
namespace: qual
|
||||||
|
spec:
|
||||||
|
replicas: 4
|
||||||
|
status:
|
||||||
|
observedGeneration: 1
|
||||||
|
currentReplicas: 4
|
||||||
|
readyReplicas: 4
|
||||||
|
replicas: 8
|
||||||
|
`
|
||||||
|
|
||||||
func TestStsStatus(t *testing.T) {
|
func TestStsStatus(t *testing.T) {
|
||||||
testCases := map[string]testSpec{
|
testCases := map[string]testSpec{
|
||||||
|
|
@ -400,6 +415,18 @@ func TestStsStatus(t *testing.T) {
|
||||||
ConditionStalled,
|
ConditionStalled,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"stsExtraPods": {
|
||||||
|
spec: stsExtraPods,
|
||||||
|
expectedStatus: InProgressStatus,
|
||||||
|
expectedConditions: []Condition{{
|
||||||
|
Type: ConditionReconciling,
|
||||||
|
Status: corev1.ConditionTrue,
|
||||||
|
Reason: "ExtraPods",
|
||||||
|
}},
|
||||||
|
absentConditionTypes: []ConditionType{
|
||||||
|
ConditionStalled,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for tn, tc := range testCases {
|
for tn, tc := range testCases {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue