state: introduce DestroyModelParams #7675

Merged
merged 2 commits into from Jul 27, 2017

Conversation

Projects
None yet
3 participants
Member

axw commented Jul 27, 2017

Description of change

We consolidate Model.Destroy and Model.DestroyIncludingHosted
into a single method, Model.Destroy, and introduce the
DestoryModelParams struct to control its behaviour. There are
two fields for now:

  • DestroyHostedModels. If this is true, then the behaviour
    is the same as the removed Model.DestroyIncludingHosted
    method; otherwise the behaviour is the same as the replaced
    Model.Destroy method.
  • DestroyStorage. If this is nil, and there is any persistent
    storage in the model, then destroying the model will fail
    with an error that satisfies state.IsHasPersistentStorageError.
    If the field's value is true, then all storage will be
    destroyed. If the field's value is false, then the storage
    will be released/disassociated from the model/controller.

To implement these changes, we have to extend the cleanup doc
with cleanup-specific arguments.

To check whether storage is persistent in hosted models, we
have had to change various volume and filesystem query functions
to operate on a database, instead of a state object. This
avoids an expensive State.ForModel call.

In a followup we'll extend the API and CLI to force the user to choose
between destroying or releasing storage when using the destroy-model
and destroy-controller commands.

QA steps

  1. juju bootstrap localhost
  2. juju deploy postgresql --storage pgdata=lxd
  3. juju destroy-controller -y localhost --destroy-all-models

Controller should be destroyed, along with storage, as before.

Documentation changes

Not yet.

Bug reference

None.

state/model.go
+ // or released, which we can do in a cleanup. If the user did
+ // not specify either, then we have already added prereq ops
+ // to assert that there is no storage in the model.
+ logger.Debugf("xxx ... %v", *args.DestroyStorage)
@wallyworld

wallyworld Jul 27, 2017

Owner

clean this up?

@axw

axw Jul 27, 2017

Member

oops, thanks

axw added some commits Jul 26, 2017

state: introduce DestroyModelParams
We consolidate Model.Destroy and Model.DestroyIncludingHosted
into a single method, Model.Destroy, and introduce the
DestoryModelParams struct to control its behaviour. There are
two fields for now:

 - DestroyHostedModels. If this is true, then the behaviour
   is the same as the removed Model.DestroyIncludingHosted
   method; otherwise the behaviour is the same as the replaced
   Model.Destroy method.
 - DestroyStorage. If this is nil, and there is any persistent
   storage in the model, then destroying the model will fail
   with an error that satisfies state.IsHasPersistentStorageError.
   If the field's value is true, then all storage will be
   destroyed. If the field's value is false, then the storage
   will be released/disassociated from the model/controller.

To implement these changes, we have to extend the cleanup doc
with cleanup-specific arguments.

To check whether storage is persistent in hosted models, we
have had to change various volume and filesystem query functions
to operate on a database, instead of a state object. This
avoids an expensive State.ForModel call.
Member

axw commented Jul 27, 2017

$$merge$$

Contributor

jujubot commented Jul 27, 2017

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

@jujubot jujubot merged commit a1819d5 into juju:develop Jul 27, 2017

1 check passed

github-check-merge-juju 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