Skip to content

Conversation

@rna-afk
Copy link
Contributor

@rna-afk rna-afk commented Mar 15, 2021

If the machineCIDR is specified by the user, the VIP IPs provided
must overlap with the CIDRs provided and the installation fails
if they do not.

Adding a validation check to see if the CIDR is provided and if so,
checks to see if the IPs are within any of the machine CIDRs provided.

@openshift-ci-robot
Copy link
Contributor

@rna-afk: This pull request references Bugzilla bug 1918469, which is invalid:

  • expected the bug to target the "4.8.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

Bug 1918469: Check if VIP IPs overlap with machine CIDR provided

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 bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Mar 15, 2021
@rna-afk
Copy link
Contributor Author

rna-afk commented Mar 15, 2021

/assign @staebler

@rna-afk
Copy link
Contributor Author

rna-afk commented Mar 15, 2021

/bugzilla refresh

@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 Mar 15, 2021
@openshift-ci-robot
Copy link
Contributor

@rna-afk: This pull request references Bugzilla bug 1918469, 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.8.0) matches configured target release for branch (4.8.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @jinyunma

Details

In response to this:

/bugzilla refresh

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 removed the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label Mar 15, 2021
Copy link
Contributor

@staebler staebler left a comment

Choose a reason for hiding this comment

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

Update the PR title and the commit message to reflect that this is for vSphere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Networking must never be nil. So rather than ignore a nil, at least add an error for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Overlap is not the right term. Overlap is used for sets. What you want to say is that the machine CIDR must contain the VIP.

Suggested change
allErrs = append(allErrs, field.Invalid(fldPath.Child("apiVIP"), p.APIVIP, "must overlap with the machine CIDRs provided"))
allErrs = append(allErrs, field.Invalid(fldPath.Child("apiVIP"), p.APIVIP, "must be contained within one of the machine networks"))

Copy link
Contributor

Choose a reason for hiding this comment

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

Do all of this contain checking in validateVIPs. That function is already parsing the string into an IP, albeit within the call to validate.IP.

This makes it a bit more complicated for the call to validateVIPs from ValidateForProvisioning. But I would argue that ValidateForProvisioning should not be doing full validation of the VIPs. It should only be validating that the VIPs have been set. If the VIPs are set, then the full validation would have been done doing the initial validation of the install config. If the VIPs are not set, then validateVIPs will fail and will not have anything more to validate beyond that the VIPs are missing anyway. What do you think, @patrickdillon (#3372)?

Copy link
Contributor

Choose a reason for hiding this comment

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

This makes it a bit more complicated for the call to validateVIPs from ValidateForProvisioning. But I would argue that ValidateForProvisioning should not be doing full validation of the VIPs. It should only be validating that the VIPs have been set. If the VIPs are set, then the full validation would have been done doing the initial validation of the install config. If the VIPs are not set, then validateVIPs will fail and will not have anything more to validate beyond that the VIPs are missing anyway. What do you think, @patrickdillon (#3372)?

I agree we should move this logic to validateVIPs. And if I understand correctly, I am fine to refactor ValidateForProvisioning so it only checks for the presence of the required VIPs fields and does not do the full validation.

To frame the discussion a bit more for @rna-afk vSphere UPI was released before IPI. When UPI was released VIPs were not required in the platform, but they are required for IPI. We cannot require VIPs in the platform as it would break backwards compatibility with UPI. Therefore we added the check here in ValidateForProvisioning to distinguish the validation only run for IPI.

If I understand @staebler's concern correctly, we want to avoid a slippery slope of allowing validation creeping in here, where it does not really belong.

Comment on lines 45 to 46
Copy link
Contributor

@patrickdillon patrickdillon Mar 16, 2021

Choose a reason for hiding this comment

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

Performance is not going to be an issue here (MachineNetwork will be a very small array) so I would opt for readability rather than optimizing performance. I would suggest losing the boolean flags like apiVIPOverlap and creating a helper function that returns bool if the MachineNetwork contains the VIP. You would call this helper function where you check the flags.

@rna-afk rna-afk changed the title Bug 1918469: Check if VIP IPs overlap with machine CIDR provided Bug 1918469: Check if VIP IPs overlap with machine CIDR provided during vsphere installation Mar 16, 2021
@rna-afk rna-afk force-pushed the vsphere_apivip_validation branch 2 times, most recently from 829b1dc to cebb327 Compare March 16, 2021 17:42
Copy link
Contributor

Choose a reason for hiding this comment

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

if network == nil {
   // add an error and return. This should not happen, so let's not make the function more complex with nested ifs to cover the case.
}

// deal with the happy scenario first
if p.APIVIP != "" {
    ip := net.ParseIP(p.APIVIP)
    if ip != nil {
        if !validateIPInCIDR(ip, network.MachineNetwork) {
            // add error
        }
    } else {
        // add error
    }
} else {
    // add error
}

// repeat for IngressVIP

Comment on lines 65 to 71
Copy link
Contributor

Choose a reason for hiding this comment

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

This check should not be done here. In ValidateForProvisioning, the two VIPs are required. The suggestion that I was trying to make was to only validate that both VIPs were provided here rather than doing all of the other validation for the VIPs, since the other validation will necessarily have already been done.

Suggested change
if strings.Join([]string{p.APIVIP, p.IngressVIP}, "") != "" {
allErrs = append(allErrs, validateVIPs(p, network, fldPath)...)
}
if p.APIVIP == "" {
// add error
}
if p.IngressVIP == "" {
// add error
}

@rna-afk rna-afk force-pushed the vsphere_apivip_validation branch from cebb327 to 679eb89 Compare March 16, 2021 18:45
Comment on lines 75 to 76
Copy link
Contributor

Choose a reason for hiding this comment

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

validateIPinCIDR -> ipInNetwork
nit: comment could be be slightly improved `ipInNetwork returns true if the given..."

@rna-afk rna-afk force-pushed the vsphere_apivip_validation branch from 679eb89 to ec46621 Compare March 16, 2021 19:14
Copy link
Contributor

@staebler staebler left a comment

Choose a reason for hiding this comment

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

Sorry to keep piling on with the nits.

Copy link
Contributor

Choose a reason for hiding this comment

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

network is unused now.

Suggested change
func ValidateForProvisioning(p *vsphere.Platform, network *types.Networking, fldPath *field.Path) field.ErrorList {
func ValidateForProvisioning(p *vsphere.Platform, fldPath *field.Path) field.ErrorList {

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ipInNetwork return true if the given ip is within the machine CIDRs.
// ipInNetwork return true if the given ip is within one of the machine networks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
allErrs = append(allErrs, field.Required(fldPath.Child("apiVIP"), "must specify a VIP for API"))
allErrs = append(allErrs, field.Required(fldPath.Child("apiVIP"), "must specify both API and Ingress VIPs when specifying either"))

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
allErrs = append(allErrs, field.Required(fldPath.Child("ingressVIP"), "must specify a VIP for Ingress"))
allErrs = append(allErrs, field.Required(fldPath.Child("ingressVIP"), "must specify both API and Ingress VIPs when specifying either"))

@rna-afk rna-afk force-pushed the vsphere_apivip_validation branch from ec46621 to 13a5ba5 Compare March 17, 2021 00:56
Copy link
Contributor

@staebler staebler left a comment

Choose a reason for hiding this comment

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

Looks good. Just need to make the unit test expectations match the reality of the recent changes.

If the machineCIDR is specified by the user during cluster
installation in vsphere, the VIP IPs provided must be within
the CIDRs provided and the installation fails if they
do not.

Adding a validation check to see if the CIDR is provided and if so,
checks to see if the IPs are within any of the machine CIDRs provided.
Changes are local to vsphere.
@rna-afk rna-afk force-pushed the vsphere_apivip_validation branch from 13a5ba5 to 5d8bba0 Compare March 17, 2021 12:35
@staebler
Copy link
Contributor

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 17, 2021
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: staebler

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 Mar 17, 2021
@staebler
Copy link
Contributor

/test e2e-vsphere
/test e2e-vsphere-upi
/hold for vsphere tests

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 17, 2021
@rna-afk
Copy link
Contributor Author

rna-afk commented Mar 19, 2021

/retest

@staebler
Copy link
Contributor

vsphere e2e jobs passed.
/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 19, 2021
@openshift-bot
Copy link
Contributor

/retest

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

11 similar comments
@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-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-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-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-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-bot
Copy link
Contributor

/retest

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

@staebler
Copy link
Contributor

These changes are only for vSphere.
/override ci/prow/e2e-aws-upgrade

@openshift-ci-robot
Copy link
Contributor

@staebler: Overrode contexts on behalf of staebler: ci/prow/e2e-aws-upgrade

Details

In response to this:

These changes are only for vSphere.
/override ci/prow/e2e-aws-upgrade

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-bot
Copy link
Contributor

/retest

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

5 similar comments
@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-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-bot
Copy link
Contributor

/retest

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

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 21, 2021

@rna-afk: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws-workers-rhel7 5d8bba0 link /test e2e-aws-workers-rhel7

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.

@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 f1a1e5a into openshift:master Mar 21, 2021
@openshift-ci-robot
Copy link
Contributor

@rna-afk: All pull requests linked via external trackers have merged:

Bugzilla bug 1918469 has been moved to the MODIFIED state.

Details

In response to this:

Bug 1918469: Check if VIP IPs overlap with machine CIDR provided during vsphere installation

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.

6 participants