Add remote spaces #12

Merged
merged 6 commits into from May 8, 2017

Conversation

Projects
None yet
2 participants
Member

babbageclunk commented May 5, 2017

These allow adding spaces and bindings to remote applications, which are needed for cross-model relations.

babbageclunk added some commits May 5, 2017

Refactored remote application import
This matches the approach used for subnets, storage and remote spaces.
Add remote spaces and subnets
Hang spaces and bindings off remote applications.

axw approved these changes May 5, 2017

LGTM. I wonder if we could get away with reusing the existing subnet de/serialisation within remote spaces. Not sure that we'll need any remote-specific bits for subnets?

@@ -94,7 +94,7 @@ func importRemoteEndpoints(sourceMap map[string]interface{}) ([]*remoteEndpoint,
}
func importRemoteEndpointList(sourceList []interface{}, importFunc remoteEndpointDeserializationFunc) ([]*remoteEndpoint, error) {
- result := make([]*remoteEndpoint, 0, len(sourceList))
+ var result []*remoteEndpoint
@axw

axw May 5, 2017

Member

why change? seemed fine as it was: optimised for the usual (success) case

@babbageclunk

babbageclunk May 7, 2017

Member

One of my tests showed that starting with a nil list of endpoints and roundtripping it would result in an empty slice, which seemed a bit nasty. This might be overly finicky. Or I could get the best of both worlds by adding an if sourceList == nil { return nil, nil } at the start.

@axw

axw May 8, 2017

Member

No big deal either way, I was just wondering. Your choice.

remotespace.go
+ return nil, errors.Annotatef(err, "remote space %d v%d schema check failed", i, version)
+ }
+ valid := coerced.(map[string]interface{})
+ subnet, err := newRemoteSpaceFromValid(valid, version)
@axw

axw May 5, 2017

Member

s/subnet/space/ ?

@babbageclunk

babbageclunk May 7, 2017

Member

Oops, my cut'n'paste is showing! Thanks.

Member

babbageclunk commented May 7, 2017

I didn't reuse subnets because I got spooked by the differences between basic subnets and the one we're using:

  • single vs multiple availability zones
  • extra fields SpaceName, AllocatableIPHigh, AllocatableIPLow
  • missing ProviderSpaceId

But I think that was wrong - maybe the right thing to do is to not worry about the extra fields, add a new version for subnet that adds ProviderSpaceId and AvailabilityZones (as a []string), and update the existing import/export code that deals with subnets to work with the updated fields (just putting the single AZ from state into a slice with one element). Does that sound reasonable?

From my reading of the release list it looks like the subnets V2 format was introduced in 2.2, which isn't out yet, so I might not need to introduce a new subnet version. I guess it's actually pretty easy to though, so I think I'll do it as V3 just to keep it cleaner.

Member

axw commented May 8, 2017

But I think that was wrong - maybe the right thing to do is to not worry about the extra fields, add a new version for subnet that adds ProviderSpaceId and AvailabilityZones (as a []slice), and update the existing import/export code that deals with subnets to work with the updated fields (just putting the single AZ from state into a slice with one element). Does that sound reasonable?

Sounds reasonable to me.

babbageclunk added some commits May 8, 2017

Subnet V3: add provider space id + multi-zones
In order to represent subnets in remote spaces, add ProviderSpaceId and
change AvailabilityZone to AvailabilityZones. Being able to have a
subnet be in multiple AZ is a limitation we want to remove from the
state subnet.
Reuse Subnet in RemoteSpace
Added the needed fields to Subnet rather than creating a new, slightly
different type.

@babbageclunk babbageclunk changed the title from Add remote spaces and remote subnets to Add remote spaces May 8, 2017

Member

babbageclunk commented May 8, 2017

$$merge$$

Member

babbageclunk commented May 8, 2017

Oh duh.

@axw axw merged commit 8aecdaa into juju:master May 8, 2017

@babbageclunk babbageclunk deleted the babbageclunk:remote-spaces branch May 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment