@@ -616,19 +616,24 @@ func (r *DynamoGraphDeploymentReconciler) reconcilePVCs(ctx context.Context, dyn
616616}
617617
618618// reconcileScalingAdapters ensures a DynamoGraphDeploymentScalingAdapter exists for each service in the DGD
619- // This enables pluggable autoscaling via HPA, KEDA, or Planner
619+ // that has scaling adapter enabled (default). Services with scalingAdapter.disable=true will not have a DGDSA.
620+ // This enables pluggable autoscaling via HPA, KEDA, or Planner.
620621func (r * DynamoGraphDeploymentReconciler ) reconcileScalingAdapters (ctx context.Context , dynamoDeployment * nvidiacomv1alpha1.DynamoGraphDeployment ) error {
621622 logger := log .FromContext (ctx )
622623
623- // Create or update an adapter for each service using SyncResource pattern
624+ // Process each service - SyncResource handles create, update, and delete via toDelete flag
624625 for serviceName , component := range dynamoDeployment .Spec .Services {
626+ // Check if scaling adapter is disabled for this service
627+ scalingAdapterDisabled := component .ScalingAdapter != nil && component .ScalingAdapter .Disable
628+
625629 // Get current replicas (default to 1 if not set)
626630 currentReplicas := int32 (1 )
627631 if component .Replicas != nil {
628632 currentReplicas = * component .Replicas
629633 }
630634
631- // Use SyncResource to handle creation/updates
635+ // Use SyncResource to handle creation/updates/deletion
636+ // When toDelete=true, SyncResource will delete the existing resource if it exists
632637 _ , _ , err := commonController .SyncResource (ctx , r , dynamoDeployment , func (ctx context.Context ) (* nvidiacomv1alpha1.DynamoGraphDeploymentScalingAdapter , bool , error ) {
633638 adapterName := generateAdapterName (dynamoDeployment .Name , serviceName )
634639 adapter := & nvidiacomv1alpha1.DynamoGraphDeploymentScalingAdapter {
@@ -648,7 +653,8 @@ func (r *DynamoGraphDeploymentReconciler) reconcileScalingAdapters(ctx context.C
648653 },
649654 },
650655 }
651- return adapter , false , nil
656+ // Return toDelete=true if scaling adapter is disabled
657+ return adapter , scalingAdapterDisabled , nil
652658 })
653659
654660 if err != nil {
@@ -657,7 +663,7 @@ func (r *DynamoGraphDeploymentReconciler) reconcileScalingAdapters(ctx context.C
657663 }
658664 }
659665
660- // Clean up orphaned adapters ( services that no longer exist in DGD)
666+ // Clean up adapters for services that were removed from DGD entirely
661667 adapterList := & nvidiacomv1alpha1.DynamoGraphDeploymentScalingAdapterList {}
662668 if err := r .List (ctx , adapterList ,
663669 client .InNamespace (dynamoDeployment .Namespace ),
@@ -671,7 +677,7 @@ func (r *DynamoGraphDeploymentReconciler) reconcileScalingAdapters(ctx context.C
671677 adapter := & adapterList .Items [i ]
672678 serviceName := adapter .Spec .DGDRef .ServiceName
673679
674- // Check if service still exists in DGD
680+ // Delete adapter if service no longer exists in DGD
675681 if _ , exists := dynamoDeployment .Spec .Services [serviceName ]; ! exists {
676682 logger .Info ("Deleting orphaned DynamoGraphDeploymentScalingAdapter" , "adapter" , adapter .Name , "service" , serviceName )
677683 if err := r .Delete (ctx , adapter ); err != nil && ! errors .IsNotFound (err ) {
0 commit comments