Skip to content
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

pdms: remove shutdown component and add test for scaler&upgrader #5554

Merged
merged 5 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions pkg/manager/member/pd_ms_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,35 @@ func (m *pdMSMemberManager) Sync(tc *v1alpha1.TidbCluster) error {
}

// Need to start PD API
if tc.Spec.PD == nil || tc.Spec.PD.Mode != "ms" {
klog.Infof("PD Micro Service is enabled, but PD is not enabled or not in `ms` mode, skip syncing PD Micro Service")
if tc.Spec.PD == nil {
klog.Infof("PD Micro Service is enabled, but PD is not enabled, skip syncing PD Micro Service")
return nil
}
if tc.Spec.PD.Mode != "ms" {
// remove all micro service components
for _, comp := range tc.Spec.PDMS {
ns := tc.GetNamespace()
tcName := tc.GetName()
curService := comp.Name

oldPDMSSetTmp, err := m.deps.StatefulSetLister.StatefulSets(ns).Get(controller.PDMSMemberName(tcName, curService))
if err != nil && !errors.IsNotFound(err) {
return fmt.Errorf("syncPDMSStatefulSet: fail to get sts %s PDMS component %s for cluster [%s/%s], error: %s",
controller.PDMSMemberName(tcName, curService), curService, ns, tcName, err)
}

oldPDMSSet := oldPDMSSetTmp.DeepCopy()
newPDMSSet := oldPDMSSetTmp.DeepCopy()
*newPDMSSet.Spec.Replicas = 0
if err := m.scaler.Scale(tc, oldPDMSSet, newPDMSSet); err != nil {
return err
}
mngerutils.UpdateStatefulSetWithPrecheck(m.deps, tc, "FailedUpdatePDMSSTS", newPDMSSet, oldPDMSSet)
}
klog.Infof("PD Micro Service is enabled, but PD is not in `ms` mode, skip syncing PD Micro Service")
return nil
}

// init PD Micro Service status
if tc.Status.PDMS == nil {
tc.Status.PDMS = make(map[string]*v1alpha1.PDMSStatus)
Expand Down Expand Up @@ -698,14 +723,6 @@ func (m *pdMSMemberManager) getNewPDMSStatefulSet(tc *v1alpha1.TidbCluster, cm *
}
// default in nil
if curSpec.StorageVolumes != nil {
storageRequest, err := controller.ParseStorageRequest(curSpec.Requests)
if err != nil {
return nil, fmt.Errorf("cannot parse storage request for PD, tidbcluster %s/%s, error: %v", tc.Namespace, tc.Name, err)
}
dataVolumeName := string(v1alpha1.GetStorageVolumeName("", v1alpha1.PDMSMemberType(curService)))
pdMSSet.Spec.VolumeClaimTemplates = []corev1.PersistentVolumeClaim{
util.VolumeClaimTemplate(storageRequest, dataVolumeName, tc.Spec.PD.StorageClassName),
}
pdMSSet.Spec.VolumeClaimTemplates = append(pdMSSet.Spec.VolumeClaimTemplates, additionalPVCs...)
}

Expand Down
Loading
Loading