state: add AttachStorage to AddApplicationArgs #7322

Merged
merged 1 commit into from May 12, 2017

Conversation

Projects
None yet
3 participants
Member

axw commented May 10, 2017

Description of change

Support attaching existing storage to the first unit when deploying an application. When the api/cmd changes are made, this will enable users to juju deploy foo --attach-storage bar/0, attaching existing persistent storage to a new application unit.

QA steps

Smoke test existing attach, since the new stuff is not connected yet:

  1. juju bootstrap aws
  2. juju deploy postgresql --storage pgdata=ebs
  3. juju detach-storage pgdata/0
  4. juju attach-storage postgresql/0 pgdata/0

Documentation changes

None yet.

Bug reference

None.

state/state.go
@@ -993,6 +994,9 @@ func (st *State) AddApplication(args AddApplicationArgs) (_ *Application, err er
if args.Charm == nil {
return nil, errors.Errorf("charm is nil")
}
+ if len(args.AttachStorage) > 0 && args.NumUnits != 1 {
+ return nil, errors.Errorf("AttachStorage is non-empty, but NumUnits is %d", args.NumUnits)
@wallyworld

wallyworld May 12, 2017

Owner

Better to word the message to tell the user what the allowed value is, eg
...., is non-empty, but NumUnits is 23, should be 1

@axw

axw May 12, 2017

Member

Nobody should ever see this (apiserver and api client, and cmd, will all check this, and the cmd provides a nicer error message). Nevertheless I'll do it, doesn't hurt.

state/storage_test.go
+ c.Assert(err, jc.ErrorIsNil)
+ c.Assert(app2Units, gc.HasLen, 1)
+
+ // Now attach the storage to the second unit.
@wallyworld

wallyworld May 12, 2017

Owner

this comment is wrong

@axw

axw May 12, 2017

Member

fixed

+ Name: "secondwind",
+ Series: app.Series(),
+ Charm: ch,
+ Storage: map[string]state.StorageConstraints{
@wallyworld

wallyworld May 12, 2017

Owner

Is this needed here - AttachStorge contains the storage to add.
Actually, what happens when there is a conflict between Storage and AttachStorage

@axw

axw May 12, 2017

Member

Storage defines how to create storage for new units; each storage constraint contains a Count. We'll create Count less the number of storage instances in AttachStorage (for the corresponding charm storage name) for the first unit, and the full Count for subsequent units.

e.g. if I do juju deploy ceph-osd --storage osd-devices=3,100G --attach-storage osd-devices/0, we'll create and attach two new osd-devices storage instances, and attach the existing osd-devices/0, to the first unit. If I then juju add-unit ceph-osd, three new storage instances will be created and attached to the new unit.

@@ -1890,93 +1890,105 @@ func machineStorageParamsForStorageInstance(
filesystemAttachments := make(map[names.FilesystemTag]FilesystemAttachmentParams)
switch storage.Kind() {
- case StorageKindBlock:
- volumeAttachmentParams := VolumeAttachmentParams{
+ case StorageKindFilesystem:
@wallyworld

wallyworld May 12, 2017

Owner

any reason for swapping the order of the switch values?

@axw

axw May 12, 2017

Member

that would be for the fallthrough at the end of the first case

state: add AttachStorage to AddApplicationArgs
Support attaching existing storage to the first
unit when deploying an application.
Member

axw commented May 12, 2017

$$merge$$

Contributor

jujubot commented May 12, 2017

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

@jujubot jujubot merged commit dcb30cb into juju:feature-persistent-storage May 12, 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