Initial implementation of Environs.Network Interface for OpenStack Pr… #7140

Merged
merged 1 commit into from Mar 29, 2017

Conversation

Projects
None yet
5 participants
Member

hmlanigan commented Mar 22, 2017

…ovider.

Updates to goose required to complete.

Please provide the following details to expedite Pull Request review:


Description of change

This is part of the Cross Model Relations work and needed for juju Networking.

environs.Networking is implemented for the OpenStack Provider. Neutron networking will be
supported here, though not Nova networking. Updates will be made once more data is available from goose.

A small bug was fixed in supportsNeutron() as well to make Neutron networking the default if
not OpenStack Endpoints are found.

QA steps

  1. juju bootstrap with an openstack cloud (utilizing neutron networking)
  2. create two models
  3. in model one:
    juju deploy mysql
    juju offer mysql:db hosted-db <-- copy url from results
    juju show-endpoints
  4. in model two:
    juju deploy ghost
    juju consume
    juju add-relation ghost:database hosted-db:db
  5. validate results of juju list-subnets
  6. the neutron security group for the machine mysql is running on should have a rule allowing traffic on port 3306 from the CIDR of the subnet the machine for ghost is running on.
  7. both charms should report a good status

Documentation changes

N/A

Bug reference

N/A

Member

hmlanigan commented Mar 22, 2017

!! testme !!

provider/openstack/provider.go
@@ -648,6 +649,11 @@ func (e *Environ) Bootstrap(ctx environs.BootstrapContext, args environs.Bootstr
func (e *Environ) supportsNeutron() bool {
client := e.client()
endpointMap := client.EndpointsForRegion(e.cloud.Region)
+ if len(endpointMap) == 0 {
+ // In some corner cases the endpoingMap is empty. Default to
@axw

axw Mar 22, 2017

Member

I think you'll only get an empty map back if the client has not authenticated? Probably need to change the order of some code, so that auth happens first.

@hmlanigan

hmlanigan Mar 23, 2017

Member

the 3 places calling supportsNeutron() try to get an authenticated client if the client isn't already.... looks like something else is going on. will investigate. all the goose output of endpoint data i saw did include "network".

@hmlanigan

hmlanigan Mar 23, 2017

Member

It turns out that even though the callers to supportsNeutron() were authenticating the client before calling. The client used by suportsNeutron() was not alway authenticated. There is a bigger question of why that should be looked at? I moved code around so that supportsNeutron() was checking for client authentication for now.

provider/openstack/provider.go
@@ -1003,6 +1009,7 @@ func (e *Environ) StartInstance(args environs.StartInstanceParams) (*environs.St
return nil, errors.Annotate(err, "getting initial networks")
}
usingNetwork := e.ecfg().network()
+ logger.Debugf("ecfg().network() returned (%s)", usingNetwork)
@wallyworld

wallyworld Mar 23, 2017

Owner

probably don't need this to be committed

Member

hmlanigan commented Mar 23, 2017

!! testmeagain !!

A couple of things needed, plus we need to understand what's happening with the supportsNeutron stuff

+
+// Subnets is part of the Networking interface.
+func (n *LegacyNovaNetworking) Subnets(instId instance.Id, subnetIds []network.Id) ([]network.SubnetInfo, error) {
+ return nil, errors.NotSupportedf("nova subnet")
@wallyworld

wallyworld Mar 23, 2017

Owner

If we are going to do this here, then the discover spaces worker will need to be tweaked to handle this error and ignore it, since the worker thinks these methods should work. Add a todo also to the worker to revert the change when nova subnet support is added.
Should also add a test for this case.

@hmlanigan

hmlanigan Mar 28, 2017

Member

updated the worker.

provider/openstack/networking.go
+// empty, in which case all known are returned.
+func (n *NeutronNetworking) Subnets(instId instance.Id, subnetIds []network.Id) ([]network.SubnetInfo, error) {
+ var results []network.SubnetInfo
+ subIdSet := make(map[string]bool)
@wallyworld

wallyworld Mar 23, 2017

Owner

we have a juju/utils/set package which has a strings set implementation which will simplify the code below

@hmlanigan

hmlanigan Mar 23, 2017

Member

thank you - updated the function.

+ if err != nil {
+ return nil, errors.Annotatef(err, "failed to retrieve subnets")
+ }
+ if len(subnetIds) == 0 {
@wallyworld

wallyworld Mar 23, 2017

Owner

This logic can be simplified using the functionality provided by Set. You just need to do a set difference between the set of passed in ids and those obtained by the list subnets call.

@hmlanigan

hmlanigan Mar 28, 2017

Member

using Set

Member

hmlanigan commented Mar 28, 2017

!! runtest !!

worker/discoverspaces/discoverspaces.go
- modelSubnetIds, err := dw.getModelSubnets()
- if err != nil {
+ subnets, err := environ.Subnets(instance.UnknownId, nil)
+ if err != nil && errors.IsNotSupported(err) {
@wallyworld

wallyworld Mar 28, 2017

Owner

you don't need the err != nil

Initial implementation of Environs.Network Interface for OpenStack Pr…
…ovider.

Updates to goose required to complete implementation.
Update Discover Spaces worker for better messaging where Subnets not implemented
for Nova.
In the OpenStack Provider, modify Open()/SetConfig() so environ.clientUnlocked not
overwritten by subsequent SetConfig() calls.
Member

hmlanigan commented Mar 29, 2017

$$ merge $$

Member

anastasiamac commented Mar 29, 2017

I think you may need to have $$merge$$ without spaces...

Member

hmlanigan commented Mar 29, 2017

$$merge$$

Contributor

jujubot commented Mar 29, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 7e402e5 into juju:develop Mar 29, 2017

@hmlanigan hmlanigan deleted the hmlanigan:networks-openstack branch Mar 29, 2017

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