Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Fix validation for firstConsecutiveStaticIP #4209

Closed
wants to merge 2 commits into from

Conversation

ritazh
Copy link
Member

@ritazh ritazh commented Nov 8, 2018

What this PR does / why we need it: Fix validation for firstConsecutiveStaticIP

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

If applicable:

  • documentation
  • unit tests
  • tested backward compatibility (ie. deploy with previous version, upgrade with this branch)

Release note:

@acs-bot
Copy link

acs-bot commented Nov 8, 2018

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ritazh
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: brendandburns

If they are not already assigned, you can assign the PR to them by writing /assign @brendandburns in a comment when ready.

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

@ghost ghost assigned ritazh Nov 8, 2018
@ghost ghost added the in progress label Nov 8, 2018
@acs-bot acs-bot added the size/L label Nov 8, 2018
@@ -383,6 +383,9 @@ func (dc *deployCmd) validateApimodel() (*api.ContainerService, string, error) {
return nil, "", errors.New("when using the kubernetes orchestrator, must either set useManagedIdentity in the kubernetes config or set --client-id and --client-secret or KeyvaultSecretRef of secret (also available in the API model)")
}
}
if p.MasterProfile != nil && p.MasterProfile.IsVirtualMachineScaleSets() && p.MasterProfile.VnetSubnetID != "" && p.MasterProfile.FirstConsecutiveStaticIP != "" {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should go in the validate.go area, as this validation is only a convenience for acs-engine deploy CLI usage.

Copy link
Member Author

Choose a reason for hiding this comment

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

This logic was originally in validate.go. But as we have seen in e2e tests, what we want to do here is to validate the user-provided apimodel, not the generated apimodel. Since we want to notify the user that we are generating this firstConsecutiveStaticIP for them if they are using custom vnet and VMSS master profile, instead of asking them to provide a value.

When we run e2e tests, cli_provisioner.go calls engine.ParseOutput in template.go which calls apiloader.LoadContainerServiceFromFile(path, true, false, nil) that triggers validate.goon the generated apimodel.

csGenerated, err := engine.ParseOutput(engCfg.GeneratedDefinitionPath + "/apimodel.json")

This causes the e2e tests to fail since the generated apimodel now includes thefirstConsecutiveStaticIP we generated based on the vnetCidr provided by the user.

// ParseOutput takes the generated api model and will parse that into a api.ContainerService
func ParseOutput(path string) (*api.ContainerService, error) {
locale, err := i18n.LoadTranslations()
if err != nil {
return nil, errors.Errorf(fmt.Sprintf("error loading translation files: %s", err.Error()))
}
apiloader := &api.Apiloader{
Translator: &i18n.Translator{
Locale: locale,
},
}
containerService, _, err := apiloader.LoadContainerServiceFromFile(path, true, false, nil)

When we run acs-engine deploy, validateApimodel in deploy.go validates the user-provided apimodel before dc.containerService.SetPropertiesDefaults is called.

acs-engine/cmd/deploy.go

Lines 88 to 91 in 29ad616

if _, _, err := dc.validateApimodel(); err != nil {
log.Fatalf("Failed to validate the apimodel after populating values: %s", err.Error())
}
return dc.run()

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, vlabs/validate.go should only validate user input, not the generated data...

@CecileRobertMichon
Copy link
Contributor

Closing since we've moved to https://github.com/Azure/aks-engine. @ritazh is this PR still relevant?

@ghost ghost removed the in progress label Jan 7, 2019
@ritazh
Copy link
Member Author

ritazh commented Jan 8, 2019

@CecileRobertMichon I think this PR was created to address a failed e2e test. We can revisit this if the issue comes up again. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants