Skip to content

Commit 2bf1d30

Browse files
committed
fix
Signed-off-by: Robert Cerven <rcerven@redhat.com>
1 parent 28d0152 commit 2bf1d30

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

internal/controller/component_build_controller.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,17 @@ func (r *ComponentBuildReconciler) SetupWithManager(mgr ctrl.Manager) error {
120120
return true
121121
},
122122
UpdateFunc: func(e event.UpdateEvent) bool {
123-
// Only reconcile when spec changes (Generation increments), not on status-only updates
124-
// This might prevent scheduled (daily) reconcile to be triggered (but we shouldn't need it)
125-
return e.ObjectOld.GetGeneration() != e.ObjectNew.GetGeneration()
123+
component, ok := e.ObjectNew.(*applicationapiv1alpha1.Component)
124+
if !ok {
125+
return false
126+
}
127+
128+
// For new model: only reconcile when spec changes (Generation increments), not on status-only updates
129+
// For old model: always reconcile on update (old model uses annotations which don't increment Generation)
130+
if isComponentUsingNewModel(component) {
131+
return e.ObjectOld.GetGeneration() != e.ObjectNew.GetGeneration()
132+
}
133+
return true
126134
},
127135
DeleteFunc: func(e event.DeleteEvent) bool {
128136
return false
@@ -135,6 +143,13 @@ func (r *ComponentBuildReconciler) SetupWithManager(mgr ctrl.Manager) error {
135143
Complete(r)
136144
}
137145

146+
// isComponentUsingNewModel checks if the component is configured to use the new model (v2).
147+
// Returns true if the component has the new model annotation set to v2 or if the default model is v2.
148+
func isComponentUsingNewModel(component *applicationapiv1alpha1.Component) bool {
149+
requestedModel, requestedModelAnnotationExists := component.Annotations[ComponentModelVersionAnnotation]
150+
return (requestedModelAnnotationExists && requestedModel == NewComponentModelVersion) || DefaultComponentModelVersion == NewComponentModelVersion
151+
}
152+
138153
func updateMetricsTimes(componentIdForMetrics string, requestedAction string, reconcileStartTime time.Time) {
139154
componentInfo, timeRecorded := bometrics.ComponentTimesForMetrics[componentIdForMetrics]
140155

@@ -185,8 +200,7 @@ func (r *ComponentBuildReconciler) Reconcile(ctx context.Context, req ctrl.Reque
185200
return ctrl.Result{}, err
186201
}
187202

188-
requestedModel, requestedModelAnnotationExists := component.Annotations[ComponentModelVersionAnnotation]
189-
if (requestedModelAnnotationExists && requestedModel == NewComponentModelVersion) || DefaultComponentModelVersion == NewComponentModelVersion {
203+
if isComponentUsingNewModel(&component) {
190204
return r.ReconcileNewModel(ctx, req)
191205
}
192206

internal/controller/component_build_controller_v2.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ func (r *ComponentBuildReconciler) ReconcileNewModel(ctx context.Context, req ct
620620
}
621621

622622
// TODO handle skip builds !!!! if it is already working in PaC
623+
// TODO rework Repository naming (it has 253 limit)
623624
log.Info("New model reconciliation completed successfully",
624625
l.Action, l.ActionView)
625626

0 commit comments

Comments
 (0)