Skip to content

Commit

Permalink
revert kubernetes annotation validation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
saikonen committed Dec 12, 2024
1 parent 253301c commit 30adda1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion metaflow/plugins/kubernetes/kube_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def qos_requests_and_limits(qos: str, cpu: int, memory: int, storage: int):
return qos_requests, qos_limits


def validate_kube_labels_or_annotations(
def validate_kube_labels(
labels: Optional[Dict[str, Optional[str]]],
) -> bool:
"""Validate label values.
Expand Down
7 changes: 4 additions & 3 deletions metaflow/plugins/kubernetes/kubernetes_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

from ..aws.aws_utils import get_docker_registry, get_ec2_instance_metadata
from .kubernetes import KubernetesException
from .kube_utils import validate_kube_labels_or_annotations, parse_kube_keyvalue_list
from .kube_utils import validate_kube_labels, parse_kube_keyvalue_list

try:
unicode
Expand Down Expand Up @@ -409,8 +409,9 @@ def step_init(self, flow, graph, step, decos, environment, flow_datastore, logge
size=self.attributes["shared_memory"], step=step
)
)
validate_kube_labels_or_annotations(self.attributes["labels"])
validate_kube_labels_or_annotations(self.attributes["annotations"])

validate_kube_labels(self.attributes["labels"])
# TODO: add validation to annotations as well?

def package_init(self, flow, step_name, environment):
try:
Expand Down
10 changes: 5 additions & 5 deletions test/unit/test_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from metaflow.plugins.kubernetes.kubernetes import KubernetesException

from metaflow.plugins.kubernetes.kube_utils import (
validate_kube_labels_or_annotations,
validate_kube_labels,
parse_kube_keyvalue_list,
)

Expand Down Expand Up @@ -41,8 +41,8 @@
},
],
)
def test_kubernetes_decorator_validate_kube_labels_or_annotations(labels):
assert validate_kube_labels_or_annotations(labels)
def test_kubernetes_decorator_validate_kube_labels(labels):
assert validate_kube_labels(labels)


@pytest.mark.parametrize(
Expand All @@ -66,10 +66,10 @@ def test_kubernetes_decorator_validate_kube_labels_or_annotations(labels):
{"valid": "test", "invalid": "bißchen"},
],
)
def test_kubernetes_decorator_validate_kube_labels_or_annotations_fail(labels):
def test_kubernetes_decorator_validate_kube_labels_fail(labels):
"""Fail if label contains invalid characters or is too long"""
with pytest.raises(KubernetesException):
validate_kube_labels_or_annotations(labels)
validate_kube_labels(labels)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 30adda1

Please sign in to comment.