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"
|
||||
tooFewUpdated = "LessUpdated"
|
||||
tooFewReplicas = "LessReplicas"
|
||||
extraPods = "ExtraPods"
|
||||
|
||||
onDeleteUpdateStrategy = "OnDelete"
|
||||
)
|
||||
|
|
@ -104,6 +105,11 @@ func stsConditions(u *unstructured.Unstructured) (*Result, error) {
|
|||
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
|
||||
if partition != -1 {
|
||||
if updatedReplicas < (specReplicas - partition) {
|
||||
|
|
@ -205,9 +211,9 @@ func deploymentConditions(u *unstructured.Unstructured) (*Result, error) {
|
|||
return newInProgressStatus(tooFewUpdated, message), nil
|
||||
}
|
||||
|
||||
if statusReplicas > updatedReplicas {
|
||||
message := fmt.Sprintf("Pending termination: %d", statusReplicas-updatedReplicas)
|
||||
return newInProgressStatus("ExtraPods", message), nil
|
||||
if statusReplicas > specReplicas {
|
||||
message := fmt.Sprintf("Pending termination: %d", statusReplicas-specReplicas)
|
||||
return newInProgressStatus(extraPods, message), nil
|
||||
}
|
||||
|
||||
if updatedReplicas > availableReplicas {
|
||||
|
|
@ -277,9 +283,9 @@ func replicasetConditions(u *unstructured.Unstructured) (*Result, error) {
|
|||
return newInProgressStatus(tooFewReady, message), nil
|
||||
}
|
||||
|
||||
if specReplicas < statusReplicas {
|
||||
message := fmt.Sprintf("replicas: %d/%d", statusReplicas, specReplicas)
|
||||
return newInProgressStatus("ExtraPods", message), nil
|
||||
if statusReplicas > specReplicas {
|
||||
message := fmt.Sprintf("Pending termination: %d", statusReplicas-specReplicas)
|
||||
return newInProgressStatus(extraPods, message), nil
|
||||
}
|
||||
// All ok
|
||||
return &Result{
|
||||
|
|
|
|||
|
|
@ -340,6 +340,21 @@ status:
|
|||
readyReplicas: 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) {
|
||||
testCases := map[string]testSpec{
|
||||
|
|
@ -400,6 +415,18 @@ func TestStsStatus(t *testing.T) {
|
|||
ConditionStalled,
|
||||
},
|
||||
},
|
||||
"stsExtraPods": {
|
||||
spec: stsExtraPods,
|
||||
expectedStatus: InProgressStatus,
|
||||
expectedConditions: []Condition{{
|
||||
Type: ConditionReconciling,
|
||||
Status: corev1.ConditionTrue,
|
||||
Reason: "ExtraPods",
|
||||
}},
|
||||
absentConditionTypes: []ConditionType{
|
||||
ConditionStalled,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for tn, tc := range testCases {
|
||||
|
|
|
|||
Loading…
Reference in New Issue