Skip to content

Commit eab02e9

Browse files
authored
Merge pull request #357 from fluxcd/debug-success-error-356
Fix error logs with stale success message
2 parents 50b261c + c612504 commit eab02e9

5 files changed

Lines changed: 18 additions & 19 deletions

File tree

controllers/imagerepository_controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import (
4949
"github.com/fluxcd/pkg/oci/auth/login"
5050
"github.com/fluxcd/pkg/runtime/conditions"
5151
helper "github.com/fluxcd/pkg/runtime/controller"
52-
"github.com/fluxcd/pkg/runtime/events"
5352
"github.com/fluxcd/pkg/runtime/patch"
5453
"github.com/fluxcd/pkg/runtime/predicates"
5554
"github.com/fluxcd/pkg/runtime/reconcile"
@@ -108,9 +107,8 @@ type ImageRepositoryReconciler struct {
108107
kuberecorder.EventRecorder
109108
helper.Metrics
110109

111-
ControllerName string
112-
ExternalEventRecorder *events.Recorder
113-
Database interface {
110+
ControllerName string
111+
Database interface {
114112
DatabaseWriter
115113
DatabaseReader
116114
}
@@ -286,6 +284,7 @@ func (r *ImageRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Ser
286284
reconcile.ProgressiveStatus(false, obj, meta.ProgressingReason, "scanning: %s", reasonMsg)
287285
if err := sp.Patch(ctx, obj, r.patchOptions...); err != nil {
288286
result, retErr = ctrl.Result{}, err
287+
return
289288
}
290289

291290
tags, err := r.scan(ctx, obj, ref, opts)

controllers/policy_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func TestImagePolicyReconciler_calculateImageFromRepoTags(t *testing.T) {
234234
// Check if the object status is valid.
235235
condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions}
236236
checker := conditionscheck.NewChecker(testEnv.Client, condns)
237-
checker.CheckErr(ctx, &pol)
237+
checker.WithT(g).CheckErr(ctx, &pol)
238238

239239
g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed())
240240
})
@@ -344,7 +344,7 @@ func TestImagePolicyReconciler_filterTags(t *testing.T) {
344344
// Check if the object status is valid.
345345
condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions}
346346
checker := conditionscheck.NewChecker(testEnv.Client, condns)
347-
checker.CheckErr(ctx, &pol)
347+
checker.WithT(g).CheckErr(ctx, &pol)
348348

349349
g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed())
350350
})
@@ -519,7 +519,7 @@ func TestImagePolicyReconciler_accessImageRepo(t *testing.T) {
519519
// Check if the object status is valid.
520520
condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions}
521521
checker := conditionscheck.NewChecker(testEnv.Client, condns)
522-
checker.CheckErr(ctx, &pol)
522+
checker.WithT(g).CheckErr(ctx, &pol)
523523

524524
g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed())
525525
})

