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

Fix TidbMonitor Service Label #2051

Merged
merged 15 commits into from
Mar 30, 2020
4 changes: 3 additions & 1 deletion pkg/controller/pv_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ func (rpc *realPVControl) UpdateMetaInfo(obj runtime.Object, pv *corev1.Persiste
pv.Labels[label.NamespaceLabelKey] = ns
pv.Labels[label.ComponentLabelKey] = component
pv.Labels[label.NameLabelKey] = pvc.Labels[label.NameLabelKey]
pv.Labels[label.ManagedByLabelKey] = pvc.Labels[label.ManagedByLabelKey]
// TidbMonitor's pod label don't have managedBy label in order to be compatible with 1.0 release monitor
// so we add manager-key label with `tidb-operator` values manually.
pv.Labels[label.ManagedByLabelKey] = "tidb-operator"
Yisaer marked this conversation as resolved.
Show resolved Hide resolved
pv.Labels[label.InstanceLabelKey] = pvc.Labels[label.InstanceLabelKey]

setIfNotEmpty(pv.Labels, label.ClusterIDLabelKey, clusterID)
Expand Down
34 changes: 22 additions & 12 deletions tests/e2e/tidbcluster/tidbcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,18 +753,28 @@ var _ = ginkgo.Describe("[tidb-operator] TiDBCluster", func() {
pvName := pvc.Spec.VolumeName
pv, err := c.CoreV1().PersistentVolumes().Get(pvName, metav1.GetOptions{})
framework.ExpectNoError(err, "Expected fetch tidbmonitor pv success")
value, existed := pv.Labels[label.ComponentLabelKey]
framework.ExpectEqual(existed, true)
framework.ExpectEqual(value, label.TiDBMonitorVal)
value, existed = pv.Labels[label.InstanceLabelKey]
framework.ExpectEqual(existed, true)
framework.ExpectEqual(value, "e2e-monitor")
value, existed = pv.Labels[label.InstanceLabelKey]
framework.ExpectEqual(existed, true)
framework.ExpectEqual(value, "e2e-monitor")
value, existed = pv.Labels[label.ManagedByLabelKey]
framework.ExpectEqual(existed, true)
framework.ExpectEqual(value, label.TiDBOperator)

err = wait.Poll(5*time.Second, 5*time.Minute, func() (done bool, err error) {
value, existed := pv.Labels[label.ComponentLabelKey]
if !existed || value != label.TiDBMonitorVal {
return false, nil
}
value, existed = pv.Labels[label.InstanceLabelKey]
if !existed || value != "e2e-monitor" {
return false, nil
}

value, existed = pv.Labels[label.NameLabelKey]
if !existed || value != "tidb-clustr" {
return false, nil
}
value, existed = pv.Labels[label.ManagedByLabelKey]
if !existed || value != label.TiDBOperator {
return false, nil
}
return true, nil
})
framework.ExpectNoError(err, "monitor pv label error")

// update TidbMonitor and check whether portName is updated and the nodePort is unchanged
tm, err = cli.PingcapV1alpha1().TidbMonitors(ns).Get(tm.Name, metav1.GetOptions{})
Expand Down