Skip to content
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

Change the FeatureGates implemantation #1060

Merged
merged 5 commits into from
Jan 18, 2021

Conversation

nunnatsa
Copy link
Collaborator

@nunnatsa nunnatsa commented Jan 17, 2021

Change the FeatureGates implemantation to be strict and to add documentation to the CR for each feature gate.

The previose implementation used a map[string]bool to store the feature gates. That way, it was impossible to add documentation for each feature gate.

This PR changes the implementation so the feature gates are now stored in a struct, as a pointer to boolean (to keep them optional). The result is a documentable feature gates as well as strict naming of the feature gates, because their names are not just astring but a field name.

Since HotplugVolumes is not a valid json or yaml tag name (starts with upper case), the gate name was changed to hotplugVolumes (starts with lower case)

As part of this change, the HyperConverged CRD contains the documentation for the hotplugVolumes feature gate, that can be read directly from the CRD, or by calling kubectl explain:

$ kubectl explain HyperConverged.spec.featureGates
KIND:     HyperConverged
VERSION:  hco.kubevirt.io/v1beta1

RESOURCE: featureGates <Object>

DESCRIPTION:
     featureGates HyperConvergedFeatureGates contains a list of feature enabler
     flags. Setting a flag to `true` will enable the feature. Setting `false` or
     removing the feature gate, disables the feature.

FIELDS:
   hotplugVolumes	<boolean>
     Allow attaching a data volume to a running VMI; type is boolean; default is
     false

In addition, this PR adds feature gates documentation to the docs/cluster-configuration.md file with the following usage example:

apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
  name: kubevirt-hyperconverged
spec:
  infra: {}
  workloads: {}
  featureGates:
    hotplugVolumes: true

Signed-off-by: Nahshon Unna-Tsameret [email protected]

Release note:

Added CRD documentation to the hotplugVolumes feature gate
Added Feature gates documentation to the cluster-configuration.md document
Change HotplugVolumes to hotplugVolumes

Change the FeatureGates implemantation to be strict and to add documentation to the CR for each feature gate

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Jan 17, 2021
Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
pkg/apis/hco/v1beta1/hyperconverged_types.go Show resolved Hide resolved
pkg/apis/hco/v1beta1/hyperconverged_types.go Outdated Show resolved Hide resolved
pkg/components/components.go Outdated Show resolved Hide resolved
pkg/controller/operands/kubevirt.go Outdated Show resolved Hide resolved
pkg/controller/operands/kubevirt.go Show resolved Hide resolved
@zcahana
Copy link
Contributor

zcahana commented Jan 17, 2021

And another general comment - what is the significance (in terms of API design) of grouping various knobs under a featureGates: field? Is it to indicate the immaturity or the temporariness of the feature gate? Is it a "part" of the HyperConverged CR that we deliberately tell users that nested fields (e.g., .hotplugVolumes) will likely be deprecated soon and later removed (i.e. once the feature graduates, or withdrawn).

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jan 17, 2021
Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
@hco-bot
Copy link
Collaborator

hco-bot commented Jan 17, 2021

hco-e2e-image-index-azure, hco-e2e-image-index-aws lanes succeeded.
/override ci/prow/hco-e2e-image-index-gcp

@kubevirt-bot
Copy link
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-image-index-gcp

In response to this:

hco-e2e-image-index-azure, hco-e2e-image-index-aws lanes succeeded.
/override ci/prow/hco-e2e-image-index-gcp

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.

@enp0s3
Copy link
Contributor

enp0s3 commented Jan 17, 2021

And another general comment - what is the significance (in terms of API design) of grouping various knobs under a featureGates: field? Is it to indicate the immaturity or the temporariness of the feature gate? Is it a "part" of the HyperConverged CR that we deliberately tell users that nested fields (e.g., .hotplugVolumes) will likely be deprecated soon and later removed (i.e. once the feature graduates, or withdrawn).

@zcahana Yes. Once a preview/optional feature will grown up into a fully fledged one, we will remove it from the feature gate section and perhaps it will have it's own place in the HCO CR.

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
Copy link
Contributor

@enp0s3 enp0s3 left a comment

Choose a reason for hiding this comment

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

/lgtm
@nunnatsa I am feeling uncomforatble with using fmt.Print in the code, but if there is a promise to refactor the code to add a logger then let's go forward with this code change.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2021
@openshift-ci
Copy link

