Skip to content

Commit

Permalink
add store labels (#3784) (#3813)
Browse files Browse the repository at this point in the history
* cherry pick #3784 to release-1.1

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* resolve conflict

Co-authored-by: zyy <zhangyunyu@zhihu.com>
Co-authored-by: DanielZhangQD <zhanghailong810@aliyun.com>
Co-authored-by: Ti Chi Robot <71242396+ti-chi-bot@users.noreply.github.com>
  • Loading branch information
4 people authored Feb 25, 2021
1 parent c9ce7c0 commit 6ebf6de
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
12 changes: 12 additions & 0 deletions docs/api-references/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16395,6 +16395,18 @@ Defaults to 10m</p>
<p>StorageVolumes configure additional storage for TiKV pods.</p>
</td>
</tr>
<tr>
<td>
<code>storeLabels</code></br>
<em>
[]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>StoreLabels configures additional labels for TiKV stores.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tikvstatus">TiKVStatus</h3>
Expand Down
4 changes: 4 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12784,6 +12784,10 @@ spec:
storageVolumes:
items: {}
type: array
storeLabels:
items:
type: string
type: array
terminationGracePeriodSeconds:
format: int64
type: integer
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/pingcap/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/apis/pingcap/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ type TiKVSpec struct {
// StorageVolumes configure additional storage for TiKV pods.
// +optional
StorageVolumes []StorageVolume `json:"storageVolumes,omitempty"`

// StoreLabels configures additional labels for TiKV stores.
// +optional
StoreLabels []string `json:"storeLabels,omitempty"`
}

// TiFlashSpec contains details of TiFlash members
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/manager/member/tikv_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,8 @@ func (m *tikvMemberManager) setStoreLabelsForTiKV(tc *v1alpha1.TidbCluster) (int
return setCount, err
}

locationLabels := []string(config.Replication.LocationLabels)
if locationLabels == nil {
storeLabels := append(config.Replication.LocationLabels, tc.Spec.TiKV.StoreLabels...)
if storeLabels == nil {
return setCount, nil
}

Expand All @@ -834,7 +834,7 @@ func (m *tikvMemberManager) setStoreLabelsForTiKV(tc *v1alpha1.TidbCluster) (int
}

nodeName := pod.Spec.NodeName
ls, err := m.getNodeLabels(nodeName, locationLabels)
ls, err := m.getNodeLabels(nodeName, storeLabels)
if err != nil || len(ls) == 0 {
klog.Warningf("node: [%s] has no node labels, skipping set store labels for Pod: [%s/%s]", nodeName, ns, podName)
continue
Expand Down

0 comments on commit 6ebf6de

Please sign in to comment.