Skip to content

Store applied config in stage CR status#280

Open
concaf wants to merge 2 commits into
redhat-data-and-ai:mainfrom
concaf:worktree-add-config-to-status
Open

Store applied config in stage CR status#280
concaf wants to merge 2 commits into
redhat-data-and-ai:mainfrom
concaf:worktree-add-config-to-status

Conversation

@concaf

@concaf concaf commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds appliedConfig field to DocumentProcessorStatus, ChunksGeneratorStatus, and VectorEmbeddingsGeneratorStatus
  • Each controller writes the resolved config (with defaults applied) to status on successful reconciliation
  • Makes it easy to inspect what config is actually being used, especially when relying on sane defaults

Test plan

  • make manifests generate passes
  • make lint passes (no new Go lint issues)
  • make test passes
  • Verified no tests, samples, or docs need updating (status fields are controller-populated, not user-facing in samples)

…rEmbeddingsGenerator status

Add AppliedConfig field to all three stage status structs so the
resolved defaults are visible in the CR status after a successful
reconciliation.
@concaf concaf marked this pull request as ready for review July 6, 2026 05:27
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves observability by exposing the effective configuration used by the controllers in the status of their respective custom resources. By recording the resolved configuration, users can easily verify the settings applied during reconciliation, particularly when relying on default values.

Highlights

  • Status Field Enhancement: Added an appliedConfig field to the status of DocumentProcessor, ChunksGenerator, and VectorEmbeddingsGenerator custom resources.
  • Controller Reconciliation: Updated the respective controllers to write the resolved configuration to the status during successful reconciliation cycles.
  • CRD Updates: Updated the Custom Resource Definitions to include the schema for the new appliedConfig status field.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

vinamra28
vinamra28 previously approved these changes Jul 6, 2026

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

Copy link
Copy Markdown

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 adds an AppliedConfig field to the status of ChunksGenerator, DocumentProcessor, and VectorEmbeddingsGenerator to track the applied configuration during reconciliation, along with updating the corresponding controllers, CRD schemas, and deepcopy code. The review feedback correctly points out that AppliedConfig should be defined as a pointer in the API types to allow the omitempty JSON tag to work properly. Additionally, the controllers should use .DeepCopy() instead of a direct assignment to prevent shallow copying of configuration structs that contain reference types.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread api/v1alpha1/chunksgenerator_types.go Outdated
LastAppliedGeneration int64 `json:"lastAppliedGeneration,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
FilesProcessed int64 `json:"filesProcessed,omitempty"`
AppliedConfig ChunksGeneratorConfig `json:"appliedConfig,omitempty"`

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

Defining AppliedConfig as a struct value instead of a pointer means it cannot be omitted when empty (even with omitempty), because Go's JSON encoder does not omit empty structs unless they are pointers. This results in an empty configuration block (e.g., with empty strings or zero values) being serialized in the status of newly created resources before they are ever reconciled.

Changing this to a pointer (*ChunksGeneratorConfig) allows it to be properly omitted from the status until a successful reconciliation occurs.

Suggested change
AppliedConfig ChunksGeneratorConfig `json:"appliedConfig,omitempty"`
AppliedConfig *ChunksGeneratorConfig `json:"appliedConfig,omitempty"`

Comment thread api/v1alpha1/documentprocessor_types.go Outdated
Jobs []Job `json:"jobs,omitempty"`
PermanentlyFailingFiles []string `json:"permanentlyFailingFiles,omitempty"`
FilesProcessed int64 `json:"filesProcessed,omitempty"`
AppliedConfig DocumentProcessorConfig `json:"appliedConfig,omitempty"`

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

Defining AppliedConfig as a struct value instead of a pointer means it cannot be omitted when empty (even with omitempty), because Go's JSON encoder does not omit empty structs unless they are pointers. This results in an empty configuration block (e.g., with empty strings or zero values) being serialized in the status of newly created resources before they are ever reconciled.

Changing this to a pointer (*DocumentProcessorConfig) allows it to be properly omitted from the status until a successful reconciliation occurs.

Suggested change
AppliedConfig DocumentProcessorConfig `json:"appliedConfig,omitempty"`
AppliedConfig *DocumentProcessorConfig `json:"appliedConfig,omitempty"`

LastAppliedGeneration int64 `json:"lastAppliedGeneration,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
FilesProcessed int64 `json:"filesProcessed,omitempty"`
AppliedConfig VectorEmbeddingsGeneratorConfig `json:"appliedConfig,omitempty"`

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

