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 implementation of Environs.Network Interface for OpenStack Pr… #7140

Merged
merged 1 commit into from Mar 29, 2017

Conversation

hmlanigan
Copy link
Member

…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

@hmlanigan
Copy link
Member Author

!! testme !!

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

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".

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

probably don't need this to be committed

@hmlanigan
Copy link
Member Author

!! testmeagain !!

Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

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

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")
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated the worker.

// 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)
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

thank you - updated the function.

if err != nil {
return nil, errors.Annotatef(err, "failed to retrieve subnets")
}
if len(subnetIds) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

using Set

@hmlanigan
Copy link
Member Author

!! runtest !!

modelSubnetIds, err := dw.getModelSubnets()
if err != nil {
subnets, err := environ.Subnets(instance.UnknownId, nil)
if err != nil && errors.IsNotSupported(err) {
Copy link
Member

Choose a reason for hiding this comment

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

you don't need the err != nil

…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.
@hmlanigan
Copy link
Member Author

$$ merge $$

@anastasiamac
Copy link
Contributor

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

@hmlanigan
Copy link
Member Author

$$merge$$

@jujubot
Copy link
Collaborator

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 networks-openstack branch March 29, 2017 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants