Skip to content

Commit

Permalink
Replacing NMC's controller watch object.
Browse files Browse the repository at this point in the history
We should watch for builds and not for jobs as we are not using jobs in
this project.

Signed-off-by: Yoni Bettan <[email protected]>
  • Loading branch information
ybettan committed Aug 22, 2023
1 parent 8baa8d6 commit f130493
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions controllers/module_nmc_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/hashicorp/go-multierror"
buildv1 "github.com/openshift/api/build/v1"
kmmv1beta1 "github.com/rh-ecosystem-edge/kernel-module-management/api/v1beta1"
"github.com/rh-ecosystem-edge/kernel-module-management/internal/api"
"github.com/rh-ecosystem-edge/kernel-module-management/internal/auth"
Expand All @@ -16,7 +17,6 @@ import (
"github.com/rh-ecosystem-edge/kernel-module-management/internal/nmc"
"github.com/rh-ecosystem-edge/kernel-module-management/internal/registry"
"github.com/rh-ecosystem-edge/kernel-module-management/internal/utils"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -290,7 +290,7 @@ func (mnr *ModuleNMCReconciler) SetupWithManager(mgr ctrl.Manager) error {
NewControllerManagedBy(mgr).
For(&kmmv1beta1.Module{}).
Owns(&kmmv1beta1.NodeModulesConfig{}).
Owns(&batchv1.Job{}, builder.WithPredicates(filter.ModuleNMCReconcileJobPredicate())).
Owns(&buildv1.Build{}, builder.WithPredicates(filter.ModuleNMCReconcileBuildPredicate())).
Watches(
&v1.Node{},
handler.EnqueueRequestsFromMapFunc(mnr.filter.FindModulesForNMCNodeChange),
Expand Down
11 changes: 5 additions & 6 deletions internal/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/go-logr/logr"
imagev1 "github.com/openshift/api/image/v1"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -83,13 +82,13 @@ var kmmClusterClaimChanged predicate.Predicate = predicate.Funcs{
},
}

var moduleJobSuccess predicate.Predicate = predicate.Funcs{
var moduleBuildSuccess predicate.Predicate = predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
job, ok := e.ObjectNew.(*batchv1.Job)
build, ok := e.ObjectNew.(*buildv1.Build)

Check failure on line 87 in internal/filter/filter.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: buildv1
if !ok {
return true
}
if job.Status.Succeeded == 1 {
if build.Status.Phase == buildv1.BuildPhaseComplete {

Check failure on line 91 in internal/filter/filter.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: buildv1
return true
}

Expand Down Expand Up @@ -133,11 +132,11 @@ func ModuleNMCReconcilerNodePredicate() predicate.Predicate {
)
}

func ModuleNMCReconcileJobPredicate() predicate.Predicate {
func ModuleNMCReconcileBuildPredicate() predicate.Predicate {
return predicate.And(
skipDeletions,
skipCreations,
moduleJobSuccess,
moduleBuildSuccess,
)
}

Expand Down

0 comments on commit f130493

Please sign in to comment.