Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error logs with stale success message #357

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions controllers/imagerepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import (
"github.com/fluxcd/pkg/oci/auth/login"
"github.com/fluxcd/pkg/runtime/conditions"
helper "github.com/fluxcd/pkg/runtime/controller"
"github.com/fluxcd/pkg/runtime/events"
"github.com/fluxcd/pkg/runtime/patch"
"github.com/fluxcd/pkg/runtime/predicates"
"github.com/fluxcd/pkg/runtime/reconcile"
Expand Down Expand Up @@ -108,9 +107,8 @@ type ImageRepositoryReconciler struct {
kuberecorder.EventRecorder
helper.Metrics

ControllerName string
ExternalEventRecorder *events.Recorder
Database interface {
ControllerName string
Database interface {
DatabaseWriter
DatabaseReader
}
Expand Down Expand Up @@ -286,6 +284,7 @@ func (r *ImageRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Ser
reconcile.ProgressiveStatus(false, obj, meta.ProgressingReason, "scanning: %s", reasonMsg)
if err := sp.Patch(ctx, obj, r.patchOptions...); err != nil {
result, retErr = ctrl.Result{}, err
return
}

tags, err := r.scan(ctx, obj, ref, opts)
Expand Down
6 changes: 3 additions & 3 deletions controllers/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func TestImagePolicyReconciler_calculateImageFromRepoTags(t *testing.T) {
// Check if the object status is valid.
condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions}
checker := conditionscheck.NewChecker(testEnv.Client, condns)
checker.CheckErr(ctx, &pol)
checker.WithT(g).CheckErr(ctx, &pol)

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

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

g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed())
})
Expand Down
18 changes: 9 additions & 9 deletions controllers/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestImageRepositoryReconciler_canonicalImageName(t *testing.T) {
// Check if the object status is valid.
condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions}
checker := conditionscheck.NewChecker(testEnv.Client, condns)
checker.CheckErr(ctx, &repo)
checker.WithT(g).CheckErr(ctx, &repo)

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

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

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

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

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

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

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

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

g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed())
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/fluxcd/pkg/apis/event v0.4.1
github.com/fluxcd/pkg/apis/meta v0.19.1
github.com/fluxcd/pkg/oci v0.21.1
github.com/fluxcd/pkg/runtime v0.31.0
github.com/fluxcd/pkg/runtime v0.32.0
github.com/fluxcd/pkg/version v0.2.1
github.com/google/go-containerregistry v0.13.0
github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20230307034325-57f010d26af8
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ github.com/fluxcd/pkg/apis/meta v0.19.1 h1:fCI5CnTXpAqr67UlaI9q0H+OztMKB5kDTr6xV
github.com/fluxcd/pkg/apis/meta v0.19.1/go.mod h1:ZPPMYrPnWwPQYNEGM/Uc0N4SurUPS3xNI3IIpCQEfuM=
github.com/fluxcd/pkg/oci v0.21.1 h1:9kn19wkabE2xB77NRlOtMJlSYhZmUjdloZCzlHdAS6s=
github.com/fluxcd/pkg/oci v0.21.1/go.mod h1:9E2DBlQII7YmeWt2ieTh38wwkiBqx3yg5NEJ51uefaA=
github.com/fluxcd/pkg/runtime v0.31.0 h1:addyXaANHl/A68bEjCbiR4HzcFKgfXv1eaG7B7ZHxOo=
github.com/fluxcd/pkg/runtime v0.31.0/go.mod h1:toGOOubMo4ZC1aWhB8C3drdTglr1/A1dETeNwjiIv0g=
github.com/fluxcd/pkg/runtime v0.32.0 h1:GwPyl27qs0jg95o8lGQD+FiAAxFPJMKs58L63AQRk50=
github.com/fluxcd/pkg/runtime v0.32.0/go.mod h1:toGOOubMo4ZC1aWhB8C3drdTglr1/A1dETeNwjiIv0g=
github.com/fluxcd/pkg/version v0.2.1 h1:RRH7+6qiWHdTvRNwpoBmilnubJ2C4FZYGgy5wTDVKVc=
github.com/fluxcd/pkg/version v0.2.1/go.mod h1:UmUYHDz4BxHQMesMUx3gYVrT2Wf66H49JpTg/PW+/OY=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down