Skip to content

Commit

Permalink
Generate uniter params via copying rather than referencing from templ…
Browse files Browse the repository at this point in the history
…ate;
  • Loading branch information
ycliuhw committed Oct 13, 2020
1 parent 5919eae commit a28e841
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions worker/caasoperator/caasoperator.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func (op *caasOperator) loop() (err error) {
if err := op.makeAgentSymlinks(unitTag); err != nil {
return errors.Trace(err)
}
params := op.config.UniterParams
params := *op.config.UniterParams
params.ModelType = model.CAAS
params.UnitTag = unitTag
params.Downloader = op.config.Downloader // TODO(caas): write a cache downloader
Expand All @@ -603,7 +603,7 @@ func (op *caasOperator) loop() (err error) {
}
params.NewRemoteRunnerExecutor = getNewRunnerExecutor(logger, execClient)
}
if err := op.config.StartUniterFunc(op.runner, params); err != nil {
if err := op.config.StartUniterFunc(op.runner, &params); err != nil {
return errors.Trace(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion worker/uniter/operation/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (x *executor) Run(op Operation, remoteStateChange <-chan remotestate.Snapsh
if op.NeedsGlobalMachineLock() {
releaser, err := x.acquireMachineLock(op.String())
if err != nil {
return errors.Annotate(err, "could not acquire lock")
return errors.Annotatef(err, "could not acquire lock for %q", op)
}
defer x.logger.Debugf("lock released")
defer releaser()
Expand Down
8 changes: 4 additions & 4 deletions worker/uniter/uniter.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func NewUniter(uniterParams *UniterParams) (*Uniter, error) {
// StartUniter creates a new Uniter and starts it using the specified runner.
func StartUniter(runner *worker.Runner, params *UniterParams) error {
startFunc := newUniter(params)
params.Logger.Debugf("starting uniter for %q", params.UnitTag.Id())
params.Logger.Debugf("starting uniter for %q", params.UnitTag.Id())
err := runner.StartWorker(params.UnitTag.Id(), startFunc)
return errors.Annotate(err, "error starting uniter worker")
}
Expand Down Expand Up @@ -273,12 +273,12 @@ func (u *Uniter) loop(unitTag names.UnitTag) (err error) {
err = nil
}
if u.runListener != nil {
u.runListener.UnregisterRunner(u.unit.Name())
u.runListener.UnregisterRunner(unitTag.Id())
}
if u.localRunListener != nil {
u.localRunListener.UnregisterRunner(u.unit.Name())
u.localRunListener.UnregisterRunner(unitTag.Id())
}
u.logger.Infof("unit %q shutting down: %s", u.unit, err)
u.logger.Infof("unit %q shutting down: %s", unitTag.Id(), err)
}()

if err := u.init(unitTag); err != nil {
Expand Down

0 comments on commit a28e841

Please sign in to comment.