Skip to content

Commit

Permalink
Merge pull request #23 from Al-assad/dev
Browse files Browse the repository at this point in the history
PreStop lifecycle for FE, BE and Broker
  • Loading branch information
Al-assad authored Nov 25, 2023
2 parents 616387d + 80b10dd commit 33603ae
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/transformer/be_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ func MakeBeStatefulSet(cr *dapi.DorisCluster, scheme *runtime.Scheme) *appv1.Sta
{Name: "be-storage", MountPath: "/opt/apache-doris/be/storage"},
{Name: "be-log", MountPath: "/opt/apache-doris/be/log"},
},
Lifecycle: &corev1.Lifecycle{
PreStop: util.NewExecLifecycleHandler("/bin/sh", "-c", "bin/stop_be.sh"),
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: util.NewTcpSocketProbeHandler(GetBeHeartbeatServicePort(cr)),
TimeoutSeconds: 1,
Expand Down
3 changes: 3 additions & 0 deletions internal/transformer/broker_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func MakeBrokerStatefulSet(cr *dapi.DorisCluster, scheme *runtime.Scheme) *appv1
VolumeMounts: []corev1.VolumeMount{
{Name: "conf", MountPath: "/opt/apache-doris/broker/conf"},
},
Lifecycle: &corev1.Lifecycle{
PreStop: util.NewExecLifecycleHandler("/bin/sh", "-c", "bin/stop_broker.sh"),
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: util.NewTcpSocketProbeHandler(GetBrokerIpcPort(cr)),
TimeoutSeconds: 1,
Expand Down
3 changes: 3 additions & 0 deletions internal/transformer/cn_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ func MakeCnStatefulSet(cr *dapi.DorisCluster, scheme *runtime.Scheme) *appv1.Sta
{Name: "conf", MountPath: "/etc/apache-doris/be/"},
{Name: "cn-log", MountPath: "/opt/apache-doris/be/log"},
},
Lifecycle: &corev1.Lifecycle{
PreStop: util.NewExecLifecycleHandler("/bin/sh", "-c", "bin/stop_be.sh"),
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: util.NewTcpSocketProbeHandler(GetCnHeartbeatServicePort(cr)),
TimeoutSeconds: 1,
Expand Down
3 changes: 3 additions & 0 deletions internal/transformer/fe_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ func MakeFeStatefulSet(cr *dapi.DorisCluster, scheme *runtime.Scheme) *appv1.Sta
{Name: "fe-meta", MountPath: "/opt/apache-doris/fe/doris-meta"},
{Name: "fe-log", MountPath: "/opt/apache-doris/fe/log"},
},
Lifecycle: &corev1.Lifecycle{
PreStop: util.NewExecLifecycleHandler("/bin/sh", "-c", "bin/stop_fe.sh"),
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: util.NewTcpSocketProbeHandler(GetFeEditLogPort(cr)),
InitialDelaySeconds: 3,
Expand Down
6 changes: 6 additions & 0 deletions internal/util/kubeutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ func NewHttpGetProbeHandler(path string, httpPort int32) corev1.ProbeHandler {
}
}

func NewExecLifecycleHandler(command ...string) *corev1.LifecycleHandler {
return &corev1.LifecycleHandler{
Exec: &corev1.ExecAction{Command: command},
}
}

func NewResourceAvgUtilizationMetricSpec(name corev1.ResourceName, avgUnit *int32) acv2.MetricSpec {
return acv2.MetricSpec{
Type: acv2.ResourceMetricSourceType,
Expand Down

0 comments on commit 33603ae

Please sign in to comment.