openshift-ci bot commented Jan 18, 2021

@nunnatsa: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/hco-e2e-image-index-gcp 2ea7ee7 link /test hco-e2e-image-index-gcp

Full PR test history. Your PR dashboard.

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.

@hco-bot
Copy link
Collaborator

hco-bot commented Jan 18, 2021

hco-e2e-upgrade-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-azure
hco-e2e-image-index-aws lane succeeded.
/override ci/prow/hco-e2e-image-index-azure
hco-e2e-upgrade-prev-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-azure

@kubevirt-bot
Copy link
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-image-index-azure, ci/prow/hco-e2e-upgrade-azure, ci/prow/hco-e2e-upgrade-prev-azure

In response to this:

hco-e2e-upgrade-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-azure
hco-e2e-image-index-aws lane succeeded.
/override ci/prow/hco-e2e-image-index-azure
hco-e2e-upgrade-prev-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-azure

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.

@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2021
@nunnatsa
Copy link
Collaborator Author

@nunnatsa I am feeling uncomforatble with using fmt.Print in the code, but if there is a promise to refactor the code to add a logger then let's go forward with this code change.

Done.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2021
@tiraboschi
Copy link
Member

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tiraboschi

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 18, 2021
Copy link
Contributor

@enp0s3 enp0s3 left a comment

Choose a reason for hiding this comment

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

/lgtm

@nunnatsa
Copy link
Collaborator Author

/override-bot

@hco-bot
Copy link
Collaborator

hco-bot commented Jan 18, 2021

hco-e2e-image-index-azure, hco-e2e-image-index-aws lanes succeeded.
/override ci/prow/hco-e2e-image-index-gcp

@kubevirt-bot
Copy link
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-image-index-gcp

In response to this:

hco-e2e-image-index-azure, hco-e2e-image-index-aws lanes succeeded.
/override ci/prow/hco-e2e-image-index-gcp

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.

@kubevirt-bot kubevirt-bot merged commit ead55cf into kubevirt:master Jan 18, 2021
@nunnatsa nunnatsa deleted the strict-fg-api branch January 18, 2021 09:12
@nunnatsa
Copy link
Collaborator Author

/cherry-pick release-1.3

@kubevirt-bot
Copy link
Contributor

@nunnatsa: #1060 failed to apply on top of branch "release-1.3":

.git/rebase-apply/patch:83: trailing whitespace.
Some configurations are done separately to Infra and Workloads. The CR's Spec object contains the `infra` and the 
.git/rebase-apply/patch:100: trailing whitespace.
The `featureGates` field is an optional set of optional boolean feature enabler. The features in this list are advanced 
.git/rebase-apply/patch:103: trailing whitespace.
To enable a feature, add its name to the `featureGates` list and set it to `true`. Missing or `false` feature gates 
warning: 3 lines add whitespace errors.
error: Failed to merge in the changes.
Using index info to reconstruct a base tree...
A	deploy/index-image/kubevirt-hyperconverged/1.4.0/hco00.crd.yaml
A	deploy/olm-catalog/kubevirt-hyperconverged/1.4.0/hco00.crd.yaml
M	pkg/apis/hco/v1beta1/hyperconverged_types_test.go
M	pkg/components/components.go
M	pkg/controller/operands/kubevirt.go
M	pkg/controller/operands/kubevirt_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/controller/operands/kubevirt_test.go
CONFLICT (content): Merge conflict in pkg/controller/operands/kubevirt_test.go
Auto-merging pkg/controller/operands/kubevirt.go
CONFLICT (content): Merge conflict in pkg/controller/operands/kubevirt.go
Auto-merging pkg/components/components.go
Auto-merging pkg/apis/hco/v1beta1/hyperconverged_types_test.go
Auto-merging deploy/olm-catalog/kubevirt-hyperconverged/1.3.0/hco00.crd.yaml
Auto-merging deploy/index-image/kubevirt-hyperconverged/1.3.0/hco00.crd.yaml
Patch failed at 0001 Change the FeatureGates implemantation

In response to this:

/cherry-pick release-1.3

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.

nunnatsa added a commit to nunnatsa/hyperconverged-cluster-operator that referenced this pull request Jan 18, 2021
* Change the FeatureGates implemantation

Change the FeatureGates implemantation to be strict and to add documentation to the CR for each feature gate

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

