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

Initial support to wire up spaces support for Azure #11983

Merged
merged 1 commit into from Sep 10, 2020

Conversation

wallyworld
Copy link
Member

Description of change

Initial spaces support is added to the Azure provider. The main changes are:

  • use subnets defined by the spaces constraint instead of the hard coded subnet "juju-internal-network"
  • create a network interface per subnet, first one is primary

Drive by fix for the firewaller worker and handling not provisioned errors.

TODO: model network security group for custom networks

QA steps

create a resource group (test-rg) and make a virtual network (test-vn) with some subnets (cidr1, cidr2)
juju bootstrap azure --no-default-model
juju add-model --config network="test-rg/test-vn"

Add some spaces to the model

juju add-space foo cidr1
juju add-space bar cidr2

Add a machine with space constraints

juju add-machine --constraints="spaces=foo,bar"

Use the Azure portal to check that machine is deployed with 2 network interfaces, one for each subnet

Bug reference

https://bugs.launchpad.net/juju/+bug/1891650
https://bugs.launchpad.net/juju/+bug/1892490

@@ -713,54 +720,20 @@ func (env *azureEnviron) createVirtualMachine(
vmDependsOn = append(vmDependsOn, availabilitySetId)
}

// Controller and non-controller machines are assigned to separate
Copy link
Member Author

Choose a reason for hiding this comment

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

moved to networkInfoForInstance

Comment on lines +181 to +224
// No space constraints so use the default network and subnet.
if !constraints.HasSpaces() {
return vnetID, []string{subnetID}, nil
}

// Attempt to filter the subnet IDs for the configured availability zone.
// If there is no configured zone, consider all subnet IDs.
az := availabilityZone
subnetIDsForZone := make([][]network.Id, len(subnetsToZones))
for i, nic := range subnetsToZones {
var subnetIDs []network.Id
if az != "" {
var err error
if subnetIDs, err = network.FindSubnetIDsForAvailabilityZone(az, nic); err != nil {
return "", nil, errors.Annotatef(err, "getting subnets in zone %q", az)
}
if len(subnetIDs) == 0 {
return "", nil, errors.Errorf("availability zone %q has no subnets satisfying space constraints", az)
}
} else {
for subnetID := range nic {
subnetIDs = append(subnetIDs, subnetID)
}
}

// Filter out any fan networks.
subnetIDsForZone[i] = network.FilterInFanNetwork(subnetIDs)
}
logger.Debugf("found subnet ids for zone: %#v", subnetIDsForZone)

/// For each list of subnet IDs that satisfy space and zone constraints,
// choose a single one at random.
subnetIDForZone := make([]network.Id, len(subnetIDsForZone))
for i, subnetIDs := range subnetIDsForZone {
if len(subnetIDs) == 1 {
subnetIDForZone[i] = subnetIDs[0]
continue
}

subnetIDForZone[i] = subnetIDs[rand.Intn(len(subnetIDs))]
}
if len(subnetIDForZone) == 0 {
return "", nil, errors.NotFoundf("subnet for constraint %q", constraints.String())
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Largely copied from openstack provider

Copy link
Member

@ycliuhw ycliuhw left a comment

Choose a reason for hiding this comment

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

lgtm, and I will leave the piece copied from the OpenStack provider to Joe to double-check.

@wallyworld
Copy link
Member Author

$$merge$$

@jujubot jujubot merged commit 81001d1 into juju:develop Sep 10, 2020
@wallyworld
Copy link
Member Author

azure custom subnets

@@ -295,7 +295,7 @@ func FindSubnetIDsForAvailabilityZone(zoneName string, subnetsToZones map[Id][]s
matchingSubnetIDs := set.NewStrings()
for subnetID, zones := range subnetsToZones {
zonesSet := set.NewStrings(zones...)
if zonesSet.Contains(zoneName) {
if zonesSet.Size() == 0 && zoneName == "" || zonesSet.Contains(zoneName) {
Copy link
Member

Choose a reason for hiding this comment

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

I am concerned with the special casing we have introduced here, particularly given that we do not call this with an empty zone name (see subnetsForZone in the Azure provider).

@@ -486,8 +487,21 @@ func (api *ProvisionerAPI) subnetsAndZonesForSpace(machineID string, spaceName s

zones := subnet.AvailabilityZones()
if len(zones) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Here too. Might it not be better to indicate whether AZs confine subnet availability via a method on NetworkingEnviron, which would allow us to design out this special casing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants