Skip to content

Commit

Permalink
Fixes comments for correct API version and fixes various variable
Browse files Browse the repository at this point in the history
declarations.

A warning is now logged if a subnet is detected in more than one space,
though it should never happen.
  • Loading branch information
manadart committed Feb 6, 2020
1 parent c787be5 commit 2909c81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apiserver/facades/agent/provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ type ProvisionerAPIV9 struct {
*ProvisionerAPIV10
}

// ProvisionerAPIV9 provides v9 of the provisioner facade.
// ProvisionerAPIV10 provides v10 of the provisioner facade.
// It returns a new form of ProvisioningInfo that
// supports multiple space constraints.
type ProvisionerAPIV10 struct {
Expand Down
12 changes: 8 additions & 4 deletions apiserver/facades/agent/provisioner/provisioninginfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (api *ProvisionerAPI) ProvisioningInfo(args params.Entities) (params.Provis

func (api *ProvisionerAPI) getProvisioningInfo(m *state.Machine, env environs.Environ) (*params.ProvisioningInfoV10, error) {
var err error
result := params.ProvisioningInfoV10{}
var result params.ProvisioningInfoV10

if result.ProvisioningInfoBase, err = api.getProvisioningInfoBase(m, env); err != nil {
return nil, errors.Trace(err)
Expand Down Expand Up @@ -156,7 +156,7 @@ func (api *ProvisionerAPI) getProvisioningInfoBase(
return result, errors.Annotate(err, "cannot get controller configuration")
}

var jobs = m.Jobs()
jobs := m.Jobs()
result.Jobs = make([]model.MachineJob, len(jobs))
for i, job := range jobs {
result.Jobs[i] = job.ToParams()
Expand Down Expand Up @@ -299,7 +299,7 @@ func (api *ProvisionerAPI) machineTags(m *state.Machine, jobs []model.MachineJob
}

func (api *ProvisionerAPI) machineSpaceTopology(m *state.Machine) (params.ProvisioningNetworkTopology, error) {
topology := params.ProvisioningNetworkTopology{}
var topology params.ProvisioningNetworkTopology

cons, err := m.Constraints()
if err != nil {
Expand All @@ -325,7 +325,11 @@ func (api *ProvisionerAPI) machineSpaceTopology(m *state.Machine) (params.Provis
subnetIDs := make([]string, 0, len(subnetsAndZones))
for sID, zones := range subnetsAndZones {
// We do not expect unique provider subnets to be in more than one
// space, so no keys will be overwritten by subsequent spaces.
// space, so no subnet should be processed more than once.
// Log a warning if this happens.
if _, ok := topology.SpaceSubnets[sID]; ok {
logger.Warningf("subnet with provider ID %q found is present in multiple spaces", sID)
}
topology.SubnetAZs[sID] = zones
subnetIDs = append(subnetIDs, sID)
}
Expand Down

0 comments on commit 2909c81

Please sign in to comment.