* Fix code-review comments

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

* Fix code-review comments

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

* Fix code-review comments

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

* modify HotplugVolumes casing to hotplugVolumes

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

(cherry picked from commit ead55cf)
Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
nunnatsa added a commit to nunnatsa/hyperconverged-cluster-operator that referenced this pull request Jan 18, 2021
Change the FeatureGates implemantation to be strict and to add documentation to the CR for each feature gate.

The previose implementation used a `map[string]bool` to store the feature gates. That way, it was impossible to add documentation for each feature gate.

This PR changes the implementation so the feature gates are now stored in a struct, as a pointer to boolean (to keep them optional). The result is a documentable feature gates as well as strict naming of the feature gates, because their names are not just astring but a field name.

Since `HotplugVolumes` is not a valid json or yaml tag name (starts with upper case), the gate name was changed to `hotplugVolumes` (starts with lower case)

As part of this change, the HyperConverged CRD contains the documentation for the `hotplugVolumes` feature gate, that can be read directly from the CRD, or by calling `kubectl explain`:
```
$ kubectl explain HyperConverged.spec.featureGates
KIND:     HyperConverged
VERSION:  hco.kubevirt.io/v1beta1

RESOURCE: featureGates <Object>

DESCRIPTION:
     featureGates HyperConvergedFeatureGates contains a list of feature enabler
     flags. Setting a flag to `true` will enable the feature. Setting `false` or
     removing the feature gate, disables the feature.

FIELDS:
   hotplugVolumes	<boolean>
     Allow attaching a data volume to a running VMI; type is boolean; default is
     false
```

In addition, this PR adds feature gates documentation to the `docs/cluster-configuration.md` file with the following usage example:

```yaml
apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
  name: kubevirt-hyperconverged
spec:
  infra: {}
  workloads: {}
  featureGates:
    hotplugVolumes: true
```

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

**Release note**:
```release-note
Added CRD documentation to the hotplugVolumes feature gate
Added Feature gates documentation to the cluster-configuration.md document
Change HotplugVolumes to hotplugVolumes
```

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
kubevirt-bot pushed a commit that referenced this pull request Jan 18, 2021
* Change the FeatureGates implemantation (#1060)

* Change the FeatureGates implemantation

Change the FeatureGates implemantation to be strict and to add documentation to the CR for each feature gate

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

* Fix code-review comments

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

* Fix code-review comments

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

* Fix code-review comments

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

* modify HotplugVolumes casing to hotplugVolumes

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

(cherry picked from commit ead55cf)
Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

* Change the FeatureGates implemantation (#1060)

Change the FeatureGates implemantation to be strict and to add documentation to the CR for each feature gate.

The previose implementation used a `map[string]bool` to store the feature gates. That way, it was impossible to add documentation for each feature gate.

This PR changes the implementation so the feature gates are now stored in a struct, as a pointer to boolean (to keep them optional). The result is a documentable feature gates as well as strict naming of the feature gates, because their names are not just astring but a field name.

Since `HotplugVolumes` is not a valid json or yaml tag name (starts with upper case), the gate name was changed to `hotplugVolumes` (starts with lower case)

As part of this change, the HyperConverged CRD contains the documentation for the `hotplugVolumes` feature gate, that can be read directly from the CRD, or by calling `kubectl explain`:
```
$ kubectl explain HyperConverged.spec.featureGates
KIND:     HyperConverged
VERSION:  hco.kubevirt.io/v1beta1

RESOURCE: featureGates <Object>

DESCRIPTION:
     featureGates HyperConvergedFeatureGates contains a list of feature enabler
     flags. Setting a flag to `true` will enable the feature. Setting `false` or
     removing the feature gate, disables the feature.

FIELDS:
   hotplugVolumes	<boolean>
     Allow attaching a data volume to a running VMI; type is boolean; default is
     false
```

In addition, this PR adds feature gates documentation to the `docs/cluster-configuration.md` file with the following usage example:

```yaml
apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
  name: kubevirt-hyperconverged
spec:
  infra: {}
  workloads: {}
  featureGates:
    hotplugVolumes: true
```

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>

**Release note**:
```release-note
Added CRD documentation to the hotplugVolumes feature gate
Added Feature gates documentation to the cluster-configuration.md document
Change HotplugVolumes to hotplugVolumes
```

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants