Skip to content

Commit caa7a0c

Browse files
Specify extra store labels by param --labels (#420) (release-8.1) (#422)
* Specify extra store labels by param `--labels` (#420) ref pingcap/tiflash#9750 * Remove param `--engine-role-label` * Specify extra store labels by param `--labels` * If there are duplicated key in `server.labels` and `--labels`, use the one in `server.labels` Signed-off-by: JaySon-Huang <[email protected]> Signed-off-by: Calvin Neo <[email protected]> --------- Signed-off-by: JaySon-Huang <[email protected]> Signed-off-by: Calvin Neo <[email protected]> Co-authored-by: Calvin Neo <[email protected]>
1 parent 3194987 commit caa7a0c

File tree

4 files changed

+234
-72
lines changed

4 files changed

+234
-72
lines changed

proxy_components/proxy_server/src/proxy.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -201,22 +201,6 @@ pub unsafe fn run_proxy(
201201
.help("Sets PD endpoints")
202202
.long_help("Set the PD endpoints to use. Use `,` to separate multiple PDs"),
203203
)
204-
.arg(
205-
Arg::with_name("labels")
206-
.long("labels")
207-
.alias("label")
208-
.takes_value(true)
209-
.value_name("KEY=VALUE")
210-
.multiple(true)
211-
.use_delimiter(true)
212-
.require_delimiter(true)
213-
.value_delimiter(",")
214-
.help("Sets server labels")
215-
.long_help(
216-
"Set the server labels. Uses `,` to separate kv pairs, like \
217-
`zone=cn,disk=ssd`",
218-
),
219-
)
220204
.arg(
221205
Arg::with_name("print-sample-config")
222206
.long("print-sample-config")
@@ -263,6 +247,22 @@ pub unsafe fn run_proxy(
263247
.required(false)
264248
.takes_value(true),
265249
)
250+
.arg(
251+
Arg::with_name("labels")
252+
.long("labels")
253+
.alias("label")
254+
.takes_value(true)
255+
.value_name("KEY=VALUE")
256+
.multiple(true)
257+
.use_delimiter(true)
258+
.require_delimiter(true)
259+
.value_delimiter(",")
260+
.help("Sets server labels")
261+
.long_help(
262+
"Set the server labels. Uses `,` to separate kv pairs, like \
263+
`zone=cn,disk=ssd`",
264+
),
265+
)
266266
.arg(
267267
Arg::with_name("engine-label")
268268
.long("engine-label")
@@ -275,12 +275,6 @@ pub unsafe fn run_proxy(
275275
.long("only-decryption")
276276
.help("Only do decryption in Proxy"),
277277
)
278-
.arg(
279-
Arg::with_name("engine-role-label")
280-
.long("engine-role-label")
281-
.help("Set engine role label")
282-
.takes_value(true),
283-
)
284278
.arg(
285279
Arg::with_name("memory-limit-size")
286280
.long("memory-limit-size")

proxy_components/proxy_server/src/setup.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
use std::borrow::ToOwned;
33

44
use clap::ArgMatches;
5-
use collections::HashMap;
65
pub use server::setup::initial_logger;
76
use tikv::config::{MetricConfig, TikvConfig, MEMORY_USAGE_LIMIT_RATE};
87
use tikv_util::{self, config::ReadableSize, logger, sys::SysQuota};
@@ -106,7 +105,7 @@ pub fn overwrite_config_with_cmd_args(
106105
}
107106

108107
if let Some(labels_vec) = matches.values_of("labels") {
109-
let mut labels = HashMap::default();
108+
// labels_vec is a vector of string like ["k1=v1", "k1=v2", ...]
110109
for label in labels_vec {
111110
let mut parts = label.split('=');
112111
let key = parts.next().unwrap().to_owned();
@@ -117,22 +116,18 @@ pub fn overwrite_config_with_cmd_args(
117116
if parts.next().is_some() {
118117
fatal!("invalid label: {}", label);
119118
}
120-
labels.insert(key, value);
119+
if config.server.labels.contains_key(&key) {
120+
warn!(
121+
"label is ignored due to duplicated key defined in `server.labels`, key={} value={}",
122+
key, value
123+
);
124+
continue; // ignore duplicated label
125+
}
126+
// only set the label when `server.labels` does not contain the label with the
127+
// same key
128+
config.server.labels.insert(key, value);
121129
}
122-
config.server.labels = labels;
123-
}
124-
125-
if let Some(capacity_str) = matches.value_of("capacity") {
126-
let capacity = capacity_str.parse().unwrap_or_else(|e| {
127-
fatal!("invalid capacity: {}", e);
128-
});
129-
config.raft_store.capacity = capacity;
130-
}
131-
132-
if matches.value_of("metrics-addr").is_some() {
133-
warn!("metrics push is not supported any more.");
134130
}
135-
136131
// User can specify engine label, because we need to distinguish TiFlash role
137132
// (tiflash-compute or tiflash-storage) in the disaggregated architecture.
138133
// If no engine label is specified, we use 'ENGINE_LABEL_VALUE'(env variable
@@ -147,13 +142,18 @@ pub fn overwrite_config_with_cmd_args(
147142
.unwrap(),
148143
),
149144
);
150-
const DEFAULT_ENGINE_ROLE_LABEL_KEY: &str = "engine_role";
151-
if let Some(engine_role_value) = matches.value_of("engine-role-label") {
152-
config.server.labels.insert(
153-
DEFAULT_ENGINE_ROLE_LABEL_KEY.to_owned(),
154-
String::from(engine_role_value),
155-
);
145+
146+
if let Some(capacity_str) = matches.value_of("capacity") {
147+
let capacity = capacity_str.parse().unwrap_or_else(|e| {
148+
fatal!("invalid capacity: {}", e);
149+
});
150+
config.raft_store.capacity = capacity;
151+
}
152+
153+
if matches.value_of("metrics-addr").is_some() {
154+
warn!("metrics push is not supported any more.");
156155
}
156+
157157
if let Some(unips_enabled_str) = matches.value_of("unips-enabled") {
158158
let enabled: u64 = unips_enabled_str.parse().unwrap_or_else(|e| {
159159
fatal!("invalid unips-enabled: {}", e);

proxy_scripts/ci_check.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ echo "PATH=", $PATH
66

77
if [[ $M == "fmt" ]]; then
88
pwd
9+
clang --version
10+
rustup toolchain list
11+
rustup show
912
git rev-parse --show-toplevel
13+
cargo --version -v
1014
make gen_proxy_ffi
15+
git diff
1116
git status -s .
1217
GIT_STATUS=$(git status -s .) && if [[ ${GIT_STATUS} ]]; then echo "Error: found illegal git status"; echo ${GIT_STATUS}; [[ -z ${GIT_STATUS} ]]; fi
1318
cargo fmt -- --check

0 commit comments

Comments
 (0)