Skip to content

Commit 7b53d41

Browse files
authored
Merge pull request juju#13422 from manadart/2.9-openstack-binding-provisioning
juju#13422 When determining OpenStack networking for instances, we only process the `SubnetsToZones` topology if we have space constraints. This is not correct, because the presence of a non-empty `SubnetsToZones` map already implies that provisioning info created it based on constraints and/or endpoint bindings. The result is that specifying multiple bindings without constraints results in an incorrectly provisioned machine. Here we simple remove the gate on the presence of space constraints, meaning that endpoint bindings (implied by a populated AZ/space topology) will be honoured. ## QA steps On an OpenStack with multiple subnets: - Bootstrap. - Carve out 2 spaces, each with a different subnet. - juju deploy --bind 'space-1 public=space-2' cs:nagios`. - Check that the provisioned machine has 2 network devices. ## Documentation changes None. ## Bug reference https://bugs.launchpad.net/juju/+bug/1943503
2 parents fe456b9 + fe9a466 commit 7b53d41

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

apiserver/facades/agent/provisioner/provisioninginfo.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,9 @@ func (api *ProvisionerAPI) machineSpaces(m *state.Machine,
409409
func (api *ProvisionerAPI) machineSpaceTopology(machineID string, spaceNames []string) (params.ProvisioningNetworkTopology, error) {
410410
var topology params.ProvisioningNetworkTopology
411411

412-
// If there are no space names, or if there is only one space name and
413-
// that's the alpha space.
412+
// If there are no space names, or if there is only one space
413+
// name and that's the alpha space, we don't bother setting a
414+
// topology that constrains provisioning.
414415
if len(spaceNames) < 1 || (len(spaceNames) == 1 && spaceNames[0] == network.AlphaSpaceName) {
415416
return topology, nil
416417
}

provider/openstack/provider.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,11 +1418,12 @@ func (e *Environ) networksForInstance(
14181418
return nil, errors.Trace(err)
14191419
}
14201420

1421-
if !args.Constraints.HasSpaces() {
1421+
if len(args.SubnetsToZones) == 0 {
14221422
return networks, nil
14231423
}
14241424
if len(networks) == 0 {
1425-
return nil, errors.New("space constraints were supplied, but no Openstack network is configured")
1425+
return nil, errors.New(
1426+
"space constraints and/or bindings were supplied, but no Openstack network is configured")
14261427
}
14271428

14281429
// We know that we are operating in the single configured network.
@@ -1452,7 +1453,7 @@ func (e *Environ) networksForInstance(
14521453
subnetIDsForZone[i] = network.FilterInFanNetwork(subnetIDs)
14531454
}
14541455

1455-
/// For each list of subnet IDs that satisfy space and zone constraints,
1456+
// For each list of subnet IDs that satisfy space and zone constraints,
14561457
// choose a single one at random.
14571458
subnetIDForZone := make([]network.Id, len(subnetIDsForZone))
14581459
for i, subnetIDs := range subnetIDsForZone {

provider/openstack/provider_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ var handlerFunc = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request)
530530
// This line is critical, the openstack provider will reject the message
531531
// if you return 200 like a mere mortal.
532532
w.WriteHeader(http.StatusMultipleChoices)
533-
fmt.Fprint(w, `
533+
_, _ = fmt.Fprint(w, `
534534
{
535535
"versions": {
536536
"values": [
@@ -920,11 +920,6 @@ func (s *providerUnitTests) TestNetworksForInstanceWithAZ(c *gc.C) {
920920
siParams := environs.StartInstanceParams{
921921
AvailabilityZone: "eu-west-az",
922922
SubnetsToZones: []map[network.Id][]string{{"subnet-foo": {"eu-west-az", "eu-east-az"}}},
923-
Constraints: constraints.Value{
924-
Spaces: &[]string{
925-
"eu-west-az",
926-
},
927-
},
928923
}
929924

930925
result, err := envWithNetworking(mockNetworking).networksForInstance(siParams, netCfg)

0 commit comments

Comments
 (0)