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

Add tikv store limit pattern (#1965) #2022

Merged
merged 4 commits into from
Mar 24, 2020
Merged
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
14 changes: 13 additions & 1 deletion pkg/manager/member/tikv_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import (
const (
// tikvClusterCertPath is where the cert for inter-cluster communication stored (if any)
tikvClusterCertPath = "/var/lib/tikv-tls"

//find a better way to manage store only managed by tikv in Operator
tikvStoreLimitPattern = `%s-tikv-\d+\.%s-tikv-peer\.%s\.svc\:\d+`
)

// tikvMemberManager implements manager.Manager.
Expand Down Expand Up @@ -574,7 +577,7 @@ func (tkmm *tikvMemberManager) syncTidbClusterStatus(tc *v1alpha1.TidbCluster, s
return err
}

pattern, err := regexp.Compile(fmt.Sprintf(`%s-tikv-\d+\.%s-tikv-peer\.%s\.svc\:\d+`, tc.Name, tc.Name, tc.Namespace))
pattern, err := regexp.Compile(fmt.Sprintf(tikvStoreLimitPattern, tc.Name, tc.Name, tc.Namespace))
if err != nil {
return err
}
Expand Down Expand Up @@ -665,7 +668,16 @@ func (tkmm *tikvMemberManager) setStoreLabelsForTiKV(tc *v1alpha1.TidbCluster) (
return setCount, nil
}

pattern, err := regexp.Compile(fmt.Sprintf(tikvStoreLimitPattern, tc.Name, tc.Name, tc.Namespace))
if err != nil {
return -1, err
}
for _, store := range storesInfo.Stores {
// In theory, the external tikv can join the cluster, and the operator would only manage the internal tikv.
// So we check the store owner to make sure it.
if store.Store != nil && !pattern.Match([]byte(store.Store.Address)) {
continue
}
status := tkmm.getTiKVStore(store)
if status == nil {
continue
Expand Down