Make storage detachable/attachable #7186

Merged
merged 4 commits into from May 2, 2017

Conversation

Projects
None yet
3 participants
Member

axw commented Mar 31, 2017

Description of change

When detaching storage from a unit, we now
leave the storage in the model, and just
clear the storage instance's ownership. The
storage can then be attached to another unit
using the new State.AttachStorage method.
Hook up the attach-storage backend so it calls
State.AttachStorage.

The existing model storage cleanups have been
replaced with one that destroys storage
instances, rather than volumes and filesystems.
The machine storage will be destroyed as a
consequence.

QA steps

  1. juju bootstrap aws
  2. juju deploy storagetest -n2
  3. juju add-storage storagetest/0 disks=ebs
    (wait)
  4. juju detach-storage disks/0
  5. juju attach-storage storagetest/1 disks/0
    (wait - should fail because storagetest/0 and storagetest/1 are in different AZs)
  6. juju detach-storage disks/0
  7. juju add-machine zone=(same zone as storagetest/0's machine)
  8. juju add-unit storagetest --to (machine ID from step 7)
  9. juju attach-storage storagetest/2 disks/0
    (wait - should attach cleanly)
  10. juju destroy-controller -y aws-...

Documentation changes

When this branch lands into develop, after 2.2 is released, we need to document detach-storage and attach-storage in the devel docs.

Bug reference

https://bugs.launchpad.net/bugs/1592887

There's a lot of txn asserts being used, but it seems there's not a lot of concurrent access test coverage? Maybe add a test or two with txn hooks to test the correct behaviour?

apiserver/application/application.go
- storage, err := common.UnitStorage(api.backend, unit.UnitTag())
+ storage, err := storagecommon.UnitStorage(api.backend, unit.UnitTag())
+ if err != nil {
+ return nil, err
@wallyworld

wallyworld Mar 31, 2017

Owner

i guess Trace(err) although in this method it's a bit hit and miss

@axw

axw Mar 31, 2017

Member

done

@@ -57,6 +58,10 @@ type StorageInterface interface {
// BlockDevices returns information about block devices published
// for the specified machine.
BlockDevices(names.MachineTag) ([]state.BlockDeviceInfo, error)
+
+ // UnitStorageAttachments returns the storage attachments for the
+ // identified unit.
@wallyworld

wallyworld Mar 31, 2017

Owner

specified unit

(to be consistent with the comment above and general usage elsewhere)

@axw

axw Mar 31, 2017

Member

sure, though several of the methods above use identified as well :) I've changed them all

state/addmachine.go
+ }
+ for tag, volumeAttachment := range args.volumeAttachments {
+ volumeAttachments = append(volumeAttachments, volumeAttachmentTemplate{
+ tag, volumeAttachment, true,
@wallyworld

wallyworld Mar 31, 2017

Owner

would be nice to have a const ExistingStorage=true and NewStorage=false or something and use the consts instead of true/false

@axw

axw Mar 31, 2017

Member

I've added function local consts to make it clearer.

Owner

wallyworld commented Mar 31, 2017

Also, is it worth adding a feature test or two?

axw added some commits Mar 30, 2017

state: make storage detachable/attachable
When detaching storage from a unit, we now
leave the storage in the model, and just
clear the storage instance's ownership. The
storage can then be attached to another unit.

The existing model storage cleanups have been
replaced with one that destroys storage
instances, rather than volumes and filesystems.
The machine storage will be destroyed as a
consequence.
apiserver/storage: implement {at,de}tach-storage
Update apiserver/storage to call through to the
new State.AttachStorage method from the AttachStorage
API method.
Member

axw commented May 2, 2017

$$merge$$

Contributor

jujubot commented May 2, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 6903556 into juju:feature-persistent-storage May 2, 2017

1 check passed

github-check-merge-juju Built PR, ran unit tests, and tested LXD deploy. Use !!.*!! to request another build. IE, !!build!!, !!retry!!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment