Skip to content

Commit 990d1a7

Browse files
akselleirvTarasLykhenko
authored andcommitted
internal/informer/branch-planner/informer.go: get actual object
1 parent dd2b951 commit 990d1a7

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

internal/informer/branch-planner/informer.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ func (i *Informer) updateHandler(oldObj, newObj interface{}) {
148148

149149
ctx := context.Background()
150150

151+
// The informer cache does not update when the status field is updated, so we need to get the object from api server.
152+
if err := i.client.Get(ctx, client.ObjectKeyFromObject(new), new); err != nil {
153+
i.log.Info("failed getting object", "namespace", new.Namespace, "name", new.Name, "error", err)
154+
return
155+
}
156+
151157
for _, condition := range new.Status.Conditions {
152158
if condition.Reason == infrav1.TFExecInitFailedReason || condition.Reason == infrav1.PostPlanningWebhookFailedReason {
153159
if ann := new.GetAnnotations(); ann != nil && ann[config.AnnotationErrorRevision] == new.Status.LastAttemptedRevision {

internal/informer/branch-planner/informer_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,6 @@ func TestInformer(t *testing.T) {
108108
tf.Status.LastPlanAt = &metav1.Time{Time: time.Now()}
109109
expectToSucceed(t, g, k8sClient.Status().Patch(ctx, tf, patch))
110110

111-
// verify that the last plan time is updated
112-
g.Eventually(func() *metav1.Time {
113-
err = k8sClient.Get(ctx, client.ObjectKeyFromObject(tf), tf)
114-
if err != nil {
115-
return nil
116-
}
117-
return tf.Status.LastPlanAt
118-
}).ShouldNot(gom.BeNil())
119-
120111
g.Eventually(func() int {
121112
return gitProvider.AddCommentToPullRequestCallCount()
122113
}).Should(gom.Equal(1))

0 commit comments

Comments
 (0)