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

pass around projected SA configs properly #976

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/config/config_parse_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,13 @@ def make_master_jobs():
items=(schema.ConfigSecretVolumeItem(key="secret1", path="abcd", mode="777"),),
),
),
projected_sa_volumes=(
schema.ConfigProjectedSAVolume(
container_path="/var/secrets/whatever",
audience="foo.bar",
expiration_seconds=1800,
),
),
node_selectors={"yelp.com/pool": "default"},
node_affinities=(
ConfigNodeAffinity(
Expand Down Expand Up @@ -451,6 +458,13 @@ class ConfigTestCase(TestCase):
],
),
],
projected_sa_volumes=[
dict(
container_path="/var/secrets/whatever",
audience="foo.bar",
expiration_seconds=1800,
),
],
cap_add=["KILL"],
cap_drop=["CHOWN", "KILL"],
node_selectors={"yelp.com/pool": "default"},
Expand Down
21 changes: 21 additions & 0 deletions tron/config/config_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from tron.config.schema import ConfigMesos
from tron.config.schema import ConfigNodeAffinity
from tron.config.schema import ConfigParameter
from tron.config.schema import ConfigProjectedSAVolume
from tron.config.schema import ConfigSecretSource
from tron.config.schema import ConfigSecretVolume
from tron.config.schema import ConfigSecretVolumeItem
Expand Down Expand Up @@ -345,6 +346,22 @@ def post_validation(self, valid_input, config_context):
valid_secret_volume = ValidateSecretVolume()


class ValidateProjectedSAVolume(Validator):
config_class = ConfigProjectedSAVolume
optional = True
defaults = {
"expiration_seconds": 1800,
}
validators = {
"container_path": valid_string,
"audience": valid_string,
"expiration_seconds": valid_int,
}


valid_projected_sa_volume = ValidateProjectedSAVolume()


class ValidateFieldSelectorSource(Validator):
config_class = ConfigFieldSelectorSource
validators = {
Expand Down Expand Up @@ -536,6 +553,7 @@ class ValidateAction(Validator):
"env": None,
"secret_env": None,
"secret_volumes": None,
"projected_sa_volumes": None,
"field_selector_env": None,
"extra_volumes": None,
"trigger_downstreams": None,
Expand Down Expand Up @@ -576,6 +594,7 @@ class ValidateAction(Validator):
"env": valid_dict,
"secret_env": build_dict_value_validator(valid_secret_source),
"secret_volumes": build_list_of_type_validator(valid_secret_volume, allow_empty=True),
"projected_sa_volumes": build_list_of_type_validator(valid_projected_sa_volume, allow_empty=True),
"field_selector_env": build_dict_value_validator(valid_field_selector_source),
"extra_volumes": build_list_of_type_validator(valid_volume, allow_empty=True),
"trigger_downstreams": valid_trigger_downstreams,
Expand Down Expand Up @@ -625,6 +644,7 @@ class ValidateCleanupAction(Validator):
"env": None,
"secret_env": None,
"secret_volumes": None,
"projected_sa_volumes": None,
"field_selector_env": None,
"extra_volumes": None,
"trigger_downstreams": None,
Expand Down Expand Up @@ -660,6 +680,7 @@ class ValidateCleanupAction(Validator):
"env": valid_dict,
"secret_env": build_dict_value_validator(valid_secret_source),
"secret_volumes": build_list_of_type_validator(valid_secret_volume, allow_empty=True),
"projected_sa_volumes": build_list_of_type_validator(valid_projected_sa_volume, allow_empty=True),
"field_selector_env": build_dict_value_validator(valid_field_selector_source),
"extra_volumes": build_list_of_type_validator(valid_volume, allow_empty=True),
"trigger_downstreams": valid_trigger_downstreams,
Expand Down
1 change: 1 addition & 0 deletions tron/core/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def from_config(cls, config: ConfigAction) -> "Action":
env=config.env or {},
secret_env=config.secret_env or {},
secret_volumes=config.secret_volumes or [],
projected_sa_volumes=config.projected_sa_volumes or [],
field_selector_env=config.field_selector_env or {},
cap_add=config.cap_add or [],
cap_drop=config.cap_drop or [],
Expand Down
Loading