@@ -95,6 +95,8 @@ func (r *RoleSetReconciler) calculateStatus(ctx context.Context, rs *orchestrati
95
95
newStatus := rs .Status .DeepCopy ()
96
96
newStatus .Roles = nil
97
97
var notReadyRoles []string
98
+ var progressingRoles []string
99
+ isProgressing := false
98
100
for _ , role := range rs .Spec .Roles {
99
101
if roleStatus , err := r .calculateStatusForRole (ctx , rs , & role ); err != nil {
100
102
// TODO: add into condition
@@ -105,20 +107,63 @@ func (r *RoleSetReconciler) calculateStatus(ctx context.Context, rs *orchestrati
105
107
if roleStatus .ReadyReplicas < * role .Replicas {
106
108
notReadyRoles = append (notReadyRoles , role .Name )
107
109
}
110
+ if roleStatus .ReadyReplicas < * role .Replicas ||
111
+ roleStatus .UpdatedReadyReplicas < roleStatus .UpdatedReplicas ||
112
+ (roleStatus .UpdatedReplicas > 0 && roleStatus .UpdatedReadyReplicas < roleStatus .UpdatedReplicas ) {
113
+ progressingRoles = append (progressingRoles , role .Name )
114
+ isProgressing = true
115
+ }
108
116
}
109
117
}
110
118
111
119
if len (notReadyRoles ) > 0 {
112
- notReadyCondition := utils .NewCondition (orchestrationv1alpha1 .RoleSetReady , v1 .ConditionFalse , "roleset is not ready" , fmt .Sprintf ("role %s is not ready" , strings .Join (notReadyRoles , "," )))
120
+ notReadyCondition := utils .NewCondition (
121
+ orchestrationv1alpha1 .RoleSetReady ,
122
+ v1 .ConditionFalse ,
123
+ orchestrationv1alpha1 .RoleSetReasonRolesNotReady ,
124
+ fmt .Sprintf ("Roles %s is not ready" , strings .Join (notReadyRoles , "," )),
125
+ )
113
126
SetRoleSetCondition (newStatus , * notReadyCondition )
114
127
} else {
115
- readyCondition := utils .NewCondition (orchestrationv1alpha1 .RoleSetReady , v1 .ConditionTrue , "roleset is ready" , "" )
128
+ readyCondition := utils .NewCondition (
129
+ orchestrationv1alpha1 .RoleSetReady ,
130
+ v1 .ConditionTrue ,
131
+ orchestrationv1alpha1 .RoleSetReasonRolesReady ,
132
+ "All roles are ready" ,
133
+ )
116
134
SetRoleSetCondition (newStatus , * readyCondition )
117
135
}
118
136
137
+ if isProgressing {
138
+ cond := utils .NewCondition (
139
+ orchestrationv1alpha1 .RoleSetProgressing ,
140
+ v1 .ConditionTrue ,
141
+ orchestrationv1alpha1 .RoleSetReasonRolesProgressing ,
142
+ fmt .Sprintf ("Roles %s are progressing" , strings .Join (progressingRoles , ", " )),
143
+ )
144
+ SetRoleSetCondition (newStatus , * cond )
145
+ } else {
146
+ // If all roles are ready, set the Progressing condition to complete.
147
+ currentProgressingCond := utils .GetCondition (rs .Status .Conditions , orchestrationv1alpha1 .RoleSetProgressing )
148
+ if currentProgressingCond != nil {
149
+ cond := utils .NewCondition (
150
+ orchestrationv1alpha1 .RoleSetProgressing ,
151
+ v1 .ConditionFalse ,
152
+ orchestrationv1alpha1 .RoleSetReasonProgressingComplete ,
153
+ "All roles have completed progressing" ,
154
+ )
155
+ SetRoleSetCondition (newStatus , * cond )
156
+ }
157
+ }
158
+
119
159
failureCond := utils .GetCondition (rs .Status .Conditions , orchestrationv1alpha1 .RoleSetReplicaFailure )
120
160
if len (managedErrors ) != 0 && failureCond == nil {
121
- cond := utils .NewCondition (orchestrationv1alpha1 .RoleSetReplicaFailure , v1 .ConditionTrue , "reconcile roleset error" , fmt .Sprintf ("%+v" , managedErrors ))
161
+ cond := utils .NewCondition (
162
+ orchestrationv1alpha1 .RoleSetReplicaFailure ,
163
+ v1 .ConditionTrue ,
164
+ orchestrationv1alpha1 .RoleSetReasonReconcileError ,
165
+ fmt .Sprintf ("%+v" , managedErrors ),
166
+ )
122
167
SetRoleSetCondition (newStatus , * cond )
123
168
} else if len (managedErrors ) == 0 && failureCond != nil {
124
169
RemoveRoleSetCondition (newStatus , orchestrationv1alpha1 .RoleSetReplicaFailure )
0 commit comments