Defining AppliedConfig as a struct value instead of a pointer means it cannot be omitted when empty (even with omitempty), because Go's JSON encoder does not omit empty structs unless they are pointers. This results in an empty configuration block (e.g., with empty strings or zero values) being serialized in the status of newly created resources before they are ever reconciled.

Changing this to a pointer (*VectorEmbeddingsGeneratorConfig) allows it to be properly omitted from the status until a successful reconciliation occurs.

Suggested change
AppliedConfig VectorEmbeddingsGeneratorConfig `json:"appliedConfig,omitempty"`
AppliedConfig *VectorEmbeddingsGeneratorConfig `json:"appliedConfig,omitempty"`

successMessage := fmt.Sprintf("successfully reconciled chunks generator: %s", chunksGeneratorCR.Name)
if err := controllerutils.StatusPatch(ctx, r.Client, chunksGeneratorCR, func() {
chunksGeneratorCR.Status.FilesProcessed += filesProcessed
chunksGeneratorCR.Status.AppliedConfig = chunksGeneratorCR.Spec.ChunksGeneratorConfig

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

Assigning the configuration directly (chunksGeneratorCR.Status.AppliedConfig = chunksGeneratorCR.Spec.ChunksGeneratorConfig) performs a shallow copy. Since the configuration struct contains reference types (such as slices or pointers), a shallow copy will cause the Status and Spec fields to share the same underlying memory. Any subsequent mutations or updates could lead to unintended side-effects or race conditions.

Using .DeepCopy() (once AppliedConfig is updated to a pointer) ensures a safe, decoupled copy of the configuration is stored in the status.

Suggested change
chunksGeneratorCR.Status.AppliedConfig = chunksGeneratorCR.Spec.ChunksGeneratorConfig
chunksGeneratorCR.Status.AppliedConfig = chunksGeneratorCR.Spec.ChunksGeneratorConfig.DeepCopy()


successMessage := fmt.Sprintf("successfully reconciled document processor: %s", documentProcessorCR.Name)
if err := controllerutils.StatusPatch(ctx, r.Client, documentProcessorCR, func() {
documentProcessorCR.Status.AppliedConfig = documentProcessorCR.Spec.DocumentProcessorConfig

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

Assigning the configuration directly (documentProcessorCR.Status.AppliedConfig = documentProcessorCR.Spec.DocumentProcessorConfig) performs a shallow copy. Since the configuration struct contains reference types (such as slices or pointers), a shallow copy will cause the Status and Spec fields to share the same underlying memory. Any subsequent mutations or updates could lead to unintended side-effects or race conditions.

Using .DeepCopy() (once AppliedConfig is updated to a pointer) ensures a safe, decoupled copy of the configuration is stored in the status.

Suggested change
documentProcessorCR.Status.AppliedConfig = documentProcessorCR.Spec.DocumentProcessorConfig
documentProcessorCR.Status.AppliedConfig = documentProcessorCR.Spec.DocumentProcessorConfig.DeepCopy()

successMessage := fmt.Sprintf("successfully reconciled vector embeddings generator: %s", vectorEmbeddingsGeneratorCR.Name)
if err := controllerutils.StatusPatch(ctx, r.Client, vectorEmbeddingsGeneratorCR, func() {
vectorEmbeddingsGeneratorCR.Status.FilesProcessed += filesProcessed
vectorEmbeddingsGeneratorCR.Status.AppliedConfig = vectorEmbeddingsGeneratorCR.Spec.VectorEmbeddingsGeneratorConfig

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

Assigning the configuration directly (vectorEmbeddingsGeneratorCR.Status.AppliedConfig = vectorEmbeddingsGeneratorCR.Spec.VectorEmbeddingsGeneratorConfig) performs a shallow copy. Since the configuration struct contains reference types (such as slices or pointers), a shallow copy will cause the Status and Spec fields to share the same underlying memory. Any subsequent mutations or updates could lead to unintended side-effects or race conditions.

Using .DeepCopy() (once AppliedConfig is updated to a pointer) ensures a safe, decoupled copy of the configuration is stored in the status.

Suggested change
vectorEmbeddingsGeneratorCR.Status.AppliedConfig = vectorEmbeddingsGeneratorCR.Spec.VectorEmbeddingsGeneratorConfig
vectorEmbeddingsGeneratorCR.Status.AppliedConfig = vectorEmbeddingsGeneratorCR.Spec.VectorEmbeddingsGeneratorConfig.DeepCopy()

…rEmbeddingsGenerator status

Add AppliedConfig pointer field to all three stage status structs so the
resolved defaults are visible in the CR status after a successful
reconciliation. Use DeepCopy() to avoid shared slice/pointer memory
between spec and status.
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.

2 participants