Skip to content

STOR 437- Create API for vsphere CSI topology configuration#1271

Merged
openshift-merge-robot merged 1 commit into
openshift:masterfrom
gnufied:api-for-vsphere-topology-config
Sep 13, 2022
Merged

STOR 437- Create API for vsphere CSI topology configuration#1271
openshift-merge-robot merged 1 commit into
openshift:masterfrom
gnufied:api-for-vsphere-topology-config

Conversation

@gnufied
Copy link
Copy Markdown
Member

@gnufied gnufied commented Aug 26, 2022

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Aug 26, 2022

Hello @gnufied! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

For merging purposes, this repository follows the no-Feature-Freeze process which means that in addition to the standard lgtm and approved labels this repository requires either:

bugzilla/valid-bug - applied if your PR references a valid bugzilla bug

OR

qe-approved, docs-approved, and px-approved - these labels can be applied by anyone in the openshift org via the /label <labelname> command.

Who should apply these qe/docs/px labels?

  • For a no-Feature-Freeze team who is merging a feature before code freeze, they need to get those labels applied to their api repo PR by the appropriate teams (i.e. qe, docs, px)
  • For a Feature Freeze (traditional) team who is merging a feature before FF, they can self-apply the labels (via /label commands), they are basically irrelevant for those teams
  • For a Feature Freeze team who is merging a feature after FF, the PR should be rejected barring an exception

@openshift-ci openshift-ci Bot requested review from adambkaplan and sjenning August 26, 2022 19:44
@gnufied
Copy link
Copy Markdown
Member Author

gnufied commented Aug 29, 2022

/retest

@gnufied gnufied force-pushed the api-for-vsphere-topology-config branch 4 times, most recently from 6ee97f8 to c275e8f Compare August 29, 2022 19:02
Comment thread operator/v1/types_csi_cluster_driver.go Outdated
// +kubebuilder:validation:Required
// +unionDiscriminator
// +required
DriverName CSIDriverName `json:"driverName"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CR.Name must be the CSI driver name, so field will duplicate that information?

Also, CR.Spec.DriverConfig.DriverName seems a bit verbose/redundant.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

^ this is a good point IMO, I don't really understand the purpose of the new DriverName field.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah I am going to rename it. But we do need a field here as a union discriminator which will basically make it obvious that if driverName: vsphere.vmware.com then - only vsphere will be set.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

https://github.com/openshift/enhancements/blob/master/dev-guide/api-conventions.md#discriminated-unions

I am torn about renaming driverName to Name. Elsewhere in OCP docs, union discriminators are called Type - if we do that, then we probably have to define a new enum.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, I don't have a strong preference on renaming the field, I think DriverName is fine. I just didn't understand the purpose, but that doc on discriminated unions explains it.

Comment thread operator/v1/types_csi_cluster_driver.go
@gnufied
Copy link
Copy Markdown
Member Author

gnufied commented Aug 31, 2022

/assign @JoelSpeed @deads2k

Comment thread operator/v1/types_csi_cluster_driver.go Outdated
Comment on lines +100 to +106
// DriverConfig field can be used to optionally specify
// driver specific configuration.
// If this field is nil, platform chosen default configuration
// will be applied.
// +kubebuilder:validation:Optional
// +optional
DriverConfig *CSIDriverConfigSpec `json:"driverConfig,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Few nits on this:

  • The first word should match the json tag
  • We should use the standard wording that other APIs use for when this is optional
  • You only need one optional tag, we prefer +optional
  • You shouldn't use a pointer here unless you have a good reason to do so, do you need a pointer?
Suggested change
// DriverConfig field can be used to optionally specify
// driver specific configuration.
// If this field is nil, platform chosen default configuration
// will be applied.
// +kubebuilder:validation:Optional
// +optional
DriverConfig *CSIDriverConfigSpec `json:"driverConfig,omitempty"`
// driverConfig can be used to specify platform specific driver configuration.
// When omitted, this means no opinion and the platform is left to choose reasonable
// defaults. These defaults are subject to change over time.
// +optional
DriverConfig CSIDriverConfigSpec `json:"driverConfig,omitempty"`

