Skip to content

Commit

Permalink
Test without automated collector
Browse files Browse the repository at this point in the history
This code should be reverted once the timing logic has been sorted out.
See issue eraser-dev#568 for details.

Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
  • Loading branch information
pmengelbert committed Dec 30, 2022
1 parent 77e4f2e commit 498814d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
23 changes: 17 additions & 6 deletions controllers/imagecollector/imagecollector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var (
collectorImage = flag.String("collector-image", "", "collector image, empty value disables collect feature")
log = logf.Log.WithName("controller").WithValues("process", "imagecollector-controller")
repeatPeriod = flag.Duration("repeat-period", time.Hour*24, "repeat period for collect/scan process")
repeatImmediate = flag.Bool("repeat-immediate", true, "begin collect/scan process immediately")
deleteScanFailedImages = flag.Bool("delete-scan-failed-images", true, "whether or not to delete images for which scanning has failed")
scannerArgs = utils.MultiFlag([]string{})
collectorArgs = utils.MultiFlag([]string{})
Expand Down Expand Up @@ -156,13 +157,23 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {

go func() {
log.Info("Queueing first ImageCollector reconcile...")
ch <- event.GenericEvent{
Object: &eraserv1alpha1.ImageJob{
ObjectMeta: metav1.ObjectMeta{
Name: "first-reconcile",
},
},

delay := *repeatPeriod
if !*repeatImmediate {
delay = 0 * time.Second
}

// runs the provided function after the specified delay
_ = time.AfterFunc(delay, func() {
ch <- event.GenericEvent{
Object: &eraserv1alpha1.ImageJob{
ObjectMeta: metav1.ObjectMeta{
Name: "first-reconcile",
},
},
}
})

log.Info("Queued first ImageCollector reconcile")
}()

Expand Down
10 changes: 0 additions & 10 deletions test/e2e/tests/imagelist_rm_images/eraser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ func TestImageListTriggersEraserImageJob(t *testing.T) {
t.Error("Failed to create the dep", err)
}

client := cfg.Client()
err := wait.For(
util.NumPodsPresentForLabel(ctx, client, 0, collectorLabel),
wait.WithTimeout(time.Minute*2),
wait.WithInterval(time.Millisecond*500),
)
if err != nil {
t.Fatal(err)
}

return ctx
}).
Assess("deployment successfully deployed", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/tests/imagelist_rm_images/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestMain(m *testing.M) {
"--set", util.EraserImageTag.Set(eraserImage.Tag),
"--set", util.ManagerImageRepo.Set(managerImage.Repo),
"--set", util.ManagerImageTag.Set(managerImage.Tag),
"--set", util.ManagerAdditionalArgs.Set("--repeat-immediate=false").String(),
),
).Finish(
envfuncs.DestroyKindCluster(util.KindClusterName),
Expand Down

0 comments on commit 498814d

Please sign in to comment.