Merge ~smoser/cloud-init:bug/1712680-maas-use-token-for-check-instance-id into cloud-init:master
| Status: | Needs review |
|---|---|
| Proposed branch: | ~smoser/cloud-init:bug/1712680-maas-use-token-for-check-instance-id |
| Merge into: | cloud-init:master |
| Diff against target: |
170 lines (+86/-21) 2 files modified
cloudinit/sources/DataSourceMAAS.py (+40/-14) tests/unittests/test_datasource/test_maas.py (+46/-7) |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Server Team CI bot | continuous-integration | Approve 6 hours ago | |
| Chad Smith | Approve 6 hours ago | ||
| Ryan Harper | 2017-12-12 | Needs Fixing on 2017-12-13 | |
|
Review via email:
|
|||
Commit Message
MAAS: add check_instance_id based off oauth tokens.
This stores a hash of the OAuth tokens as an 'id' for the maas
datasource. Since new instances get new tokens created and those tokens
are written by curtin into datasource system config this will provide
a way to identify a new "instance" (install).
LP: #1712680
| Scott Moser (smoser) wrote : | # |
PASSED: Continuous integration, rev:cefcd130bfb
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
| Chad Smith (chad.smith) wrote : | # |
I know this is a completely separate direction than you are taking.
It feels a bit like we are gating all cloud-init updates/runs based on whether the instance-id changes. In a world where cloud-init becomes re-entrany (or hotplug handling) should cloud-init grow the ability for people to supplement cloud-init's written content, with more information?
I'm thinking like bookend comments like this.
# begin cloud-init ignore
# end cloud-init ignore
In either case, I'll try deploying a node twice with reboots in between and make sure this only changes on node re-install. It feels like we are working around a problem by relying on instance-id as our gate for rewriting content. Should cloud-init ever accept
| Chad Smith (chad.smith) wrote : | # |
Another question I have is across reboots (same instance) do we worry about MAAS changing network topology between boots? If so, locking network setup permanently until re-deploy would cause breakage
PASSED: Continuous integration, rev:2543c765cba
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
| Ryan Harper (raharper) wrote : | # |
Looking at a deployed node, the instance id is node-<uuid>;
IIUC, upon reboot, the MAAS Datasource url is re-crawled, and in that metadata url, it has an instance-id; and if that matches the 'previous-iid' that's on disk, then we assume it's a reboot of the same instance.
Then, instead of MAAS including the instance-id (node-uuid) bit in the original configuration that's written out to /etc/cloud/
That's pretty neat.
--
Now, w.r.t the code. My first worry was about upgrade. Since we always throw away the obj.pkl until this version; I don't think we'll have to worry about loading an object that doesn't have those internal members; however if someone were to "manually run cloud-init init" again, then I think we have that same issue here. We should handle that just because we're aware of that.
| Ryan Harper (raharper) wrote : | # |
> I know this is a completely separate direction than you are taking.
>
> It feels a bit like we are gating all cloud-init updates/runs based on whether
> the instance-id changes. In a world where cloud-init becomes re-entrany (or
> hotplug handling) should cloud-init grow the ability for people to supplement
> cloud-init's written content, with more information?
>
> I'm thinking like bookend comments like this.
> # begin cloud-init ignore
> # end cloud-init ignore
I'm not sure a book-end sort of comment is going to be sufficient; generally
there are config management engines that handle this sort of thing better.
However, I do think we can look toward creating idempotent config modules which
can check if they need to do anything w.r.t updates to files, versus blind rendering.
>
> In either case, I'll try deploying a node twice with reboots in between and
> make sure this only changes on node re-install. It feels like we are working
> around a problem by relying on instance-id as our gate for rewriting content.
> Should cloud-init ever accept
I think that's generally the design of instance-id; I don't think that's an issue.
In the event we want to react to changes in user-data/metadata then I think the
code that renders based on the metadata will need to handle that it may be called
many times, rather than once-per instance.
| Ryan Harper (raharper) wrote : | # |
> Another question I have is across reboots (same instance) do we worry about
> MAAS changing network topology between boots? If so, locking network setup
> permanently until re-deploy would cause breakage
MAAS , AFAIK, does not change/update metadata (including network configuration) between
deployments of a node. The node is allocated and deployed and remains the same (from a metadata perspective) until the node is released from MAAS for a new deployment.
| Scott Moser (smoser) wrote : | # |
@Chad, @Ryan
We do need to have way to allow user updates to a file without blowing
them away. This is non-trivial for sure.
That said, rendering some things that cloud-init "owns" on first instance
is necessary. If the user had made edits to files on an old instance,
with possibly instance-specific data inside it then it is quite likely
that those modifications are not consistent with the new instance. One
solution we had to this (/etc/hosts, /etc/apt/
the files from a template, and to allow the user to modify the template
source then if they want to make changes that persist across an instance,
they change the template.
network config wasn't really ever meant to be "multi-party updatable", so
this is non-trivial in this case. netplan has some sort of plan for that
(multiple .yaml files in /etc/netplan) but the reality is that it will
still be non-trivial. Multi-party modification of *anything* is non-
trivial.
@Ryan,
I'm not sure weather or not this hits the attribute missing-
bug that we saw in bug 1732917. I'll check to make sure.
Over all, this is a simple-ish fix that does dramatically improve the
state of maas reboot scenario. It does come at the cost of now
requiring the user to "clean" the image if they want to take the image
out of MAAS, but that isn't actually a reality at this point that I'm
aware of.
| Scott Moser (smoser) wrote : | # |
I played a bit and I'm pretty sure this is safe
Heres an example which can be built on,b ut shows store and reload with changing class.
| Ryan Harper (raharper) wrote : | # |
After discussion, the use of self.hash_id is safe because we don't expect a non-none value as we did in other cases of restored object code.
While discussing this in IRC, discovered that self.hash_id isn't set in get_data()
That needs doing and unittests.
Otherwise, it looks good.
- 13e000d... by Scott Moser on 2017-12-13
- 3a3d6fc... by Scott Moser on 2017-12-21
FAILED: Continuous integration, rev:ed4c0c24c1f
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
- 886ad31... by Scott Moser on 2018-01-08
PASSED: Continuous integration, rev:7cef59571b9
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
- c726f64... by Scott Moser on 2018-01-08
PASSED: Continuous integration, rev:f55dd0e0f67
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
- b5264bd... by Scott Moser 11 hours ago
FAILED: Continuous integration, rev:cefe421e2ed
https:/
Executed test runs:
SUCCESS: Checkout
FAILED: Unit & Style Tests
Click here to trigger a rebuild:
https:/
PASSED: Continuous integration, rev:b5264bdb066
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
| Chad Smith (chad.smith) wrote : | # |
+1 just a minor docstr fix request
- ae66049... by Scott Moser 6 hours ago
PASSED: Continuous integration, rev:ae66049ceee
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
Unmerged commits
- ae66049... by Scott Moser 6 hours ago
- b5264bd... by Scott Moser 11 hours ago
- c726f64... by Scott Moser on 2018-01-08
- 886ad31... by Scott Moser on 2018-01-08
- 3a3d6fc... by Scott Moser on 2017-12-21
- 13e000d... by Scott Moser on 2017-12-13
- d47aedd... by Scott Moser on 2017-12-12


no tests, but I'm interested in thoughts.
We could make 'id_hash' a property since ds_cfg gets stored.
Chad I'm interested in your thoughts on this and the unification of storage, how did I affect that?