Skip to content

Commit cc86d90

Browse files
author
smiletan
authored
Merge pull request #415 from intelligentfu8/mount-annotation
[bugfix][ddc]ddc support container mount pod information
2 parents f5a55f0 + 4b42d3b commit cc86d90

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

pkg/common/utils/resource/pod.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const (
8787

8888
DISAGGREGATED_FE_MAIN_CONTAINER_NAME = "fe"
8989
DISAGGREGATED_BE_MAIN_CONTAINER_NAME = "compute"
90+
DISAGGREGATED_MS_MAIN_CONTAINER_NAME= "metaservice"
9091
)
9192

9293
type ProbeType string
@@ -738,6 +739,11 @@ func getFeDefaultVolumesVolumeMounts() ([]corev1.Volume, []corev1.VolumeMount) {
738739
return volumes, volumMounts
739740
}
740741

742+
//
743+
func GetPodInfoVolumesVolumeMounts() ([]corev1.Volume, []corev1.VolumeMount){
744+
return appendPodInfoVolumesVolumeMounts(nil, nil)
745+
}
746+
741747
func appendPodInfoVolumesVolumeMounts(volumes []corev1.Volume, volumeMounts []corev1.VolumeMount) ([]corev1.Volume, []corev1.VolumeMount) {
742748
if volumes == nil {
743749
var _ []corev1.Volume

pkg/controller/sub_controller/disaggregated_cluster/computegroups/controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ func (dcgs *DisaggregatedComputeGroupsController) computeGroupSync(ctx context.C
166166
func (dcgs *DisaggregatedComputeGroupsController) reconcileStatefulset(ctx context.Context, st *appv1.StatefulSet, cluster *dv1.DorisDisaggregatedCluster, cg *dv1.ComputeGroup) (*sc.Event, error) {
167167
var est appv1.StatefulSet
168168
if err := dcgs.K8sclient.Get(ctx, types.NamespacedName{Namespace: st.Namespace, Name: st.Name}, &est); apierrors.IsNotFound(err) {
169+
//TODO: add downlaodAPI volume Mounts
170+
dcgs.DisaggregatedSubDefaultController.AddDownwardAPI(st)
169171
if err = k8s.CreateClientObject(ctx, dcgs.K8sclient, st); err != nil {
170172
klog.Errorf("disaggregatedComputeGroupsController reconcileStatefulset create statefulset namespace=%s name=%s failed, err=%s", st.Namespace, st.Name, err.Error())
171173
return &sc.Event{Type: sc.EventWarning, Reason: sc.CGCreateResourceFailed, Message: err.Error()}, err
@@ -206,6 +208,7 @@ func (dcgs *DisaggregatedComputeGroupsController) reconcileStatefulset(ctx conte
206208
ddc_annos := (resource.Annotations)(cluster.Annotations)
207209
msUniqueIdKey := strings.ToLower(fmt.Sprintf(dv1.UpdateStatefulsetName, cluster.GetCGStatefulsetName(cg)))
208210
ddc_annos.Add(msUniqueIdKey, "true")
211+
dcgs.DisaggregatedSubDefaultController.AddDownwardAPI(st)
209212
}
210213
return equal
211214

pkg/controller/sub_controller/disaggregated_cluster/metaservice/statefulset.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ func (dms *DisaggregatedMSController) NewMSContainer(ddc *v1.DorisDisaggregatedC
122122
cmd, args := sc.GetDisaggregatedCommand(v1.DisaggregatedMS)
123123
c.Command = cmd
124124
c.Args = args
125-
c.Name = "metaservice"
125+
//c.Name = "metaservice"
126+
c.Name = resource.DISAGGREGATED_MS_MAIN_CONTAINER_NAME
126127

127128
c.Ports = resource.GetDisaggregatedContainerPorts(cvs, v1.DisaggregatedMS)
128129
c.Env = ddc.Spec.MetaService.CommonSpec.EnvVars

pkg/controller/sub_controller/disaggregated_subcontroller.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const (
5757
FileCachePathKey = "file_cache_path"
5858
FileCacheSubConfigPathKey = "path"
5959
FileCacheSubConfigTotalSizeKey = "total_size"
60-
6160
)
6261

6362
type DisaggregatedSubController interface {
@@ -605,6 +604,19 @@ func (d *DisaggregatedSubDefaultController) getEmptyDirVolumesVolumeMounts(confM
605604
}
606605
}
607606

607+
// this function is a compensation, because the DownwardAPI annotations and labels are not mount in pod, so this function amends。
608+
func(d *DisaggregatedSubDefaultController) AddDownwardAPI(st *appv1.StatefulSet) {
609+
t := &st.Spec.Template
610+
for index, _ := range t.Spec.Containers {
611+
if t.Spec.Containers[index].Name == resource.DISAGGREGATED_FE_MAIN_CONTAINER_NAME || t.Spec.Containers[index].Name == resource.DISAGGREGATED_BE_MAIN_CONTAINER_NAME ||
612+
t.Spec.Containers[index].Name == resource.DISAGGREGATED_MS_MAIN_CONTAINER_NAME {
613+
_, d_v_m := resource.GetPodInfoVolumesVolumeMounts()
614+
t.Spec.Containers[index].VolumeMounts = append(t.Spec.Containers[index].VolumeMounts, d_v_m...)
615+
break
616+
}
617+
}
618+
}
619+
608620
func (d *DisaggregatedSubDefaultController) getBEEmptyDirVolumesVolumeMounts(confMap map[string]interface{}) ([]corev1.Volume, []corev1.VolumeMount) {
609621
vs := []corev1.Volume{
610622
{

0 commit comments

Comments
 (0)