Skip to content

feat: add observedGeneration for better visibility#99

Open
cwrau wants to merge 1 commit intomainfrom
feat/add-generation
Open

feat: add observedGeneration for better visibility#99
cwrau wants to merge 1 commit intomainfrom
feat/add-generation

Conversation

@cwrau
Copy link
Member

@cwrau cwrau commented Feb 9, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 9, 2026 10:54
@cwrau cwrau enabled auto-merge February 9, 2026 10:54
@gemini-code-assist
Copy link

Summary of Changes

Hello @cwrau, 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 enhances the HostedControlPlane custom resource by incorporating an observedGeneration field into its status. This addition is a crucial step for improving the observability and reliability of the resource, as it allows users and other controllers to ascertain whether the reported status corresponds to the most recently processed desired state. By updating this field during each reconciliation cycle, the controller provides a clear signal that it has acknowledged and acted upon the latest configuration changes.

Highlights

  • API Definition Update: Introduced a new ObservedGeneration field of type int64 to the HostedControlPlaneStatus struct in api/v1alpha1/hostedcontrolplane_types.go. This field is marked as optional and will be omitted if empty, aligning with standard Kubernetes API practices for status fields.
  • Controller Logic Enhancement: Modified the Reconcile function in pkg/hostedcontrolplane/controller.go to set the hostedControlPlane.Status.ObservedGeneration to the current hostedControlPlane.Generation before patching the status. This ensures that the reported status accurately reflects the generation of the observed specification, providing better visibility into the controller's reconciliation progress.
Changelog
  • api/v1alpha1/hostedcontrolplane_types.go
    • Added ObservedGeneration int64 field to the HostedControlPlaneStatus struct, including +kubebuilder:validation:Optional and json:"observedGeneration,omitempty" tags.
  • pkg/hostedcontrolplane/controller.go
    • Inserted a line hostedControlPlane.Status.ObservedGeneration = hostedControlPlane.Generation within the defer block of the Reconcile function, ensuring the status's observed generation is updated before the status patch operation.
Activity
  • No human activity has been recorded on this pull request yet.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link

@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 the observedGeneration field to the HostedControlPlaneStatus to provide better visibility into the reconciliation state of the resource. While the field is correctly added to the API type, its implementation in the controller is flawed. The observedGeneration is updated within a defer block that executes on all reconciliation exit paths, not just successful ones. This can lead to an incorrect status that misrepresents the controller's state, suggesting that a spec change has been reconciled when it has not. I have left a comment detailing the issue and suggesting a fix.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a standard Kubernetes visibility field (status.observedGeneration) to HostedControlPlane and updates the controller to populate it during reconciliation, improving consumers’ ability to see which spec generation the controller has observed.

Changes:

  • Add ObservedGeneration to HostedControlPlaneStatus.
  • Set status.observedGeneration = metadata.generation when reconciling a HostedControlPlane.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/hostedcontrolplane/controller.go Populates status.observedGeneration during the deferred patch at the end of reconcile.
api/v1alpha1/hostedcontrolplane_types.go Extends the CRD Go types to include status.observedGeneration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cwrau cwrau force-pushed the feat/add-generation branch from 6c1e35c to 5d62f64 Compare February 11, 2026 11:33
Copilot AI review requested due to automatic review settings February 11, 2026 15:06
@cwrau cwrau force-pushed the feat/add-generation branch from 5d62f64 to 2aa0e77 Compare February 11, 2026 15:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant