~ubuntu-branches/ubuntu/vivid/juju-core/vivid-proposed

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/doc/block_commands_operations.txt

  • Committer: Package Import Robot
  • Author(s): Curtis C. Hovey
  • Date: 2015-09-29 19:43:29 UTC
  • mfrom: (47.1.4 wily-proposed)
  • Revision ID: package-import@ubuntu.com-20150929194329-9y496tbic30hc7vp
Tags: 1.24.6-0ubuntu1~15.04.1
Backport of 1.24.6 from wily. (LP: #1500916, #1497087)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
PROBLEM
 
2
=========================
 
3
Customers and stakeholders want to be able to 
 
4
prevent accidental damage to Juju deployments.
 
5
 
 
6
SOLUTION
 
7
=========================
 
8
To prevent running some commands, a concept of commands block was implemented.
 
9
Once the block is switched on, it has to be manually switched off
 
10
to run commands successfully.
 
11
 
 
12
There are currently three types of blocks developed.
 
13
 
 
14
 1. DESTROY_BLOCK blocks destroy-environment command.
 
15
 2. REMOVE_BLOCK blocks destroy-environment as well as all object removal - 
 
16
    machines, services, units, relations.
 
17
 3. CHANGE_BLOCK blocks all commands from DESTROY and REMOVE blocks 
 
18
    as well as all environment modifications.
 
19
 
 
20
For more information and the list of all commands that are blocked, run
 
21
    `juju help block`
 
22
or
 
23
    `juju help unblock`
 
24
 
 
25
IMPLEMENTATION
 
26
=========================
 
27
Command: package cmd/juju
 
28
---------------------------------------------
 
29
 1. Help for block/unblock command is updated to contain your command.
 
30
 2. Delegate error processing of the client from apiserver error.
 
31
    Usually it would be done in the implementation of Command.Run.
 
32
    E.g.
 
33
 
 
34
          func (c *SetFluffCommand) Run(_ *cmd.Context) (err error) {
 
35
            ....
 
36
            err := apiclient.SetFluff(args)
 
37
            // there are corresponding
 
38
            // block.BlockDestroy and block.BlockRemove
 
39
            return block.ProcessBlockedError(err, block.BlockChange)
 
40
          }
 
41
 3. Add tests switching the block on before running the command.
 
42
 
 
43
Server: client instance in apiserver package
 
44
---------------------------------------------
 
45
  1. Check if the block is enabled using common.BlockChecker,
 
46
     before any other processing.
 
47
     Some client already have this checker embedded.
 
48
     To construct new checker, you'll need a state.State.
 
49
     E.g.
 
50
 
 
51
        func (c *Client) SetFluff(args params.SetFluff) error {
 
52
            if err := c.check.ChangeAllowed(); err != nil {
 
53
               return errors.Trace(err)
 
54
            }
 
55
            ......
 
56
        }
 
57
     or
 
58
 
 
59
        func (c *Client) SetFluff(args params.SetFluff) error {
 
60
            blockChecker := common.NewBlockChecker(st)
 
61
            // there are corresponding
 
62
            // blockChecker.DestroyAllowed() and block.RemoveAllowed()
 
63
            if err := blockChecker.ChangeAllowed(); err != nil {
 
64
                return errors.Trace(err)
 
65
            }
 
66
            ......
 
67
        }
 
68
  2. Add tests switching the block on. 
 
69
 
 
70
Interested Parties
 
71
---------------------------------------------
 
72
 1. Notify QA team that a new command became block-able.
 
73
 
 
74
 2. Juju documentation may need to be updated as well.
 
 
b'\\ No newline at end of file'