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

server: support command line output config info #12956

Merged
merged 13 commits into from Jul 15, 2022

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Jul 5, 2022

Signed-off-by: glorv glorvs@163.com

What is changed and how it works?

Issue Number: ref #12492

What's Changed:

Add a new command line parameter `--config-info json` to output all config infos. Currently, the command only support Name, DefaultValue and ValueInFile 3 fields.

This is a simplified implementation of #12517 that only support output "Name, DefaultValue and ValueInFile", so we can avoid using the complex proc-macro.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM
  • Breaking backward compatibility

Release note

Add a new command line parameter `--config-info` to output some information of all configs.

Signed-off-by: glorv <glorvs@163.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 5, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • BusyJay
  • tabokie

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@glorv glorv requested review from tabokie and BusyJay July 6, 2022 02:50
@glorv
Copy link
Contributor Author

glorv commented Jul 6, 2022

@BusyJay @tabokie PTAL, thank you

) {
for (k, v) in default_obj.iter() {
let cfg_val = value_obj.get(k);
append_sub_key(key_buf, k);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tiny functions don't make it easy to review. How about

Suggested change
append_sub_key(key_buf, k);
let old_len = key_buf.len();
if !k.is_empty() {
key.push_str(k);
key.push('.');
}

} else {
res.push(to_cfg_value(v, cfg_val, key_buf));
}
pop_sub_key(key_buf, k);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pop_sub_key(key_buf, k);
key_buf.truncate(old_len);

@@ -1851,3 +1854,118 @@ impl IOBudgetAdjustor for EnginesResourceInfo {
(total_budgets as f32 * score) as usize
}
}

// currently, only support return json result
pub fn get_flatten_cfg_info(cfg: &TiKvConfig) -> Vec<Value> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put it near TiKvConfig?

glorv added 2 commits July 6, 2022 20:22
Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: glorv <glorvs@163.com>
@glorv
Copy link
Contributor Author

glorv commented Jul 12, 2022

@tabokie @BusyJay PTAL again, thanks~

@ti-chi-bot ti-chi-bot added the status/LGT1 Status: PR - There is already 1 approval label Jul 12, 2022
Copy link
Member

@tabokie tabokie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you paste a sample output? I'm not sure if deprecated items are printed.

@ti-chi-bot ti-chi-bot added status/LGT2 Status: PR - There are already 2 approvals and removed status/LGT1 Status: PR - There is already 1 approval labels Jul 12, 2022
@glorv
Copy link
Contributor Author

glorv commented Jul 12, 2022

Could you paste a sample output? I'm not sure if deprecated items are printed.

emm.. The currently implement outputs all serializable config fields. The configs included are the same as all the configs in the last_tikv.toml. So deprecated items are also included. Do you have any good ideas to excludes them? @tabokie

The current output is like:

[gl@ip-172-16-5-33 tikv]$ ./target/debug/tikv-server --config tests/integrations/config/test-custom.toml --config-info json
{
  "Component": "TiKV Server",
  "Version": "6.2.0-alpha",
  "Parameters": [
    {
      "Name": "log-level",
      "DefaultValue": "info"
    },
    {
      "Name": "log-file",
      "DefaultValue": ""
    },
    {
      "Name": "log-format",
      "DefaultValue": "text"
    },
    {
      "Name": "log-rotation-timespan",
      "DefaultValue": "0s",
      "ValueInFile": "1d"
    },
    {
      "Name": "log-rotation-size",
      "DefaultValue": "300MiB"
    },
    {
      "Name": "slow-log-file",
      "DefaultValue": "",
      "ValueInFile": "slow_foo"
    },
    {
      "Name": "slow-log-threshold",
      "DefaultValue": "1s"
    },
    {
      "Name": "panic-when-unexpected-key-or-data",
      "DefaultValue": false,
      "ValueInFile": true
    },
    {
      "Name": "abort-on-panic",
      "DefaultValue": false,
      "ValueInFile": true
    },
   ...
  ]
}

@tabokie
Copy link
Member

tabokie commented Jul 12, 2022

@glorv deprecated items are all marked with #[online_config(skip)] and #[serde(skip_serializing)]. So I guess they won't appear in the list of ConfigValue?

You can verify it by checking a deprecated config e.g. xxcf.titan.gc-merge-rewrite.

If #[online_config(skip)] doesn't work, maybe try #[online_config(hidden)].

@glorv
Copy link
Contributor Author

glorv commented Jul 12, 2022

@glorv deprecated items are all marked with #[online_config(skip)] and #[serde(skip_serializing)]. So I guess they won't appear in the list of ConfigValue?

You can verify it by checking a deprecated config e.g. xxcf.titan.gc-merge-rewrite.

If #[online_config(skip)] doesn't work, maybe try #[online_config(hidden)].

I have checked all the configs, there are only 8 commented with // deprecated. And there are 19 fields that are marked with #[serde(skip_serializing)]. These fields won't be included in the output.

@glorv
Copy link
Contributor Author

glorv commented Jul 15, 2022

@tabokie can we merge this pr now?

@tabokie
Copy link
Member

tabokie commented Jul 15, 2022

Sure, I already approved it.

@tabokie
Copy link
Member

tabokie commented Jul 15, 2022

/merge

@ti-chi-bot
Copy link
Member

@tabokie: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 8033514

@ti-chi-bot ti-chi-bot added the status/can-merge Status: Can merge to base branch label Jul 15, 2022
@ti-chi-bot ti-chi-bot merged commit 956c219 into tikv:master Jul 15, 2022
@ti-chi-bot ti-chi-bot added this to the Pool milestone Jul 15, 2022
@glorv glorv deleted the json-config-info branch July 15, 2022 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note size/L status/can-merge Status: Can merge to base branch status/LGT2 Status: PR - There are already 2 approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants