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

discoverspaces: Get subnets when provider doesn't support space discovery #7067

Merged
merged 8 commits into from Mar 14, 2017

Conversation

babbageclunk
Copy link
Contributor

Description of change

At the moment we only get subnets from the provider if it supports space discovery, but it would be useful to have them for providers that support networking (even if we don't have them tagged with a space). That will allow us to use them to set up ingress rules when a cross-model relation is created.

Change the discover spaces worker to collect subnets (with no associated spaces) if the provider doesn't support space discovery. Also change the AddSubnets API call to allow subnets without a space, and change the ListSubnets API method and command to handle empty space.

Rewrite the worker tests to not use JujuConnSuite.

QA steps

  • Bootstrap on AWS.
  • Run juju subnets to verify that subnets have been imported in by the discoverspaces worker - they'll come back with a blank space tag.

@babbageclunk
Copy link
Contributor Author

!!build!!

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.

Not 100% on the non-transactional nature of the discovery but it seems that's an existing issue

@@ -55,7 +55,7 @@ func NewAddSubnetsCache(api NetworkBacking) *addSubnetsCache {
// up in the cache (or populates the cache if empty).
func (cache *addSubnetsCache) validateSpace(spaceTag string) (*names.SpaceTag, error) {
if spaceTag == "" {
return nil, errors.Errorf("SpaceTag is required")
return nil, nil
Copy link
Member

Choose a reason for hiding this comment

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

Would be great if "" were a valid space name.
That would require a change to the names.v2 package though. But it would avoid all the special case code in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll put a TODO in for this. Maybe linked to a bug?

if err != nil {
return errors.Trace(err)
}
stateSubnets, err := facade.ListSubnets(params.SubnetsFilters{})
var addSubnetsArgs params.AddSubnetsParams
collectMissingSubnets(&addSubnetsArgs, "", stateSubnetIds, subnets)
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 really needs to be server side - it is not transactional as is.
But it seems the existing code suffers from the same problem.....

jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"gopkg.in/juju/names.v2"
//"gopkg.in/juju/names.v2"
Copy link
Member

Choose a reason for hiding this comment

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

delete me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup

cf.addSubnetsCallback()
}
return cf.API.AddSubnets(args)
coretesting.BaseSuite
Copy link
Member

Choose a reason for hiding this comment

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

yay!

@@ -297,3 +296,44 @@ func (dw *discoverspacesWorker) addSubnetsFromArgs(addSubnetsArgs params.AddSubn

return nil
}

func (dw *discoverspacesWorker) getStateSubnets() (set.Strings, error) {
Copy link
Member

Choose a reason for hiding this comment

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

can we call this getModelSubnets()
let's not leak the state.State abstraction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@jameinel
Copy link
Member

jameinel commented Mar 3, 2017 via email

@jameinel
Copy link
Member

jameinel commented Mar 3, 2017 via email

Rearrange to add a path where we just get subnets when space discovery
isn't supported by the provider. Extract code to get existing
subnets and collect subnets that need to be added into functions that
can be reused from the subnet discovery.
It was getting very tricky to add new tests for other cases using the
full API and dummy provider. Rework the tests to use a fake API facade
and fake provider that we can inject data and errors into more easily.
If the provider doesn't support space discovery, we still add
subnets (with no space tag). This enables setting up ingress rules for
cross-model relations.
@babbageclunk
Copy link
Contributor Author

!!build!!

Subnets obtained from providers with no space discovery will have blank
space tags - the API and client need to handle that.
This will enable simplifying the discover spaces API. At the moment the
API requests these from the provider itself. It has a lot of extra
complexity for cross-checking the sent subnet information with the details
queried from the provider. This makes sense for the API underpinning
the `juju add-subnet` command, where we want the user to provide either
the provider id or the CIDR, and need to fill in the other fields. But
it's very confusing to make the discover spaces worker go through the
same path, when it has all the necessary info from the provider already.
Implemented the method standalone rather than using
networkingcommon.AddSubnets. That has far more cleverness than is needed
for this case and it overcomplicated how this worker behaves in tests.
@babbageclunk
Copy link
Contributor Author

!!build!!

@babbageclunk
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Mar 14, 2017

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

@jujubot jujubot merged commit 7c2469e into juju:develop Mar 14, 2017
@babbageclunk babbageclunk deleted the discover-subnets-tests branch March 20, 2017 07:03
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