controllers/scan_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestImageRepositoryReconciler_canonicalImageName(t *testing.T) {
7979
// Check if the object status is valid.
8080
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
8181
checker := conditionscheck.NewChecker(testEnv.Client, condns)
82-
checker.CheckErr(ctx, &repo)
82+
checker.WithT(g).CheckErr(ctx, &repo)
8383

8484
// Cleanup.
8585
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -149,7 +149,7 @@ func TestImageRepositoryReconciler_fetchImageTags(t *testing.T) {
149149
// Check if the object status is valid.
150150
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
151151
checker := conditionscheck.NewChecker(testEnv.Client, condns)
152-
checker.CheckErr(ctx, &repo)
152+
checker.WithT(g).CheckErr(ctx, &repo)
153153

154154
// Cleanup.
155155
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -251,7 +251,7 @@ func TestImageRepositoryReconciler_reconcileAtAnnotation(t *testing.T) {
251251
// Check if the object status is valid.
252252
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
253253
checker := conditionscheck.NewChecker(testEnv.Client, condns)
254-
checker.CheckErr(ctx, &repo)
254+
checker.WithT(g).CheckErr(ctx, &repo)
255255

256256
// Cleanup.
257257
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -327,7 +327,7 @@ func TestImageRepositoryReconciler_authRegistry(t *testing.T) {
327327
// Check if the object status is valid.
328328
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
329329
checker := conditionscheck.NewChecker(testEnv.Client, condns)
330-
checker.CheckErr(ctx, &repo)
330+
checker.WithT(g).CheckErr(ctx, &repo)
331331

332332
// Cleanup.
333333
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -372,7 +372,7 @@ func TestImageRepositoryReconciler_imageAttribute_schemePrefix(t *testing.T) {
372372
// Check if the object status is valid.
373373
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
374374
checker := conditionscheck.NewChecker(testEnv.Client, condns)
375-
checker.CheckErr(ctx, &repo)
375+
checker.WithT(g).CheckErr(ctx, &repo)
376376

377377
// Cleanup.
378378
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -417,7 +417,7 @@ func TestImageRepositoryReconciler_imageAttribute_withTag(t *testing.T) {
417417
// Check if the object status is valid.
418418
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
419419
checker := conditionscheck.NewChecker(testEnv.Client, condns)
420-
checker.CheckErr(ctx, &repo)
420+
checker.WithT(g).CheckErr(ctx, &repo)
421421

422422
// Cleanup.
423423
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -460,7 +460,7 @@ func TestImageRepositoryReconciler_imageAttribute_hostPort(t *testing.T) {
460460
// Check if the object status is valid.
461461
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
462462
checker := conditionscheck.NewChecker(testEnv.Client, condns)
463-
checker.CheckErr(ctx, &repo)
463+
checker.WithT(g).CheckErr(ctx, &repo)
464464

465465
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
466466
}
@@ -541,7 +541,7 @@ func TestImageRepositoryReconciler_authRegistryWithServiceAccount(t *testing.T)
541541
// Check if the object status is valid.
542542
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
543543
checker := conditionscheck.NewChecker(testEnv.Client, condns)
544-
checker.CheckErr(ctx, &repo)
544+
checker.WithT(g).CheckErr(ctx, &repo)
545545

546546
// Cleanup.
547547
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
@@ -585,7 +585,7 @@ func TestImageRepositoryReconciler_ScanPublicRepos(t *testing.T) {
585585
// Check if the object status is valid.
586586
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
587587
checker := conditionscheck.NewChecker(testEnv.Client, condns)
588-
checker.CheckErr(ctx, &repo)
588+
checker.WithT(g).CheckErr(ctx, &repo)
589589

590590
g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
591591
})

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/fluxcd/pkg/apis/event v0.4.1
1414
github.com/fluxcd/pkg/apis/meta v0.19.1
1515
github.com/fluxcd/pkg/oci v0.21.1
16-
github.com/fluxcd/pkg/runtime v0.31.0
16+
github.com/fluxcd/pkg/runtime v0.32.0
1717
github.com/fluxcd/pkg/version v0.2.1
1818
github.com/google/go-containerregistry v0.13.0
1919
github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20230307034325-57f010d26af8

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ github.com/fluxcd/pkg/apis/meta v0.19.1 h1:fCI5CnTXpAqr67UlaI9q0H+OztMKB5kDTr6xV
212212
github.com/fluxcd/pkg/apis/meta v0.19.1/go.mod h1:ZPPMYrPnWwPQYNEGM/Uc0N4SurUPS3xNI3IIpCQEfuM=
213213
github.com/fluxcd/pkg/oci v0.21.1 h1:9kn19wkabE2xB77NRlOtMJlSYhZmUjdloZCzlHdAS6s=
214214
github.com/fluxcd/pkg/oci v0.21.1/go.mod h1:9E2DBlQII7YmeWt2ieTh38wwkiBqx3yg5NEJ51uefaA=
215-
github.com/fluxcd/pkg/runtime v0.31.0 h1:addyXaANHl/A68bEjCbiR4HzcFKgfXv1eaG7B7ZHxOo=
216-
github.com/fluxcd/pkg/runtime v0.31.0/go.mod h1:toGOOubMo4ZC1aWhB8C3drdTglr1/A1dETeNwjiIv0g=
215+
github.com/fluxcd/pkg/runtime v0.32.0 h1:GwPyl27qs0jg95o8lGQD+FiAAxFPJMKs58L63AQRk50=
216+
github.com/fluxcd/pkg/runtime v0.32.0/go.mod h1:toGOOubMo4ZC1aWhB8C3drdTglr1/A1dETeNwjiIv0g=
217217
github.com/fluxcd/pkg/version v0.2.1 h1:RRH7+6qiWHdTvRNwpoBmilnubJ2C4FZYGgy5wTDVKVc=
218218
github.com/fluxcd/pkg/version v0.2.1/go.mod h1:UmUYHDz4BxHQMesMUx3gYVrT2Wf66H49JpTg/PW+/OY=
219219
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=

0 commit comments

Comments
 (0)