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

Don't check labels when user enable placement-rule #1378

Merged
merged 2 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions pkg/cluster/api/pdapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,18 +692,18 @@ func (pc *PDClient) GetReplicateConfig() ([]byte, error) {
}

// GetLocationLabels gets the replication.location-labels config from pd server
func (pc *PDClient) GetLocationLabels() ([]string, error) {
func (pc *PDClient) GetLocationLabels() ([]string, bool, error) {
config, err := pc.GetReplicateConfig()
if err != nil {
return nil, err
return nil, false, err
}

rc := PDReplicationConfig{}
if err := json.Unmarshal(config, &rc); err != nil {
return nil, perrs.Annotatef(err, "unmarshal replication config: %s", string(config))
return nil, false, perrs.Annotatef(err, "unmarshal replication config: %s", string(config))
}

return rc.LocationLabels, nil
return rc.LocationLabels, rc.EnablePlacementRules, nil
}

// GetTiKVLabels implements TiKVLabelProvider
Expand Down
9 changes: 6 additions & 3 deletions pkg/cluster/manager/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,13 @@ func (m *Manager) Display(name string, opt operator.Options) error {
if t, ok := topo.(*spec.Specification); ok {
// Check if TiKV's label set correctly
pdClient := api.NewPDClient(masterActive, 10*time.Second, tlsCfg)
if lbs, err := pdClient.GetLocationLabels(); err != nil {

if lbs, placementRule, err := pdClient.GetLocationLabels(); err != nil {
log.Debugf("get location labels from pd failed: %v", err)
} else if err := spec.CheckTiKVLabels(lbs, pdClient); err != nil {
color.Yellow("\nWARN: there is something wrong with TiKV labels, which may cause data losing:\n%v", err)
} else if !placementRule {
if err := spec.CheckTiKVLabels(lbs, pdClient); err != nil {
color.Yellow("\nWARN: there is something wrong with TiKV labels, which may cause data losing:\n%v", err)
}
}

// Check if there is some instance in tombstone state
Expand Down
8 changes: 5 additions & 3 deletions pkg/cluster/manager/scale_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ func (m *Manager) ScaleOut(
return err
}
pdClient := api.NewPDClient(pdList, 10*time.Second, tlsCfg)
lbs, err := pdClient.GetLocationLabels()
lbs, placementRule, err := pdClient.GetLocationLabels()
if err != nil {
return err
}
if err := spec.CheckTiKVLabels(lbs, mergedTopo.(*spec.Specification)); err != nil {
return perrs.Errorf("check TiKV label failed, please fix that before continue:\n%s", err)
if !placementRule {
if err := spec.CheckTiKVLabels(lbs, mergedTopo.(*spec.Specification)); err != nil {
return perrs.Errorf("check TiKV label failed, please fix that before continue:\n%s", err)
}
}
}

Expand Down