Copy link
Copy Markdown
Member Author

@gnufied gnufied Aug 31, 2022

Choose a reason for hiding this comment

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

I was reading about API conventions and although I have accepted this suggestion, one of the things which I find sometimes problematic is - CSIDriverConfigSpec says DriverName is a required field and hence by that definition - an empty CSIDriverConfigSpec isn't a valid object because DriverName is not set. I know on the wire, if field is empty - it is entirely omitted but I think that after deserializing we basically have a GO object that is essentially invalid and does not conform to schema it defines itself, which is weird.

So I think for union types which have a required union discriminator I think that a nil pointer is only sensible default if users don't want to specify one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a trade off we have decide to make for the discoverability benefits. But yes, you need to teach your controller to handle the empty DriverConfig. It shouldn't be too difficult and isn't dissimilar to the nil check you'd have to otherwise do

emptyConfig := operatorv1.CSIDriverConfigSpec{} 
if spec.DriverConfig == emptyConfig {
  // No driver config was specified
  return nil
}

Comment thread operator/v1/types_csi_cluster_driver.go
Comment thread operator/v1/types_csi_cluster_driver.go Outdated
Comment thread operator/v1/types_csi_cluster_driver.go Outdated
Comment thread operator/v1/types_csi_cluster_driver.go Outdated
Comment on lines +130 to +131
// TopologyCategories indicates categories with which
// vcenter resources as hostcluster or datacenter were tagged with.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you clarify what this means? It doesn't make sense to me, do you mean resources such as?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added more details. PTAL

Comment thread operator/v1/types_csi_cluster_driver.go Outdated
Comment on lines +132 to +133
// If unspecified CSI driver configuration will default to configuration
// specified in cluster configuration.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where does this configuration live? On the Infrastructure object?

Copy link
Copy Markdown
Member Author

@gnufied gnufied Aug 31, 2022

Choose a reason for hiding this comment

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

Yes - basically what @jcpowermac is proposing in his enhancement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, I'd expect the comment here to mention that it's on the Infrastructure object, gives user a hint as to where they can find the defaults

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done. PTAL

Comment thread operator/v1/types_csi_cluster_driver.go Outdated
Comment thread operator/v1/types_csi_cluster_driver.go Outdated
// driverName indicates which CSI driver should be installed.
// +kubebuilder:validation:Required
// +unionDiscriminator
DriverName CSIDriverName `json:"driverName"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be an enum, do we have a list of valid values for this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have renamed this to CSIDriverType and defined a new enum. @bertinatto raised a concern that we were overloading CSIDriverName type which is used for defining driver name.

Comment thread operator/v1/types_csi_cluster_driver.go Outdated

// vsphere is used to configure the vsphere CSI driver.
// +optional
VSphere *VSphereCSIDriverConfigSpec `json:"vsphere,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What value must DriverName have for this configuration to be observed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated to reflect the values.

@dobsonj
Copy link
Copy Markdown
Member

dobsonj commented Sep 6, 2022

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 6, 2022
@gnufied gnufied force-pushed the api-for-vsphere-topology-config branch from 1d1f84c to 5a99faf Compare September 7, 2022 15:39
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 7, 2022
Copy link
Copy Markdown
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

I think we are pretty close, a few more comments

