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

[dev] Augment application model with expose parameters #11963

Conversation

achilleasa
Copy link
Contributor

Description of change

This PR is part of the work for enhancing the juju expose command to target endpoints and/or allow operators to specify the spaces/CIDRs that should be able to access the application once exposed.

The PR augments the application model with the following new fields:

  • ExposedEndpoints: tracks the application endpoints whose ports will be made accessible once the app is exposed.
  • ExposeToSpaceIDs: a list of space IDs which should be able to access the application ports once the app is exposed (note: the operator will provide space names to the CLI; internally they are stored as space IDs)
  • ExposeToCIDRs: a list of CIDRs which should be able to access the application ports once the app is exposed.

As part of this set of changes, the SetExposed method of the application model has been modified to accept (and validate) the above new set of fields.

The CLI updates and related API changes for actually populating/querying the new fields will be tacked via a separate PR.

QA steps

Just check that juju expose X works. The new fields are not used for now so there are no visible functional changes introduced by this PR.

The new version includes the bits for exporting the expose-related
parameters that will be introduced in the following commits.
@achilleasa achilleasa force-pushed the dev-augment-application-model-with-expose-parameters branch 2 times, most recently from 40b271e to d86c94e Compare September 3, 2020 12:10
Copy link
Member

@manadart manadart left a comment

Choose a reason for hiding this comment

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

Looks good.

state/application.go Show resolved Hide resolved
@achilleasa achilleasa force-pushed the dev-augment-application-model-with-expose-parameters branch from d86c94e to c3f08ba Compare September 3, 2020 14:45
@achilleasa
Copy link
Contributor Author

$$merge$$

1 similar comment
@achilleasa
Copy link
Contributor Author

$$merge$$

@achilleasa achilleasa force-pushed the dev-augment-application-model-with-expose-parameters branch from c3f08ba to eef923b Compare September 3, 2020 16:24
@achilleasa
Copy link
Contributor Author

@manadart I just realized that I forgot the omitempty bits for the bson tags. I have force-pushed to get those landed.

@achilleasa
Copy link
Contributor Author

$$merge$$

@achilleasa achilleasa force-pushed the dev-augment-application-model-with-expose-parameters branch from eef923b to ea254f7 Compare September 3, 2020 16:37
// application that should be reachable once the application is exposed. An
// empty returned list means that all endpoints should be reachable.
func (a *Application) ExposedEndpoints() []string {
if len(a.doc.ExposedEndpoints) == 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@manadart I have also added these guard blocks to avoid breaking errors that check for a nil []string and not for a []string(nil). As an alternative, I could patch setExposed to check for nil args and generate $unset commands but I think it's better if we see the fields in the application docs even if they are empty.

@achilleasa
Copy link
Contributor Author

$$merge$$

@achilleasa
Copy link
Contributor Author

$$merge$$ (unrelated failure for APIAddressUpdaterSuite.TestAddressChangeEmpty)

@achilleasa achilleasa force-pushed the dev-augment-application-model-with-expose-parameters branch from ea254f7 to 930bce0 Compare September 3, 2020 17:28
Comment on lines +695 to +697
// The default space entry has an empty string as its
// key but is not a valid endpoint.
if _, found := bindings[endpoint]; !found || endpoint == "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yet another thing that I missed and fixed via force-pushing. The "" endpoint represents the default space binding but it is not a valid endpoint name ;-)

Copy link
Member

Choose a reason for hiding this comment

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

Oof. I should have seen that.

@achilleasa
Copy link
Contributor Author

$$merge$$

@jujubot jujubot merged commit c3b386f into juju:develop Sep 3, 2020
@achilleasa achilleasa deleted the dev-augment-application-model-with-expose-parameters branch September 3, 2020 20:27
jujubot added a commit that referenced this pull request Sep 7, 2020
…pose-parameters

#11973

# Description of change

Due to a change in the approach for modeling expose parameters, this PR revises the changes from #11963 so that we can specify a list of spaces and/or CIDRs that can access exposed application ports on a **per endpoint** basis.

## QA steps

None needed. The `exposed` flag is still being set as usual and that's the only thing that the firewall worker considers when generating ingress rules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants