Skip to content

Commit

Permalink
Add tikv store limit pattern (#1965) (#2022)
Browse files Browse the repository at this point in the history
* add limit pattern

* Update tikv_member_manager.go

* fix lint

* Update tikv_member_manager.go

Co-authored-by: Song Gao <2695690803@qq.com>
  • Loading branch information
sre-bot and Song Gao authored Mar 24, 2020
1 parent 23a1bba commit 190e7fb
Showing 1 changed file with 13 additions and 1 deletion.
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

0 comments on commit 190e7fb

Please sign in to comment.