Comment thread operator/v1/types_csi_cluster_driver.go Outdated
//
// +kubebuilder:validation:Required
// +unionDiscriminator
DriverType CSIDriverType `json:"driverType"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As this enum is expected over time, you need to add a developer note to explain what consumers should do when they observe an unknown value, there's typically two options there

Suggested change
DriverType CSIDriverType `json:"driverType"`
// ---
// + Consumers should treat unknown values as a no-op || Consumers should treat unknown values as an error and stop processing.
DriverType CSIDriverType `json:"driverType"`

Comment thread operator/v1/types_csi_cluster_driver.go Outdated
Comment on lines +143 to +145
// specified in Infrastructure object. If both Infrastructure object and
// ClusterCSIDriver specify topology - then values in Infrastructure object
// will take precedence.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typically the closer object to the action (this resource) would take precedence, it seems odd to say the Infrastructure object will take precedence here, I would expect to reverse that.

Having the closer object allows whoever owns that specific component to override the global configuration should they need to.

Why are you suggesting it to be this way around?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Currently its bit like you would expect ebs provisioner as default in a storageclass deployed on AWS cluster not ceph provisioner. One can deploy ceph on OCP AWS cluster sure but it requires bunch of manual configuration.

Similarly topology from Infrastructure object is guaranteed to be right and does not require any further manual configuration in vcenter, so we want to start with somewhat stricter definition of topologyCategories if Infra object already defines one.

Currently we are thinking - once Infra changes are merged, we will not allow setting these values at all by end users and any changes to ClusterCSIDriver topologies will be rejected by webhook, if Infra object already defines a topology(via failure-domains). I will update the wording here to be more clear on this.

But we also realize that, compute and storage topologies can have two different values - so we don't want to close the door completely on that option, so we may choose to relax this in a future version of OCP.

Comment thread operator/v1/types_csi_cluster_driver.go Outdated

// vsphere is used to configure the vsphere CSI driver.
// +optional
VSphere *VSphereCSIDriverConfigSpec `json:"vsphere,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the right CSIDriverType is "VSphere", then this must be json:"vSphere

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Check the discriminated unions in the config v1 types and follow their patterns

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed.

@gnufied
Copy link
Copy Markdown
Member Author

gnufied commented Sep 9, 2022

@JoelSpeed PTAL. Dropped omitempty from optional but non-pointer fields and addressed other review comments.

Copy link
Copy Markdown
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

API looks good, have you tested it against a real cluster to make sure it behaves how you expect it should?

@gnufied
Copy link
Copy Markdown
Member Author

gnufied commented Sep 9, 2022

@JoelSpeed yep. The entire PR has been verified using linked changes into vmware-vpshere-csi-driver openshift/vmware-vsphere-csi-driver-operator#107 and it works as expected.

@JoelSpeed
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 12, 2022
Update API to use latest guidelines, drop omitempty
@gnufied gnufied force-pushed the api-for-vsphere-topology-config branch from 2d7e29c to 269199d Compare September 12, 2022 14:19
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 12, 2022
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Sep 12, 2022

@gnufied: all tests passed!

Full PR test history. Your PR dashboard.

Details

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/test-infra repository. I understand the commands that are listed here.

@jsafrane
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 12, 2022
@deads2k
Copy link
Copy Markdown
Contributor

deads2k commented Sep 12, 2022

/approve

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Sep 12, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, dobsonj, gnufied, JoelSpeed, jsafrane

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 openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 12, 2022
@gnufied
Copy link
Copy Markdown
Member Author

gnufied commented Sep 12, 2022

/docs approved
/px approved

@gnufied
Copy link
Copy Markdown
Member Author

gnufied commented Sep 13, 2022

Since this is just an API change.

/label docs-approved
/label px-approved

@openshift-ci openshift-ci Bot added docs-approved Signifies that Docs has signed off on this PR px-approved Signifies that Product Support has signed off on this PR labels Sep 13, 2022
@duanwei33
Copy link
Copy Markdown

/label qe-approved

@openshift-ci openshift-ci Bot added the qe-approved Signifies that QE has signed off on this PR label Sep 13, 2022
@openshift-merge-robot openshift-merge-robot merged commit 67162ff into openshift:master Sep 13, 2022
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. docs-approved Signifies that Docs has signed off on this PR lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants