Skip to content

Commit

Permalink
add store labels (#3784)
Browse files Browse the repository at this point in the history
* add store labels

* Update pkg/apis/pingcap/v1alpha1/types.go

Co-authored-by: Lonng <heng@lonng.org>

* Update pkg/manager/member/tikv_member_manager.go

Co-authored-by: Lonng <heng@lonng.org>

* Update pkg/apis/pingcap/v1alpha1/types.go

Co-authored-by: Lonng <heng@lonng.org>

* fix var

* fix

* generate code

Co-authored-by: Lonng <heng@lonng.org>
Co-authored-by: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 25, 2021
1 parent 64a6d40 commit a3b0e6c
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 @@ -18057,6 +18057,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 @@ -12788,6 +12788,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 @@ -468,6 +468,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 @@ -816,8 +816,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 @@ -843,7 +843,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 a3b0e6c

Please sign in to comment.