Skip to content

Conversation

@Miciah
Copy link
Contributor

@Miciah Miciah commented Sep 24, 2019

Make the type field of the endpoint publishing strategy for an IngressController resource a required field.

The type field is a union discriminator field, and the KEP for union types states that a union discriminator field "CAN be optional". The IngressController resource's spec.endpointPublishingStrategy field is optional, so if it is specified, then it is reasonable to expect an explicit value be specified for spec.endpointPublishingStrategy.type, and the ingress operator will always set an explicit value for the status.endpointPublishingStrategy.type field.

The ingress operator currently has a CRD that was generated using controller-tools v0.2.0-beta.1, which ignores the +optional marker, with the result that spec.endpointPublishingStrategy.type is required. controller-tools v0.2.0-beta.3 and newer respects the +optional marker (kubernetes-sigs/controller-tools@fcf4205), with the result that regenerating the CRD with the current API would cause the field to become no longer required. Because the current CRD specifies the field to be required, it is safe to remove the +optional marker now so that the field will continue to be required when the CRD is regenerated using newer controller-tools.

  • operator/v1/types_ingress.go (EndpointPublishingStrategy): Remove the +optional marker on the type field.

Make the "type" field of the endpoint publishing strategy for an
IngressController resource a required field.

The "type" field is a union discriminator field, and the KEP for union
types states that a union discriminator field "CAN be optional"[1].  The
IngressController resource's "spec.endpointPublishingStrategy" field is
optional, so if it is specified, then it is reasonable to expect an
explicit value be specified for "spec.endpointPublishingStrategy.type", and
the ingress operator will always set an explicit value for the
"status.endpointPublishingStrategy.type" field.

The ingress operator currently has a CRD that was generated using
controller-tools v0.2.0-beta.1, which ignores the "+optional" marker, with
the result that "spec.endpointPublishingStrategy.type" is required[2].
controller-tools v0.2.0-beta.3 and newer respects the "+optional"
marker[3], with the result that regenerating the CRD with the current API
would cause the field to become no longer required.  Because the current
CRD specifies the field to be required, it is safe to remove the
"+optional" marker now so that the field will continue to be required when
the CRD is regenerated using newer controller-tools.

1. https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/20190325-unions.md#go-tags
2. openshift/cluster-ingress-operator@b32cee9#diff-1b0497d8867a90088e4614b2e61dc496R40
3. kubernetes-sigs/controller-tools@fcf4205

* operator/v1/types_ingress.go (EndpointPublishingStrategy): Remove the
"+optional" marker on the "type" field.
@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 24, 2019
@ironcladlou
Copy link
Contributor

/approve

@sttts PTAL, thanks for your help with these.

@sttts
Copy link
Contributor

sttts commented Sep 25, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 25, 2019
@sttts
Copy link
Contributor

sttts commented Sep 25, 2019

/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ironcladlou, Miciah, sttts

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

The pull request process is described here

Details 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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 25, 2019
@openshift-merge-robot openshift-merge-robot merged commit 97311a7 into openshift:master Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants