Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state: add AttachStorage to AddApplicationArgs #7322

Conversation

axw
Copy link
Contributor

@axw 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 Outdated
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

c.Assert(err, jc.ErrorIsNil)
c.Assert(app2Units, gc.HasLen, 1)

// Now attach the storage to the second unit.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Name: "secondwind",
Series: app.Series(),
Charm: ch,
Storage: map[string]state.StorageConstraints{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for swapping the order of the switch values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Support attaching existing storage to the first
unit when deploying an application.
@axw axw force-pushed the state-addapplication-attachstorage branch from bcd764e to fc661da Compare May 12, 2017 06:00
@axw
Copy link
Contributor Author

axw commented May 12, 2017

$$merge$$

@jujubot
Copy link
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants