2
=========================
3
Customers and stakeholders want to be able to
4
prevent accidental damage to Juju deployments.
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.
12
There are currently three types of blocks developed.
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.
20
For more information and the list of all commands that are blocked, run
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.
34
func (c *SetFluffCommand) Run(_ *cmd.Context) (err error) {
36
err := apiclient.SetFluff(args)
37
// there are corresponding
38
// block.BlockDestroy and block.BlockRemove
39
return block.ProcessBlockedError(err, block.BlockChange)
41
3. Add tests switching the block on before running the command.
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.
51
func (c *Client) SetFluff(args params.SetFluff) error {
52
if err := c.check.ChangeAllowed(); err != nil {
53
return errors.Trace(err)
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)
68
2. Add tests switching the block on.
71
---------------------------------------------
72
1. Notify QA team that a new command became block-able.
74
2. Juju documentation may need to be updated as well.
b'\\ No newline at end of file'