Skip to content

Commit

Permalink
during the sync update the spec of the cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
mkabilov committed Oct 12, 2017
1 parent 7d55f9e commit 56c8685
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/cluster/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import (

// Sync syncs the cluster, making sure the actual Kubernetes objects correspond to what is defined in the manifest.
// Unlike the update, sync does not error out if some objects do not exist and takes care of creating them.
func (c *Cluster) Sync() (err error) {
func (c *Cluster) Sync(newSpec *spec.Postgresql) (err error) {
c.mu.Lock()
defer c.mu.Unlock()

c.Postgresql = *newSpec

err = c.loadResources()
if err != nil {
c.logger.Errorf("could not load resources: %v", err)
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func (c *Controller) clusterListFunc(options metav1.ListOptions) (runtime.Object
err = json.Unmarshal(b, &list)

if time.Now().Unix()-atomic.LoadInt64(&c.lastClusterSyncTime) <= int64(c.opConfig.ResyncPeriod.Seconds()) {
c.logger.Debugln("skipping resync of clusters")
return &list, err
}

Expand Down Expand Up @@ -249,7 +248,7 @@ func (c *Controller) processEvent(event spec.ClusterEvent) {
}

c.curWorkerCluster.Store(event.WorkerID, cl)
if err := cl.Sync(); err != nil {
if err := cl.Sync(event.NewSpec); err != nil {
cl.Error = fmt.Errorf("could not sync cluster: %v", err)
lg.Error(cl.Error)
return
Expand Down

0 comments on commit 56c8685

Please sign in to comment.