Skip to content

Commit

Permalink
label
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed May 27, 2024
1 parent 143532c commit 497779b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/meta/meta_backup_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1474,8 +1474,8 @@ bool backup_service::is_valid_policy_name_unlocked(const std::string &policy_nam
}

// Because the policy name is used as a metric name in prometheus, it must match the regex.
if (!prometheus::CheckMetricName(policy_name)) {
hint_message = "policy name should match regex '[a-zA-Z_:][a-zA-Z0-9_:]*'";
if (!prometheus::CheckLabelName(policy_name)) {
hint_message = "policy name should match regex '[a-zA-Z_][a-zA-Z0-9_]*'";
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/meta/test/meta_backup_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ TEST_F(backup_service_test, test_valid_policy_name)
ASSERT_EQ("policy name is reserved", hint_message);

ASSERT_FALSE(_backup_service->is_valid_policy_name_unlocked("bad-policy-name", hint_message));
ASSERT_EQ("policy name should match regex '[a-zA-Z_:][a-zA-Z0-9_:]*'", hint_message);
ASSERT_EQ("policy name should match regex '[a-zA-Z_][a-zA-Z0-9_]*'", hint_message);

_backup_service->_policy_states.insert(std::make_pair("exist_policy_name", nullptr));
ASSERT_FALSE(_backup_service->is_valid_policy_name_unlocked("exist_policy_name", hint_message));
Expand Down

0 comments on commit 497779b

Please sign in to comment.