<div dir="ltr">+1 to using a UUID to identify a universally unique environment. Any other route is just asking for pain and suffering. <div><br></div><div>Ideally there would also be an easy way to change the name of an environment so that if you do end up with two environments that have the same name.... you can just change the name of one of them. Given that the name is just user-friendly decoration, it shouldn't bother anyone to change it, right?</div><div><br></div><div>Finally, it means that you <span style="line-height:1.5">probably</span><span style="line-height:1.5"> </span><span style="line-height:1.5">need to be able to reference an environment by UUID on the CLI (i.e. juju switch <uuid> or juju deploy -e <uuid>). Of course, duplicate names is incompatible with the whole model of our environments.yaml, but I think we were already working on discarding that?</span></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 12, 2015 at 10:09 PM Andrew Wilkins <<a href="mailto:andrew.wilkins@canonical.com">andrew.wilkins@canonical.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Nov 13, 2015 at 10:38 AM Tim Penhey <<a href="mailto:tim.penhey@canonical.com" target="_blank">tim.penhey@canonical.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi William and list,<br>
<br>
I have been alternating between thinking this should be a document or an<br>
initial email. In the end I have gone for email even though this is<br>
likely to be longish.<br>
<br>
Before I get started on multiple environments in Juju controllers, I'd<br>
like to double check on Juju's expectations around named environments.<br>
<br>
Right now, meaning Juju 1.25, Juju environments have names, and UUIDs.<br>
The name is determined by the section in the environments.yaml file of<br>
the user that bootstrapped the Juju environment.<br>
<br>
There exists code in every Juju provider that attempts to determine the<br>
state server instances of an environment. This code is used by bootstrap<br>
to make sure you aren't trying to bootstrap an existing environment. I'm<br>
sure the guts of this came from the early juju days when we didn't have<br>
any cached information about the juju environments.<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>It's a transformation of earlier code that returned API info directly, but the current incarnation does not predate cached info. It needs to be there in case your cached addresses are out of date.</div></div></div><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It appears to me, that there is an implicit assumption in the code that<br>
there will exist only one environment of a particular name for a set of<br>
cloud credentials.<br>
<br>
Is this correct?<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>There should not be an assumption of a single name per cloud credentials, but I think some providers still do make that assumption.</div></div></div><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The next question is a more interesting one. Should this be the case?<br>
<br>
As environments are created, we generate a UUID for it. This is supposed<br>
to be globally unique, and a way to actually discriminate different<br>
environments.<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>Yes, we're meant to be using the UUID to distinguish between environments.</div></div></div><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Consider the situation where Bob and Mary share some cloud credentials.<br>
Both have an environment name defined locally in their environments.yaml<br>
called "ec2" using those same credentials.<br>
<br>
If Bob bootstraps "ec2", then Mary bootstraps "ec2", what should happen?<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>The name is meant to be informational only, and the UUID should be used to uniquely identify (!) the resources for an environment.<br></div><div><br></div><div>It *should* just work. Specifically in the case of ec2, it won't at the moment, because we use security groups to group resources. The security group name is based on environment name, and not UUID. We should be able to fix for new ec2 environments by using the UUID in the security group name. We could also use tags, but for some bizarre reason you specify tags at creation time.</div><div><br></div><div>Another issue with ec2, and possibly others, is the use of storage to record state server instance IDs. I don't think we keep a unique file name for each environment. We should be using tags for identify state server instances anyway, which is what we're now doing in GCE, Azure, OpenStack, possibly others.</div><div><br></div><div>FWIW, I've got multi-env working in the new Azure provider. Each environment is put in a group called "juju-<env-name>-environment-<env-uuid>". Each hosted environment knows the UUID of the controller environment so StateServerInstances does the right thing, among other reasons.</div></div></div><div dir="ltr"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If the answer is "they clash", then this has implications for<br>
environments in Juju controllers as described below.<br>
<br>
If the answer is "they should be independent", I'm fairly sure that Juju<br>
does not do this correctly for at least some, perhaps all, of the providers.<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>I'm pretty confident it works correctly for some of the providers, but as above, definitely not true for all. It works correctly for the new Azure provider, and possibly the old one (can't remember, would need to dig).</div></div></div><div dir="ltr"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Let's for now, assume that the answer is that "they clash" and move on<br>
to multiple environments in juju controllers.<br>
<br>
<br>
When we bootstrap a Juju controller, as the name will be from Juju 1.26,<br>
we will be creating something that can host many environments. The best<br>
practice will be to have real workload environments separate from the<br>
environment that is hosting the machines that manage the Juju API<br>
servers and database. A key here is to make sure that when we bootstrap<br>
a controller, we leave the user in a best practice scenario.<br>
<br>
This means that when we bootstrap a controller, we should create one<br>
environment for managing the controller (the controller environment),<br>
and another empty environment which is the active environment at the end<br>
of bootstrap which the user can immediately start deploying workloads into.<br>
<br>
What we are changing is the connection between the name of the<br>
controller, which is how the user interacts with it, and the names of<br>
the environments inside that controller.<br>
<br>
Lets take the current proposal for 1.26. When I now bootstrap the<br>
controller that I have called "staging" what I get is a controller that<br>
locally is called "staging", and that controller has two environments in<br>
it, "admin" and "mymodel". One problem is that many providers use the<br>
name of the environment to tag or discriminate.<br>
<br>
Now I have the same cloud credentials and a controller called<br>
"production". That controller also wants to create environments called<br>
"admin" and "mymodel". We have now hit the same problem we had before<br>
where we are expecting environment names and cloud credentials to be unique.<br>
<br>
So... one of two things needs to happen:<br>
<br>
1) We enforce the ability of every cloud provider to have multiple<br>
environments of the same name owned by the same cloud credentials by<br>
making sure they use the environment UUID to do the real discrimination.<br>
This has the side effect of no longer being able to determine if an<br>
environment of a given name is already bootstrapped, but perhaps this<br>
check is no longer required in the time of having locally cached<br>
endpoints and environment UUID information.<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>We should do this. We need something unique, a UUID is fitting.</div><div><br></div><div>We should still be able to list state server instances, but it should be based on the UUID of the controller environment (the env with state server machines), not on the name of any environment.</div><div><br></div><div>I think the only reason to check for an existing bootstrap is if the bootstrap with the current UUID partially failed, and left turds behind. Then you should destroy-env --force to clean up.</div></div></div><div dir="ltr"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2) Separate out the Name that is stored in the environment config from<br>
what we use in the model for the "name" of the environment. This would<br>
result in the environment config having names like "production-admin"<br>
and "staging-admin", but when reporting the list of environments to the<br>
user, we really don't want this controller prefix. Right now we have<br>
one value that is used in two places.<br>
<br>
Currently we have no place where we'd store the controller name in the<br>
database model other than the name of the environment itself.<br>
<br>
Worth noting that if we choose (2) above, we need to remember that soon<br>
we'll be able to migrate environments from one controller to another, so<br>
the controller prefix that was added to the environment when it was<br>
created won't necessarily always match the name of the controller that<br>
it is currently running in.<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>Are there some docs on how migration is going to work? It may have implications for work I'm doing with Azure.</div><div><br></div><div>Cheers,</div><div>List</div></div></div><div dir="ltr"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, we have the desire to be able to rename environments. This is not<br>
currently possible, mostly due to the way that the environment names are<br>
used to discriminate cloud resources, or at least group or tag cloud<br>
resources.<br>
<br>
These last two points make me lean more towards (1), but I'd like to<br>
know where people think this may fall down or cause other issues.<br>
<br>
<br>
Thoughts?<br>
<br>
Tim<br>
<br>
--<br>
Juju-dev mailing list<br>
<a href="mailto:Juju-dev@lists.ubuntu.com" target="_blank">Juju-dev@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/juju-dev" rel="noreferrer" target="_blank">https://lists.ubuntu.com/mailman/listinfo/juju-dev</a><br>
</blockquote></div></div>
--<br>
Juju-dev mailing list<br>
<a href="mailto:Juju-dev@lists.ubuntu.com" target="_blank">Juju-dev@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/juju-dev" rel="noreferrer" target="_blank">https://lists.ubuntu.com/mailman/listinfo/juju-dev</a><br>
</blockquote></div>