github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/uniter/resolver/interface.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package resolver 5 6 import ( 7 "github.com/juju/errors" 8 "gopkg.in/juju/charm.v6-unstable" 9 10 "github.com/juju/juju/worker/uniter/operation" 11 "github.com/juju/juju/worker/uniter/remotestate" 12 ) 13 14 // ErrNoOperation is used to indicate that there are no 15 // currently pending operations to run. 16 var ErrNoOperation = errors.New("no operations") 17 18 // ErrWaiting indicates that the resolver loop should 19 // not execute any more operations until a remote state 20 // event has occurred. 21 var ErrWaiting = errors.New("waiting for remote state change") 22 23 // ErrRestart indicates that the resolver loop should 24 // be restarted with a new remote state watcher. 25 var ErrRestart = errors.New("restarting resolver") 26 27 // ErrTerminate is used when the unit has been marked 28 // as dead and so there will never be any more 29 // operations to run for that unit. 30 var ErrTerminate = errors.New("terminate resolver") 31 32 // Resolver instances use local (as is) and remote (to be) state 33 // to provide operations to run in order to progress towards 34 // the desired state. 35 type Resolver interface { 36 // NextOp returns the next operation to run to reconcile 37 // the local state with the remote, desired state. The 38 // operations returned must be created using the given 39 // operation.Factory. 40 // 41 // This method must return ErrNoOperation if there are no 42 // operations to perform. 43 // 44 // By returning ErrTerminate, the resolver indicates that 45 // it will never have any more operations to perform, 46 // and the caller can cease calling. 47 NextOp( 48 LocalState, 49 remotestate.Snapshot, 50 operation.Factory, 51 ) (operation.Operation, error) 52 } 53 54 // LocalState is a cache of the state of the local unit, as needed by the 55 // Uniter. It is generally compared to the remote state of the expected state of 56 // the unit as stored in the controller. 57 type LocalState struct { 58 operation.State 59 60 // CharmModifiedVersion increases any time the charm, 61 // or any part of it, is changed in some way. 62 CharmModifiedVersion int 63 64 // CharmURL reports the currently installed charm URL. This is set 65 // by the committing of deploy (install/upgrade) ops. 66 CharmURL *charm.URL 67 68 // Conflicted indicates that the uniter is in a conflicted state, 69 // and needs either resolution or a forced upgrade to continue. 70 Conflicted bool 71 72 // Restart indicates that the resolver should exit with ErrRestart 73 // at the earliest opportunity. 74 Restart bool 75 76 // UpdateStatusVersion is the version of update status from remotestate.Snapshot 77 // for which an update-status hook has been committed. 78 UpdateStatusVersion int 79 80 // RetryHookVersion is the version of hook-retries from 81 // remotestate.Snapshot for which a hook has been retried. 82 RetryHookVersion int 83 84 // ConfigVersion is the version of config from remotestate.Snapshot 85 // for which a config-changed hook has been committed. 86 ConfigVersion int 87 88 // LeaderSettingsVersion is the version of leader settings from 89 // remotestate.Snapshot for which a leader-settings-changed hook has 90 // been committed. 91 LeaderSettingsVersion int 92 93 // CompletedActions is the set of actions that have been completed. 94 // This is used to prevent us re running actions requested by the 95 // controller. 96 CompletedActions map[string]struct{} 97 }