Skip to content

feat(apis/batch): PodFailurePolicyOnPodConditionsPattern.Status can be omitted #133479

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mayooot
Copy link
Contributor

@mayooot mayooot commented Aug 12, 2025

What type of PR is this?

/kind feature

Optionally add one or more of the following kinds if applicable:

/kind api-change

What this PR does / why we need it:

// PodFailurePolicyOnPodConditionsPattern describes a pattern for matching
// an actual pod condition type.
type PodFailurePolicyOnPodConditionsPattern struct {
// Specifies the required Pod condition type. To match a pod condition
// it is required that specified type equals the pod condition type.
Type api.PodConditionType
// Specifies the required Pod condition status. To match a pod condition
// it is required that the specified status equals the pod condition status.
// Defaults to True.
// +default="True"
Status api.ConditionStatus
}

Status is not explicitly set to "True", which may lead to errors in Python Kubernetes client generated by upstream.

In kube-apiserver, the Status will be set to "True" automatically even if we don't set it manually - this can be done by a webhook or controller — but this does not resolve downstream errors.

Which issue(s) this PR is related to:

kubernetes-client/python#2430
kubernetes-client/python#2432

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

https://github.com/kubernetes-client/python/blob/master/CONTRIBUTING.md

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 12, 2025
@k8s-ci-robot
Copy link
Contributor

Please note that we're already in Test Freeze for the release-1.34 branch. This means every merged PR will be automatically fast-forwarded via the periodic ci-fast-forward job to the release branch of the upcoming v1.34.0 release.

Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Tue Aug 12 04:23:31 UTC 2025.

@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 12, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 12, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @mayooot. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Aug 12, 2025
@k8s-ci-robot k8s-ci-robot requested review from deads2k and kow3ns August 12, 2025 07:38
@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 12, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Apps Aug 12, 2025
@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@mayooot mayooot changed the title ufeat(apis/batch): set defaults Status to "True" in PodFailurePolicyOn… feat(apis/batch): set defaults Status to "True" in PodFailurePolicyOn… Aug 13, 2025
@mayooot
Copy link
Contributor Author

mayooot commented Aug 13, 2025

/label api-review

@k8s-ci-robot k8s-ci-robot added the api-review Categorizes an issue or PR as actively needing an API review. label Aug 13, 2025
@liggitt
Copy link
Member

liggitt commented Aug 14, 2025

the PodFailurePolicyOnPodConditionsPattern type documents type and status fields as required, since they are not marked as +optional and are not omitempty

we can verify that those fields are marked as required in openapi:

    "io.k8s.api.batch.v1.PodFailurePolicyOnPodConditionsPattern": {
      "description": "PodFailurePolicyOnPodConditionsPattern describes a pattern for matching an actual pod condition type.",
      "properties": {
        "status": {
          "description": "Specifies the required Pod condition status. To match a pod condition it is required that the specified status equals the pod condition status. Defaults to True.",
          "type": "string"
        },
        "type": {
          "description": "Specifies the required Pod condition type. To match a pod condition it is required that specified type equals the pod condition type.",
          "type": "string"
        }
      },
      "required": [
        "type",
        "status"
      ],
      "type": "object"
    },

however, if I submit a manifest to the server omitting that field, the API server does accept it and defaults the status field to True

func SetDefaults_PodFailurePolicyOnPodConditionsPattern(obj *batchv1.PodFailurePolicyOnPodConditionsPattern) {
	if obj.Status == "" {
		obj.Status = corev1.ConditionTrue
	}
}

That means the status field is not actually required.

I think the correct change here would be to mark the field as // +optional to fix the advertised openapi.

@@ -212,6 +212,7 @@ type PodFailurePolicyOnPodConditionsPattern struct {
// Specifies the required Pod condition status. To match a pod condition
// it is required that the specified status equals the pod condition status.
// Defaults to True.
// +default="True"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mark this field as // +optional instead, and make the change to the v1/types.go and v1beta1/types.go files as well (will require regenerating docs, etc, with make update)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staging/src/k8s.io/api/batch/v1beta1/types.go doesn't define the PodFailurePolicyOnPodConditionsPattern struct, perhaps we should update both staging/src/k8s.io/api/batch/v1/types.go and pkg/apis/batch/types.go.

@liggitt liggitt moved this to Changes requested in API Reviews Aug 14, 2025
@mayooot
Copy link
Contributor Author

mayooot commented Aug 14, 2025

@liggitt Got it, I'll update it soon.

@mayooot mayooot force-pushed the feat/set-default-value branch from 0d10d5b to 3f8de6c Compare August 15, 2025 08:33
@mayooot mayooot requested a review from liggitt August 15, 2025 08:33
@mayooot mayooot changed the title feat(apis/batch): set defaults Status to "True" in PodFailurePolicyOn… feat(apis/batch): PodFailurePolicyOnPodConditionsPattern.Status can be omitted Aug 15, 2025
@liggitt liggitt added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Aug 15, 2025
@liggitt
Copy link
Member

liggitt commented Aug 15, 2025

/ok-to-test
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 15, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 15, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: c17b3d7c8fcffe79c68a20a356a4d15769a59f67

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, mayooot

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 15, 2025
@mayooot
Copy link
Contributor Author

mayooot commented Aug 15, 2025

/retest-required

@liggitt liggitt added this to the v1.35 milestone Aug 15, 2025
@liggitt
Copy link
Member

liggitt commented Aug 15, 2025

Status is not explicitly set to "True", which may lead to errors in Python Kubernetes client generated by upstream.

if this is leading to errors, does that mean the client is doing blocking client-side validation by default? that's not really recommended... is there an issue in the python library tracking that?

@liggitt liggitt moved this from Changes requested to API review completed, 1.35 in API Reviews Aug 15, 2025
@mayooot
Copy link
Contributor Author

mayooot commented Aug 16, 2025

Status is not explicitly set to "True", which may lead to errors in Python Kubernetes client generated by upstream.

if this is leading to errors, does that mean the client is doing blocking client-side validation by default? that's not really recommended... is there an issue in the python library tracking that?

I think this can be resolved once this PR has been mered, because Status is not required. Therefore, the genereated codes will change as folows:
Before:

def __init__(self, status=None, type=None, local_vars_configuration=None):

After:

def __init__(self, type=None, local_vars_configuration=None):

And the python status function will be changed to look like this:

    @status.setter
    def status(self, status):
        """Sets the status of this V1PodFailurePolicyOnPodConditionsPattern.

        Specifies the required Pod condition status. To match a pod condition it is required that the specified status equals the pod condition status. Defaults to True.  # noqa: E501

        :param status: The status of this V1PodFailurePolicyOnPodConditionsPattern.  # noqa: E501
        :type: str
        """
-        if self.local_vars_configuration.client_side_validation and status is None:  # noqa: E501
-            raise ValueError("Invalid value for `status`, must not be `None`")  # noqa: E501

        self._status = status

WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/code-generation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
Status: API review completed, 1.35
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

4 participants