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

Bug 1882723: vSphere: Create warning on invalid specs and remove defaults #732

Merged

Conversation

alexander-demicev
Copy link
Contributor

@alexander-demicev alexander-demicev commented Oct 21, 2020

If the user forgets to specify CPU, memory, or disk size we default it to 0 and the reconciler then defaults it to a minimal value.
This PR:

  1. Make webhook return warning on missing VM specs
  2. Removes defaulting from the controller and let's fail to pass.

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. label Oct 21, 2020
@openshift-ci-robot
Copy link
Contributor

@alexander-demichev: This pull request references Bugzilla bug 1882723, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1882723: vSphere: make webhook return error on invalid VM specs

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Oct 21, 2020
Comment on lines 993 to 995
if providerSpec.NumCPUs == 0 {
errs = append(errs, field.Invalid(field.NewPath("providerSpec", "numCPUs"), providerSpec.NumCPUs, "numCPUs must be greater than 0"))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC there's something in the controller that caters for this scenario, can we check that before we add this one?

We want to verify that placing a 0 value in this field will result in a failed machine, have you tried this for each of the three errors you're adding?

@@ -980,14 +980,24 @@ func validateVSphere(m *Machine, clusterID string) (bool, []string, utilerrors.A

errs = append(errs, validateVSphereNetwork(providerSpec.Network, field.NewPath("providerSpec", "network"))...)

if providerSpec.NumCPUs < minVSphereCPU {
warnings = append(warnings, fmt.Sprintf("providerSpec.numCPUs: %d is less than the minimum value (%d): the minimum value will be used instead", providerSpec.NumCPUs, minVSphereCPU))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing the minimum value will be used instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I completely forgot about this behavior.

pkg/apis/machine/v1beta1/machine_webhook.go Show resolved Hide resolved
@alexander-demicev alexander-demicev changed the title Bug 1882723: vSphere: make webhook return error on invalid VM specs Bug 1882723: vSphere: Create warning on invalid specs and remove defaults Oct 23, 2020
@openshift-ci-robot
Copy link
Contributor

@alexander-demichev: This pull request references Bugzilla bug 1882723, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1882723: vSphere: Create warning on invalid specs and remove defaults

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

@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.

Have you tried this out on a real cluster, what happens if you set CPU 0?

@@ -980,14 +980,14 @@ func validateVSphere(m *Machine, clusterID string) (bool, []string, utilerrors.A

errs = append(errs, validateVSphereNetwork(providerSpec.Network, field.NewPath("providerSpec", "network"))...)

if providerSpec.NumCPUs < minVSphereCPU {
warnings = append(warnings, fmt.Sprintf("providerSpec.numCPUs: %d is less than the minimum value (%d): the minimum value will be used instead", providerSpec.NumCPUs, minVSphereCPU))
if providerSpec.NumCPUs < minVSphereCPU || providerSpec.NumCPUs == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think we actually need the or statement here, 0 < minVSphereCPU is true anyway. Similar goes for the cases below

@JoelSpeed
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoelSpeed

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 30, 2020
@JoelSpeed
Copy link
Contributor

/retest

@@ -981,13 +981,13 @@ func validateVSphere(m *Machine, clusterID string) (bool, []string, utilerrors.A
errs = append(errs, validateVSphereNetwork(providerSpec.Network, field.NewPath("providerSpec", "network"))...)

if providerSpec.NumCPUs < minVSphereCPU {
warnings = append(warnings, fmt.Sprintf("providerSpec.numCPUs: %d is less than the minimum value (%d): the minimum value will be used instead", providerSpec.NumCPUs, minVSphereCPU))
warnings = append(warnings, fmt.Sprintf("providerSpec.numCPUs: %d is missing or less than the minimum value (%d): the minimum value will be used instead", providerSpec.NumCPUs, minVSphereCPU))
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we actually setting the minimum value? Below it looks like that logic was removed from the reconciler.

Copy link
Contributor

Choose a reason for hiding this comment

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

The logic was removed from the webhook, but is being done in the reconcile loop currently

numCPUs := s.providerSpec.NumCPUs
if numCPUs < minCPU {
numCPUs = minCPU
}
numCoresPerSocket := s.providerSpec.NumCoresPerSocket
if numCoresPerSocket == 0 {
numCoresPerSocket = numCPUs
}
memMiB := s.providerSpec.MemoryMiB
if memMiB == 0 {
memMiB = minMemMB
}

Copy link
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 4, 2020
@elmiko
Copy link
Contributor

elmiko commented Dec 4, 2020

Mike's comment came in while i was reviewing, removing my lgtm to ensure we don't merge before it's answered.
/lgtm cancel

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 4, 2020
@alexander-demicev
Copy link
Contributor Author

@elmiko @michaelgugino Can I get another review?

Copy link
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 8, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 063975e into openshift:master Dec 8, 2020
@openshift-ci-robot
Copy link
Contributor

@alexander-demichev: All pull requests linked via external trackers have merged:

Bugzilla bug 1882723 has been moved to the MODIFIED state.

In response to this:

Bug 1882723: vSphere: Create warning on invalid specs and remove defaults

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.

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. bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants