Skip to content

Commit

Permalink
Adding yelpy label for tron pods
Browse files Browse the repository at this point in the history
  • Loading branch information
wilmer05 committed Feb 15, 2024
1 parent dc34e82 commit 725c58d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
34 changes: 17 additions & 17 deletions tests/bin/action_runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,38 +152,38 @@ class TestBuildLabels:
def test_build_labels(self):
labels = action_runner.build_labels("MASTER.foo.10.bar")

assert labels == dict(
TRON_RUN_NUM="10",
)
assert labels == {
"tron.yelp.com/run_num": "10",
}

def test_build_labels_with_merging(self):
current_labels = {"LABEL1": "value_1"}
labels = action_runner.build_labels("MASTER.foo.10.bar", current_labels)

assert labels == dict(
TRON_RUN_NUM="10",
LABEL1="value_1",
)
assert labels == {
"tron.yelp.com/run_num": "10",
"LABEL1": "value_1",
}

def test_build_labels_with_merging_on_unknown(self):
current_labels = {"LABEL1": "value_1"}
labels = action_runner.build_labels("asdf", current_labels)

assert labels == dict(
TRON_RUN_NUM="UNKNOWN",
LABEL1="value_1",
)
assert labels == {
"tron.yelp.com/run_num": "UNKNOWN",
"LABEL1": "value_1",
}

def test_build_labels_invalid_run_id(self):
labels = action_runner.build_labels("asdf")

assert labels == dict(
TRON_RUN_NUM="UNKNOWN",
)
assert labels == {
"tron.yelp.com/run_num": "UNKNOWN",
}

def test_build_labels_too_long_run_id(self):
labels = action_runner.build_labels("MASTER.foo.10.bar.baz")

assert labels == dict(
TRON_RUN_NUM="10",
)
assert labels == {
"tron.yelp.com/run_num": "10",
}
2 changes: 1 addition & 1 deletion tests/core/actionrun_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ def mock_k8s_action_run(self):
"TRON_ACTION": "mock_action_name",
},
labels={
"TRON_RUN_NUM": "42",
"tron.yelp.com/run_num": "42",
},
)

Expand Down
2 changes: 1 addition & 1 deletion tron/bin/action_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def build_labels(run_id: str, original_labels: Optional[Dict[str, str]] = None)
run_num = "UNKNOWN"

new_labels = dict(original_labels)
new_labels["TRON_RUN_NUM"] = run_num
new_labels["tron.yelp.com/run_num"] = run_num

return new_labels

Expand Down

0 comments on commit 725c58d

Please sign in to comment.