Skip to content

Create SQSInformer from UnstructuredDataProduct reconcile loop#132

Open
concaf wants to merge 1 commit intoredhat-data-and-ai:mainfrom
concaf:sqsinformer-from-udp-reconcile
Open

Create SQSInformer from UnstructuredDataProduct reconcile loop#132
concaf wants to merge 1 commit intoredhat-data-and-ai:mainfrom
concaf:sqsinformer-from-udp-reconcile

Conversation

@concaf
Copy link
Copy Markdown
Contributor

@concaf concaf commented Apr 6, 2026

Summary

  • Adds optional sqsInformerConfig (with queueURL) to the UnstructuredDataProduct spec
  • UDP reconciler now creates/updates an SQSInformer CR when the config is provided, following the same pattern as DocumentProcessor, ChunksGenerator, and VectorEmbeddingsGenerator
  • Sets owner reference (SetControllerReference) on the SQSInformer so it is garbage-collected when the parent UDP is deleted
  • Cleans up existing SQSInformer if the config is later removed from the spec
  • Updates e2e tests to use the new field instead of manual SQSInformer creation/deletion

Closes #110

Test plan

  • Verify creating a UDP with sqsInformerConfig creates the SQSInformer CR
  • Verify updating sqsInformerConfig.queueURL updates the SQSInformer CR
  • Verify deleting the UDP cascade-deletes the SQSInformer
  • Verify removing sqsInformerConfig from the spec deletes the SQSInformer
  • Verify a UDP without sqsInformerConfig does not create an SQSInformer
  • Run e2e tests

SQSInformer CR is now created/updated by the UnstructuredDataProduct
reconciler instead of requiring manual creation. An optional
sqsInformerConfig field (with queueURL) is added to the UDP spec.

Owner reference is set on the SQSInformer so it is automatically
garbage-collected when the parent UDP is deleted. If the config is
later removed from the spec, the existing SQSInformer is cleaned up.

Closes redhat-data-and-ai#110
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces SQSInformerConfig to the UnstructuredDataProduct API, enabling the controller to automatically manage the lifecycle of SQSInformer resources. The controller now handles the creation, update, and deletion of these resources based on the specification, and E2E tests have been updated accordingly. Feedback includes a suggestion to simplify the resource cleanup logic by removing an unnecessary Get call and a recommendation to address inconsistencies in owner references for other sub-resources in a follow-up PR.

sqsInformerCR.Spec = operatorv1alpha1.SQSInformerSpec{
QueueURL: unstructuredDataProductCR.Spec.SQSInformerConfig.QueueURL,
}
return controllerutil.SetControllerReference(unstructuredDataProductCR, sqsInformerCR, r.Scheme)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The PR description states that setting the owner reference follows the same pattern as DocumentProcessor, ChunksGenerator, and VectorEmbeddingsGenerator. However, those resources currently lack owner references in the reconciler (see lines 119-174). While adding it here for SQSInformer is correct and recommended for proper garbage collection, this creates an inconsistency. It is highly recommended to also add owner references to the other sub-resources in a follow-up PR to prevent resource leaks when an UnstructuredDataProduct is deleted.

Comment on lines +202 to +216
existingSQSInformer := &operatorv1alpha1.SQSInformer{}
sqsInformerKey := client.ObjectKey{
Name: dataProductName,
Namespace: unstructuredDataProductCR.Namespace,
}
if err := r.Get(ctx, sqsInformerKey, existingSQSInformer); err == nil {
if err := r.Delete(ctx, existingSQSInformer); err != nil {
logger.Error(err, "failed to delete SQSInformer CR")
return r.handleError(ctx, unstructuredDataProductCR, err)
}
logger.Info("SQSInformer CR deleted (config removed)")
} else if !apierrors.IsNotFound(err) {
logger.Error(err, "failed to check for existing SQSInformer CR")
return r.handleError(ctx, unstructuredDataProductCR, err)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The manual cleanup of the SQSInformer can be simplified by calling Delete directly with a pre-populated object and checking for NotFound errors. This avoids an unnecessary Get request to the API server.

existingSQSInformer := &operatorv1alpha1.SQSInformer{
			ObjectMeta: metav1.ObjectMeta{
				Name:      dataProductName,
				Namespace: unstructuredDataProductCR.Namespace,
			},
		}
		if err := r.Delete(ctx, existingSQSInformer); err != nil {
			if !apierrors.IsNotFound(err) {
				logger.Error(err, "failed to delete SQSInformer CR")
				return r.handleError(ctx, unstructuredDataProductCR, err)
			}
		} else {
			logger.Info("SQSInformer CR deleted (config removed)")
		}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqsinformer will be created by unstructureddataproduct reconcile loop

1 participant