The trouble with EnvironProvider.InstanceId()
roger peppe
roger.peppe at canonical.com
Fri Mar 15 16:32:25 UTC 2013
On 15 March 2013 16:06, William Reade <william.reade at canonical.com> wrote:
> On Fri, 2013-03-15 at 15:48 +0000, roger peppe wrote:
>> Perhaps rather than providing Environ.CurrentInstanceId and
>> comparing that, it might be cleaner to provide
>> a environs.Instance.IsCurrent method to determine if the given
>> instance is the one we're running on. In most implementations
>> it would probably do the same thing under the hood.
>>
>> Thoughts?
>
> If machine 0 has no instance id, it hasn't yet started provisioning;
> therefore, there must be only one instance in the environment. So, the
> provisioner can just check for machine 0 having no instance id; if so,
> it can get the *only* instance in the environment with AllInstances,
> (barf if count != 1; who knows what's going on, if it's transient it'll
> probably be ok when the task is restarted), and set machine 0's instance
> id to that one's id. That way we get to use Instance.InstanceId() in all
> cases, and don't need to worry about new methods or implementation
> differences at all. Sane?
I thought of that solution, but I think we have to deal reasonably with the
case that a previous incarnation of the environment has not been
destroyed correctly and there are instances still hanging around
from then.
We could just punt on that case though, in which case it's
a fine solution.
More information about the Juju-dev
mailing list