Skip to content

Commit

Permalink
adding updatedAvailableReplicas field
Browse files Browse the repository at this point in the history
Signed-off-by: ntishchauhan0022 <[email protected]>
  • Loading branch information
nitishchauhan0022 committed Jun 16, 2023
1 parent ffcf189 commit 01ae904
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
4 changes: 4 additions & 0 deletions apis/apps/v1alpha1/cloneset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ type CloneSetStatus struct {
// indicated by updateRevision and have a Ready Condition.
UpdatedReadyReplicas int32 `json:"updatedReadyReplicas"`

// UpdatedAvailabelReplicas is the number of Pods created by the CloneSet controller from the CloneSet version
// indicated by updateRevision and have a Ready Condition for at least minReadySeconds.
UpdatedAvailabelReplicas int32 `json:"updatedAvailabelReplicas"`

// ExpectedUpdatedReplicas is the number of Pods that should be updated by CloneSet controller.
// This field is calculated via Replicas - Partition.
ExpectedUpdatedReplicas int32 `json:"expectedUpdatedReplicas,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions apis/apps/v1beta1/statefulset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ type StatefulSetStatus struct {
// updatedReadyReplicas is the number of updated Pods created by the StatefulSet controller that have a Ready Condition.
UpdatedReadyReplicas int32 `json:"updatedReadyReplicas,omitempty"`

// updatedAvailbelReplicas is the number of updated Pods created by the StatefulSet controller that have a Ready condition
//for atleast minReadySeconds.
UpdatedAvailabelReplicas int32 `json:"updatedAvailabelReplicas,omitempty"`

// currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the
// sequence [0,currentReplicas).
CurrentRevision string `json:"currentRevision,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/apps.kruise.io_clonesets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,12 @@ spec:
description: UpdateRevision, if not empty, indicates the latest revision
of the CloneSet.
type: string
updatedAvailabelReplicas:
description: UpdatedAvailabelReplicas is the number of Pods created
by the CloneSet controller from the CloneSet version indicated by
updateRevision and have a Ready Condition for at least minReadySeconds.
format: int32
type: integer
updatedReadyReplicas:
description: UpdatedReadyReplicas is the number of Pods created by
the CloneSet controller from the CloneSet version indicated by updateRevision
Expand All @@ -513,6 +519,7 @@ spec:
- availableReplicas
- readyReplicas
- replicas
- updatedAvailabelReplicas
- updatedReadyReplicas
- updatedReplicas
type: object
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/apps.kruise.io_statefulsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,12 @@ spec:
description: updateRevision, if not empty, indicates the version of
the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)
type: string
updatedAvailabelReplicas:
description: updatedAvailbelReplicas is the number of updated Pods
created by the StatefulSet controller that have a Ready condition
for atleast minReadySeconds.
format: int32
type: integer
updatedReadyReplicas:
description: updatedReadyReplicas is the number of updated Pods created
by the StatefulSet controller that have a Ready Condition.
Expand Down
14 changes: 7 additions & 7 deletions pkg/client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions pkg/client/clientset/versioned/scheme/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/controller/cloneset/cloneset_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (r *realStatusUpdater) inconsistentStatus(cs *appsv1alpha1.CloneSet, newSta
newStatus.AvailableReplicas != oldStatus.AvailableReplicas ||
newStatus.UpdatedReadyReplicas != oldStatus.UpdatedReadyReplicas ||
newStatus.UpdatedReplicas != oldStatus.UpdatedReplicas ||
newStatus.UpdatedAvailableReplicas != oldStatus.UpdatedAvailableReplicas ||
newStatus.ExpectedUpdatedReplicas != oldStatus.ExpectedUpdatedReplicas ||
newStatus.UpdateRevision != oldStatus.UpdateRevision ||
newStatus.CurrentRevision != oldStatus.CurrentRevision ||
Expand All @@ -99,6 +100,9 @@ func (r *realStatusUpdater) calculateStatus(cs *appsv1alpha1.CloneSet, newStatus
if clonesetutils.EqualToRevisionHash("", pod, newStatus.UpdateRevision) && coreControl.IsPodUpdateReady(pod, 0) {
newStatus.UpdatedReadyReplicas++
}
if clonesetutils.EqualToRevisionHash("", pod, newStatus.UpdateRevision) && sync.IsPodAvailable(coreControl, pod, cs.Spec.MinReadySeconds) {
newStatus.UpdatedAvailableReplicas++
}
}
// Consider the update revision as stable if revisions of all pods are consistent to it, no need to wait all of them ready
if newStatus.UpdatedReplicas == newStatus.Replicas {
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/statefulset/stateful_set_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
status.ReadyReplicas++
if getPodRevision(pods[i]) == updateRevision.Name {
status.UpdatedReadyReplicas++
if avail, _ := isRunningAndAvailable(pods[i], minReadySeconds); avail {
status.UpdatedAvailabelReplicas++
}
}
if avail, _ := isRunningAndAvailable(pods[i], minReadySeconds); avail {
status.AvailableReplicas++
Expand Down

0 comments on commit 01ae904

Please sign in to comment.