Skip to content

Commit

Permalink
remove unnecessary pod and statefulset update (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
tennix authored Sep 20, 2018
1 parent b1731d7 commit 669b023
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/controller/pod_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ func (rpc *realPodControl) UpdateMetaInfo(tc *v1alpha1.TidbCluster, pod *corev1.
podName := pod.GetName()
labels := pod.GetLabels()
tcName := tc.GetName()
var clusterID, storeID, memberID string
if labels == nil {
return pod, fmt.Errorf("pod %s/%s has empty labels, TidbCluster: %s", ns, podName, tcName)
}
_, ok := labels[label.InstanceLabelKey]
if !ok {
return pod, fmt.Errorf("pod %s/%s doesn't have %s label, TidbCluster: %s", ns, podName, label.InstanceLabelKey, tcName)
}
clusterID := labels[label.ClusterIDLabelKey]
memberID := labels[label.MemberIDLabelKey]
storeID := labels[label.StoreIDLabelKey]
pdClient := rpc.pdControl.GetPDClient(tc)
if labels[label.ClusterIDLabelKey] == "" {
cluster, err := pdClient.GetCluster()
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/member/tidb_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (tmm *tidbMemberManager) syncTiDBStatefulSetForTidbCluster(tc *v1alpha1.Tid
}
}

if !statefulSetEqual(*oldTiDBSet, *newTiDBSet) {
if !statefulSetEqual(*newTiDBSet, *oldTiDBSet) {
set := *oldTiDBSet
set.Spec.Template = newTiDBSet.Spec.Template
*set.Spec.Replicas = *newTiDBSet.Spec.Replicas
Expand Down
3 changes: 2 additions & 1 deletion pkg/manager/member/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func statefulSetEqual(new apps.StatefulSet, old apps.StatefulSet) bool {
glog.Errorf("unmarshal Statefulset: [%s/%s]'s applied config failed,error: %v", old.GetNamespace(), old.GetName(), err)
return false
}
return apiequality.Semantic.DeepEqual(oldConfig, new.Spec)
return apiequality.Semantic.DeepEqual(oldConfig.Replicas, new.Spec.Replicas) &&
apiequality.Semantic.DeepEqual(oldConfig.Template, new.Spec.Template)
}
return false
}
Expand Down

0 comments on commit 669b023

Please sign in to comment.