From 91c0fffb0460b23f45f5fa8a563c3a055e4b122d Mon Sep 17 00:00:00 2001 From: Justin Edwins Date: Fri, 7 Jun 2024 15:24:04 -0700 Subject: [PATCH] Add omitempty to annotation of OnJobFailureReasons. (#596) * Add omitempty to annotation of OnJobFailureReasons. * Regenerate manifests. --- api/jobset/v1alpha2/jobset_types.go | 2 +- api/jobset/v1alpha2/openapi_generated.go | 2 +- config/components/crd/bases/jobset.x-k8s.io_jobsets.yaml | 1 - hack/python-sdk/swagger.json | 3 +-- sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md | 2 +- .../jobset/models/jobset_v1alpha2_failure_policy_rule.py | 5 ++--- sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py | 3 --- 7 files changed, 6 insertions(+), 12 deletions(-) diff --git a/api/jobset/v1alpha2/jobset_types.go b/api/jobset/v1alpha2/jobset_types.go index 3ba52f7ff..42bf17cf8 100644 --- a/api/jobset/v1alpha2/jobset_types.go +++ b/api/jobset/v1alpha2/jobset_types.go @@ -265,7 +265,7 @@ type FailurePolicyRule struct { // rule is executed. // An empty list applies the rule to any job failure reason. // +kubebuilder:validation:UniqueItems:true - OnJobFailureReasons []string `json:"onJobFailureReasons"` + OnJobFailureReasons []string `json:"onJobFailureReasons,omitempty"` // TargetReplicatedJobs are the names of the replicated jobs the operator applies to. // An empty list will apply to all replicatedJobs. // +optional diff --git a/api/jobset/v1alpha2/openapi_generated.go b/api/jobset/v1alpha2/openapi_generated.go index 55cc4b6b9..dca32ff10 100644 --- a/api/jobset/v1alpha2/openapi_generated.go +++ b/api/jobset/v1alpha2/openapi_generated.go @@ -132,7 +132,7 @@ func schema_jobset_api_jobset_v1alpha2_FailurePolicyRule(ref common.ReferenceCal }, }, }, - Required: []string{"name", "action", "onJobFailureReasons"}, + Required: []string{"name", "action"}, }, }, } diff --git a/config/components/crd/bases/jobset.x-k8s.io_jobsets.yaml b/config/components/crd/bases/jobset.x-k8s.io_jobsets.yaml index ebd17bc1e..bf4c485a8 100644 --- a/config/components/crd/bases/jobset.x-k8s.io_jobsets.yaml +++ b/config/components/crd/bases/jobset.x-k8s.io_jobsets.yaml @@ -113,7 +113,6 @@ spec: required: - action - name - - onJobFailureReasons type: object type: array type: object diff --git a/hack/python-sdk/swagger.json b/hack/python-sdk/swagger.json index 8df6b3670..b0959fe76 100644 --- a/hack/python-sdk/swagger.json +++ b/hack/python-sdk/swagger.json @@ -30,8 +30,7 @@ "type": "object", "required": [ "name", - "action", - "onJobFailureReasons" + "action" ], "properties": { "action": { diff --git a/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md b/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md index 4f123b360..3f7169a08 100644 --- a/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md +++ b/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **action** | **str** | The action to take if the rule is matched. | [default to ''] **name** | **str** | The name of the failure policy rule. The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. The name must match the regular expression \"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$\". | [default to ''] -**on_job_failure_reasons** | **list[str]** | The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. | +**on_job_failure_reasons** | **list[str]** | The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. | [optional] **target_replicated_jobs** | **list[str]** | TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs. | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py index 5c1054bb9..459eab518 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py @@ -60,7 +60,8 @@ def __init__(self, action='', name='', on_job_failure_reasons=None, target_repli self.action = action self.name = name - self.on_job_failure_reasons = on_job_failure_reasons + if on_job_failure_reasons is not None: + self.on_job_failure_reasons = on_job_failure_reasons if target_replicated_jobs is not None: self.target_replicated_jobs = target_replicated_jobs @@ -134,8 +135,6 @@ def on_job_failure_reasons(self, on_job_failure_reasons): :param on_job_failure_reasons: The on_job_failure_reasons of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 :type: list[str] """ - if self.local_vars_configuration.client_side_validation and on_job_failure_reasons is None: # noqa: E501 - raise ValueError("Invalid value for `on_job_failure_reasons`, must not be `None`") # noqa: E501 self._on_job_failure_reasons = on_job_failure_reasons diff --git a/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py b/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py index b20b6e472..fe706e322 100644 --- a/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py +++ b/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py @@ -51,9 +51,6 @@ def make_instance(self, include_optional): return JobsetV1alpha2FailurePolicyRule( action = '0', name = '0', - on_job_failure_reasons = [ - '0' - ], ) def testJobsetV1alpha2FailurePolicyRule(self):