Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Take cluster lock as late as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Broughton committed Jan 2, 2018
1 parent c113bd1 commit 8c3f720
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cluster/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ func (c *Cluster) AllControllers(namespace string) (res []cluster.Controller, er
// Sync performs the given actions on resources. Operations are
// asynchronous, but serialised.
func (c *Cluster) Sync(spec cluster.SyncDef) error {
c.mu.Lock()
defer c.mu.Unlock()
logger := log.With(c.logger, "method", "Sync")

cs := makeChangeSet()
Expand All @@ -243,6 +241,9 @@ func (c *Cluster) Sync(spec cluster.SyncDef) error {
}
}
}

c.mu.Lock()
defer c.mu.Unlock()
c.applier.apply(logger, cs, errs)
if len(errs) != 0 {
return errs
Expand Down

0 comments on commit 8c3f720

Please sign in to comment.