Skip to content

Commit

Permalink
rolling restart
Browse files Browse the repository at this point in the history
  • Loading branch information
catpineapple committed Nov 22, 2024
1 parent 5e70cdb commit c2cb4eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions pkg/controller/sub_controller/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ var (
MSServiceDeletedFailed EventReason = "MSServiceDeletedFailed"
MSStatefulsetDeleteFailed EventReason = "MSStatefulsetDeleteFailed"
FDBAddressNotConfiged EventReason = "FDBAddressNotConfiged"
RestartParameterIllegal EventReason = "RestartParameterIllegal"
RollingRestart EventReason = "Restarting"
RestartTimeInvalid EventReason = "RestartTimeInvalid"
)

type Event struct {
Expand Down
14 changes: 5 additions & 9 deletions pkg/controller/sub_controller/sub_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,15 @@ func (d *SubDefaultController) CheckRestartTimeAndInject(dcr *dorisv1.DorisClust
if err != nil {
checkErr := fmt.Errorf("CheckRestartTimeAndInject error: time format is incorrect. dorisClusterName: %s, namespace: %s, componentType %s, wrong parse 'restartedAt': %s , error: %s", dcr.Name, dcr.Namespace, componentType, restartedAt, err.Error())
klog.Error(checkErr.Error())
d.K8srecorder.Event(dcr, string(EventWarning), string(RestartParameterIllegal), checkErr.Error())
d.K8srecorder.Event(dcr, string(EventWarning), string(RestartTimeInvalid), checkErr.Error())
return false
}

restartAt := time.Now().Add(-10 * time.Minute)
effectiveStartTime := time.Now().Add(-10 * time.Minute)

if restartAt.After(parseTime) {
checkErr := fmt.Errorf("CheckRestartTimeAndInject The time has expired, dorisClusterName: %s, namespace: %s, componentType %s, wrong parse 'restartedAt': %s : The time has expired, if you want to restart doris, please set a future time", dcr.Name, dcr.Namespace, componentType, restartedAt)
klog.Error(checkErr.Error())
d.K8srecorder.Event(dcr, string(EventWarning), string(RestartParameterIllegal), checkErr.Error())
if effectiveStartTime.After(parseTime) {
klog.Errorf("CheckRestartTimeAndInject The time has expired, dorisClusterName: %s, namespace: %s, componentType %s, wrong parse 'restartedAt': %s : The time has expired, if you want to restart doris, please set a future time", dcr.Name, dcr.Namespace, componentType, restartedAt)
d.K8srecorder.Event(dcr, string(EventWarning), string(RestartTimeInvalid), fmt.Sprintf("the %s restart time is not effective. the 'restartedAt' %s can't be earlier than 10 minutes before the current time", componentType, restartedAt))
return false
}

Expand Down Expand Up @@ -120,9 +119,6 @@ func (d *SubDefaultController) ClassifyPodsByStatus(namespace string, status *do
podmap := make(map[string]corev1.Pod)

if len(podList.Items) == 0 {
status.RunningMembers = readys
status.FailedMembers = faileds
status.CreatingMembers = creatings
return nil
}

Expand Down

0 comments on commit c2cb4eb

Please sign in to comment.