Fix validation for firstConsecutiveStaticIP #4209
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ritazh If they are not already assigned, you can assign the PR to them by writing 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 |
@@ -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 != "" { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.go
on the generated apimodel.
acs-engine/test/e2e/runner/cli_provisioner.go
Line 223 in 29ad616
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.
acs-engine/test/e2e/engine/template.go
Lines 283 to 294 in 29ad616
// 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.
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() |
There was a problem hiding this comment.
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...
Closing since we've moved to https://github.com/Azure/aks-engine. @ritazh is this PR still relevant? |
@CecileRobertMichon I think this PR was created to address a failed e2e test. We can revisit this if the issue comes up again. Thanks! |
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:
Release note: