-
Notifications
You must be signed in to change notification settings - Fork 435
[Misc] feature: add Progressing condition in roleset controller #1308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,8 @@ func (r *RoleSetReconciler) calculateStatus(ctx context.Context, rs *orchestrati | |
newStatus := rs.Status.DeepCopy() | ||
newStatus.Roles = nil | ||
var notReadyRoles []string | ||
var progressingRoles []string | ||
isProgressing := false | ||
for _, role := range rs.Spec.Roles { | ||
if roleStatus, err := r.calculateStatusForRole(ctx, rs, &role); err != nil { | ||
// TODO: add into condition | ||
|
@@ -105,20 +107,63 @@ func (r *RoleSetReconciler) calculateStatus(ctx context.Context, rs *orchestrati | |
if roleStatus.ReadyReplicas < *role.Replicas { | ||
notReadyRoles = append(notReadyRoles, role.Name) | ||
} | ||
if roleStatus.ReadyReplicas < *role.Replicas || | ||
roleStatus.UpdatedReadyReplicas < roleStatus.UpdatedReplicas || | ||
(roleStatus.UpdatedReplicas > 0 && roleStatus.UpdatedReadyReplicas < roleStatus.UpdatedReplicas) { | ||
progressingRoles = append(progressingRoles, role.Name) | ||
isProgressing = true | ||
} | ||
Comment on lines
+110
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition to check if a role is progressing is partially redundant. The third part of the If if roleStatus.ReadyReplicas < *role.Replicas ||
roleStatus.UpdatedReadyReplicas < roleStatus.UpdatedReplicas {
progressingRoles = append(progressingRoles, role.Name)
isProgressing = true
} |
||
} | ||
} | ||
|
||
if len(notReadyRoles) > 0 { | ||
notReadyCondition := utils.NewCondition(orchestrationv1alpha1.RoleSetReady, v1.ConditionFalse, "roleset is not ready", fmt.Sprintf("role %s is not ready", strings.Join(notReadyRoles, ","))) | ||
notReadyCondition := utils.NewCondition( | ||
orchestrationv1alpha1.RoleSetReady, | ||
v1.ConditionFalse, | ||
orchestrationv1alpha1.RoleSetReasonRolesNotReady, | ||
fmt.Sprintf("Roles %s are not ready", strings.Join(notReadyRoles, ",")), | ||
) | ||
SetRoleSetCondition(newStatus, *notReadyCondition) | ||
} else { | ||
readyCondition := utils.NewCondition(orchestrationv1alpha1.RoleSetReady, v1.ConditionTrue, "roleset is ready", "") | ||
readyCondition := utils.NewCondition( | ||
orchestrationv1alpha1.RoleSetReady, | ||
v1.ConditionTrue, | ||
orchestrationv1alpha1.RoleSetReasonRolesReady, | ||
"All roles are ready", | ||
) | ||
SetRoleSetCondition(newStatus, *readyCondition) | ||
} | ||
|
||
if isProgressing { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is Progressing, add condition. |
||
cond := utils.NewCondition( | ||
orchestrationv1alpha1.RoleSetProgressing, | ||
v1.ConditionTrue, | ||
orchestrationv1alpha1.RoleSetReasonRolesProgressing, | ||
fmt.Sprintf("Roles %s are progressing", strings.Join(progressingRoles, ", ")), | ||
) | ||
SetRoleSetCondition(newStatus, *cond) | ||
} else { | ||
// If all roles are ready, set the Progressing condition to complete. | ||
currentProgressingCond := utils.GetCondition(rs.Status.Conditions, orchestrationv1alpha1.RoleSetProgressing) | ||
if currentProgressingCond != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic sets the if currentProgressingCond != nil && currentProgressingCond.Status == v1.ConditionTrue { |
||
cond := utils.NewCondition( | ||
orchestrationv1alpha1.RoleSetProgressing, | ||
v1.ConditionFalse, | ||
orchestrationv1alpha1.RoleSetReasonProgressingComplete, | ||
"All roles have completed progressing", | ||
) | ||
SetRoleSetCondition(newStatus, *cond) | ||
} | ||
} | ||
|
||
failureCond := utils.GetCondition(rs.Status.Conditions, orchestrationv1alpha1.RoleSetReplicaFailure) | ||
if len(managedErrors) != 0 && failureCond == nil { | ||
cond := utils.NewCondition(orchestrationv1alpha1.RoleSetReplicaFailure, v1.ConditionTrue, "reconcile roleset error", fmt.Sprintf("%+v", managedErrors)) | ||
cond := utils.NewCondition( | ||
orchestrationv1alpha1.RoleSetReplicaFailure, | ||
v1.ConditionTrue, | ||
orchestrationv1alpha1.RoleSetReasonReconcileError, | ||
fmt.Sprintf("%+v", managedErrors), | ||
) | ||
SetRoleSetCondition(newStatus, *cond) | ||
} else if len(managedErrors) == 0 && failureCond != nil { | ||
RemoveRoleSetCondition(newStatus, orchestrationv1alpha1.RoleSetReplicaFailure) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current Progressing logic is as here 🤔