@@ -13,6 +13,7 @@ import (
1313 "k8s.io/client-go/tools/cache"
1414 "k8s.io/client-go/util/workqueue"
1515
16+ "github.com/jetstack/tarmak/pkg/apis/wing/common"
1617 "github.com/jetstack/tarmak/pkg/apis/wing/v1alpha1"
1718 "github.com/jetstack/tarmak/pkg/wing/interfaces"
1819)
@@ -81,7 +82,7 @@ func (c *Controller) syncToStdout(key string) error {
8182 },
8283 Status : & v1alpha1.MachineStatus {
8384 Converge : & v1alpha1.MachineStatusManifest {
84- State : v1alpha1 .MachineManifestStateConverging ,
85+ State : common .MachineManifestStateConverging ,
8586 },
8687 },
8788 }
@@ -91,33 +92,36 @@ func (c *Controller) syncToStdout(key string) error {
9192 }
9293
9394 c .log .Infof ("Machine created %v" , key )
94- } else {
95- // Note that you also have to check the uid if you have a local controlled resource, which
96- // is dependent on the actual machine, to detect that a Machine was recreated with the same name
97- machine , ok := obj .(* v1alpha1.Machine )
98- if ! ok {
99- return errors .New ("failed to process next item, not a machine" )
100- }
95+ return nil
96+ }
97+
98+ // Note that you also have to check the uid if you have a local controlled resource, which
99+ // is dependent on the actual machine, to detect that a Machine was recreated with the same name
100+ machine , ok := obj .(* v1alpha1.Machine )
101+ if ! ok {
102+ return errors .New ("failed to process next item, not a machine" )
103+ }
101104
102- // trigger converge if status time is older or not existing
103- if machine .Spec != nil && machine .Spec .Converge != nil && ! machine .Spec .Converge .RequestTimestamp .Time .IsZero () {
104- if machine .Status != nil && machine .Status .Converge != nil && ! machine .Status .Converge .LastUpdateTimestamp .Time .IsZero () {
105- if machine .Status .Converge .LastUpdateTimestamp .Time .After (machine .Spec .Converge .RequestTimestamp .Time ) {
106- c .log .Debug ("no converge neccessary, last update was after request" )
107- return nil
108- }
109- } else {
110- c .log .Debug ("no converge neccessary, no status section found or update timestamp zero" )
105+ // trigger converge if status time is older or not existing
106+ if machine .Spec != nil && machine .Spec .Converge != nil && ! machine .Spec .Converge .RequestTimestamp .Time .IsZero () {
107+ if machine .Status != nil && machine .Status .Converge != nil && ! machine .Status .Converge .LastUpdateTimestamp .Time .IsZero () {
108+ if machine .Status .Converge .LastUpdateTimestamp .Time .After (machine .Spec .Converge .RequestTimestamp .Time ) {
109+ c .log .Debug ("no converge neccessary, last update was after request" )
111110 return nil
112111 }
113112 } else {
114- c .log .Debug ("no converge neccessary, no spec section found or request timestamp zero" )
113+ c .log .Debug ("no converge neccessary, no status section found or update timestamp zero" )
115114 return nil
116115 }
116+ }
117117
118+ if machine .Status != nil && machine .Status .Converge != nil &&
119+ machine .Status .Converge .State != common .MachineManifestStateConverging &&
120+ machine .Status .Converge .State != common .MachineManifestStateConverged {
118121 c .log .Infof ("running converge" )
119122 c .wing .Converge ()
120123 }
124+
121125 return nil
122126}
123127
0 commit comments