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

Fix the Default Values in the FeatureGates field #1113

Merged
merged 2 commits into from
Feb 2, 2021

Conversation

nunnatsa
Copy link
Collaborator

@nunnatsa nunnatsa commented Jan 31, 2021

PR #1109 added default valuse for several feature gates. In order to do that, it tried to set the default value of the featureGates field to an empty object ({}), in order to force its existance, and then the flag specific default value shoulf take place.

Although this is working very well by manually editing the CRD, and we get exactlly what we want, this is not possible to set the empty object using an annotation:

// +kubebuilder:default={}
FeatureGates *HyperConvergedFeatureGates `json:"featureGates,omitempty"`

produces a CRD with default of null:

featureGates:
  default: null

instead of the required:

featureGates:
  default: {}

And that causes to the featureGates field to not appear by default as required.

This PR sets the default in two places: both on the featureGates field as an object, and on withHostModelCPU and the withHostPassthroughCPU inner fields as a boolean (no change).

After the change we get the required behavior - the default flags appear if they are missing with their default values, independently - it is possible to set each one of them to other value, but deleting them or the whole fatureGates field will cause applying of the default values.

Nahshon Unna-Tsameret nunnatsa@redhat.com

Signed-off-by: Nahshon Unna-Tsameret nunnatsa@redhat.com

Release note:

Fix the Default Values in the FeatureGates field

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Jan 31, 2021
@nunnatsa nunnatsa requested review from enp0s3 and removed request for zcahana January 31, 2021 15:19
@coveralls
Copy link
Collaborator

coveralls commented Jan 31, 2021

Pull Request Test Coverage Report for Build 529987507

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 72.015%

Totals Coverage Status
Change from base Build 528112219: 0.0%
Covered Lines: 2352
Relevant Lines: 3266

💛 - Coveralls

@hco-bot
Copy link
Collaborator

hco-bot commented Jan 31, 2021

hco-e2e-upgrade-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-aws
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, ci/prow/hco-e2e-upgrade-aws

In response to this:

hco-e2e-upgrade-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-aws
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.

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

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 1, 2021
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2021
PR kubevirt#1109 added default valuse for several feature gates. In order to do that, it tried to set the default value of the `featureGates` field to an empty object (`{}`), in order to force its existance, and then the flag specific default value shoulf take place.

Although this is working very well by manually editing the CRD, and we get exactlly what we want, this is not possible to set the empty object using an annotation:

``` golang
// +kubebuilder:default={withHostModelCPU: true, withHostPassthroughCPU: false}
FeatureGates *HyperConvergedFeatureGates `json:"featureGates,omitempty"`
```

produces a CRD with default of `null`:
``` yaml
featureGates:
  default: null
```
instead of the required:
``` yaml
featureGates:
  default: {}
```
And that causes to the `featureGates` field to not appear by default as required.

This PR sets the default in two places: both on the `featureGates` field as an object, and on `withHostModelCPU` and the `withHostPassthroughCPU` inner fields as a boolean (no change).

After the change we get the required behavior - the default flags appear if they are missing with their default values, independently - it is possible to set each one of them to other value, but deleting them or the whole `fatureGates` field will cause applying of the default values.

Nahshon Unna-Tsameret <nunnatsa@redhat.com>

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
…ates

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
@sonarcloud
Copy link

sonarcloud bot commented Feb 2, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@openshift-ci
Copy link

openshift-ci bot commented Feb 2, 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 14b4197 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 Feb 2, 2021

hco-e2e-image-index-aws lane succeeded.
/override ci/prow/hco-e2e-image-index-gcp
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-image-index-gcp, ci/prow/hco-e2e-upgrade-prev-azure

In response to this:

hco-e2e-image-index-aws lane succeeded.
/override ci/prow/hco-e2e-image-index-gcp
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.

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

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

nunnatsa commented Feb 2, 2021

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nunnatsa

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 Feb 2, 2021
@kubevirt-bot kubevirt-bot merged commit 1ba5ba6 into kubevirt:master Feb 2, 2021
@nunnatsa nunnatsa deleted the fix-fg-default branch February 2, 2021 09:33
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/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants