Skip to content

Commit

Permalink
Fix duplicate resource tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelattwood committed Jan 14, 2025
1 parent 3e24e7c commit 682073f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion internal/controller/account_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)
Expand Down Expand Up @@ -217,6 +218,8 @@ func (r *AccountReconciler) findDependentResources(ctx context.Context, log logr
func (r *AccountReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&api.Account{}).
Owns(&api.Account{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: 1,
}).
Complete(r)
}
3 changes: 2 additions & 1 deletion internal/controller/consumer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ func (r *ConsumerReconciler) createOrUpdate(ctx context.Context, log klog.Logger
}
consumer.Annotations[stateAnnotationStream] = string(knownState)
}

return r.Update(ctx, consumer)
}

return nil
Expand Down Expand Up @@ -393,7 +395,6 @@ func compareConsumerConfig(actual *jetstream.ConsumerConfig, desired *jetstream.
func (r *ConsumerReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&api.Consumer{}).
Owns(&api.Consumer{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: 1,
}).
Expand Down
1 change: 0 additions & 1 deletion internal/controller/keyvalue_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ func keyValueSpecToConfig(spec *api.KeyValueSpec) (jetstream.KeyValueConfig, err
func (r *KeyValueReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&api.KeyValue{}).
Owns(&api.KeyValue{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: 1,
}).
Expand Down
1 change: 0 additions & 1 deletion internal/controller/objectstore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ func objectStoreSpecToConfig(spec *api.ObjectStoreSpec) (jetstream.ObjectStoreCo
func (r *ObjectStoreReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&api.ObjectStore{}).
Owns(&api.ObjectStore{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: 1,
}).
Expand Down
3 changes: 2 additions & 1 deletion internal/controller/stream_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ func (r *StreamReconciler) createOrUpdate(ctx context.Context, log logr.Logger,
}
stream.Annotations[stateAnnotationStream] = string(knownState)
}

return r.Update(ctx, stream)
}

return nil
Expand Down Expand Up @@ -467,7 +469,6 @@ func mapStreamSource(ss *api.StreamSource) (*jetstream.StreamSource, error) {
func (r *StreamReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&api.Stream{}).
Owns(&api.Stream{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: 1,
}).
Expand Down

0 comments on commit 682073f

Please sign in to comment.