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
SettingsAddress should take the private-address from the default binding #7707
SettingsAddress should take the private-address from the default binding #7707
Conversation
…ing space, not the machines private address
Bootstrapped a controller from scratch - could not reproduce the issue with a patched version. juju run --unit memcached/0 'relation-get -r |
// the unit, but if this is a cross-model relation then it will be the | ||
// public address. If this is cross-model and there's no public | ||
// address for the unit, return an error. | ||
// of this relation. Generally this will be the address of the unit in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can rephrase the whole comment a little bit.
If a default space binding is specified, then this address will be a primary address of the unit in the default binding space. Otherwise, it is less well-defined and private address logic is used to find a value for this setting. If the relation is a cross-model relation then public address of the unit is returned if present or an error indicating that it is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we can guarantee a primary-address here though. We are taking the first one ([0]) in an array of addresses.
if !ok || len(info.NetworkInfos) == 0 || len(info.NetworkInfos[0].Addresses) == 0 { | ||
privateAddress, err := unit.PrivateAddress() | ||
if err == nil { | ||
logger.Warningf("Can't find an address for default binding space %q, falling back to units' private address %q", space, privateAddress.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot find an address in a default binding space, a unit's private address will be used instead.
Would a better test for this be to deploy 2 applications to the same machine, with inverted spaces? eg:
By doing the bidirectional test, you know that at least one of them cannot be the machine's private address. I think you also need to do a test that the app1's address is in space-a, and the app2's address is in space-b. |
@@ -482,7 +483,26 @@ func (ru *RelationUnit) SettingsAddress() (network.Address, error) { | |||
if crossmodel, err := ru.relation.IsCrossModel(); err != nil { | |||
return network.Address{}, errors.Trace(err) | |||
} else if !crossmodel { | |||
return unit.PrivateAddress() | |||
space, err := unit.GetSpaceForBinding("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels big enough that we should probably pull it out into a separate helper function (possibly exported for direct testing.)
Also, this shouldn't be the default space (I think). I think it should be the space for the binding on this end of the relation.
for example, if you do:
juju deploy app1 --space "bar endpt1=foo"
then
juju relate app1:endpt1 app2
should expose 'foo' as the private address, while if you do:
juju relate app1:endpt2 app3
that should expose 'bar' as the private address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the right value is:
ru.endpoint.Relation.Name
(it embeds, so it might also just be ru.endpoint.Name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this, we probably need more tests, including: juju deploy app --space "1 A=2 B=3"
and then various relations between those and other applications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this shouldn't be the default space (I think). I think it should be the space for the binding on this end of the relation.
Terminology-wise I think we should have a good (and short) way to say that. I agree that we should mention the side as well.
Here we have:
"default option for any interfaces not specified"
"default-space"
https://jujucharms.com/docs/2.2/charms-deploying#deploying-to-spaces
I used the following instead:
a default space binding ~ when talking about a binding and the fact that we have an ability to specify a default binding for all endpoints of an application for which there is no explicit binding;
a default binding space ~ when talking about a space specifically, not a binding, i.e. "a space that I have used in a default binding".
The term "default space" is kind of confusing: one might think that this space can be applied bundle-wise. I think this is something that could be added as a model property (not sure if it fits into the current data model we have) - any charms without a default binding would get one from a model property. The problem is that not all providers support network spaces. We have a workaround for that with yaml aliases but this gets cumbersome as we have to specify that for all charms.
|
Status: merge request accepted. Url: http://ci.jujucharms.com/job/github-merge-juju |
Description of change
SettingsAddress must work in the same way as unit-get private-address - that is be space aware and take the address from the space for the default binding, not the machine PrivateAddress
QA steps
In an environment with spaces, deploy an app "app1" with multiple spaces and default binding set to a space NOT containing the machines' private address.
Deploy app "app2" and relate it to app1.
Then:
Documentation changes
None
Bug reference
https://bugs.launchpad.net/juju/+bug/1708492