github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/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 type LocalState struct { 55 operation.State 56 57 // CharmURL reports the currently installed charm URL. This is set 58 // by the committing of deploy (install/upgrade) ops. 59 CharmURL *charm.URL 60 61 // Conflicted indicates that the uniter is in a conflicted state, 62 // and needs either resolution or a forced upgrade to continue. 63 Conflicted bool 64 65 // Restart indicates that the resolver should exit with ErrRestart 66 // at the earliest opportunity. 67 Restart bool 68 69 // UpdateStatusVersion is the version of update status from remotestate.Snapshot 70 // for which an update-status hook has been committed. 71 UpdateStatusVersion int 72 73 // ConfigVersion is the version of config from remotestate.Snapshot 74 // for which a config-changed hook has been committed. 75 ConfigVersion int 76 77 // LeaderSettingsVersion is the version of leader settings from 78 // remotestate.Snapshot for which a leader-settings-changed hook has 79 // been committed. 80 LeaderSettingsVersion int 81 82 // CompletedActions is the set of actions that have been completed. 83 // This is used to prevent us re running actions requested by the 84 // state server. 85 CompletedActions map[string]struct{} 86 }