Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

Add cluster reference to ClusterOrder.status - #8

Merged
larsks merged 2 commits into
osac-project:mainfrom
larsks:feature/cluster-reference
Mar 27, 2025
Merged

larsks merged 2 commits into
osac-project:mainfrom
larsks:feature/cluster-reference

Conversation

@larsks

@larsks larsks commented Mar 26, 2025

Copy link
Copy Markdown
Member

Add a clusterReference field to clusterOrder.status that records the namespace, cluster name, and service account name created by the controller in response to a ClusterOrder.

Summary by CodeRabbit

  • New Features
    • Enhanced order validations with a strict naming convention for template identifiers.
    • Added mandatory cluster reference details in the order status, requiring specific namespace and account information.
    • Refined order status phases with a clear set of allowed values to improve progress tracking.
  • Bug Fixes
    • Removed deprecated condition tracking for node pool availability.
  • Documentation
    • Updated Custom Resource Definition (CRD) to reflect new validation and structural requirements for ClusterOrder.

Add kubebuilder validation markers [1] to ClusterOrder type definitions.

[1]: https://book.kubebuilder.io/reference/markers/crd-validation.html
@larsks
larsks requested a review from mhrivnak March 26, 2025 15:38
@coderabbitai

coderabbitai Bot commented Mar 26, 2025

Copy link
Copy Markdown

Walkthrough

The changes modify the ClusterOrder API across its types, deep copy functions, and CRD definition. In the API types, additional validation annotations have been added to the TemplateID and Phase fields to enforce required presence, type constraints, and specific value patterns or enumerations. A new struct, ClusterOrderClusterReferenceType, has been introduced with fields to reference associated cluster details, and a corresponding field has been added to ClusterOrderStatus. Furthermore, an obsolete condition constant has been removed from the set of tracked conditions. Updates in the deep copy implementations ensure that the new cluster reference field is correctly handled. Lastly, the CRD YAML has been updated to include the new validation rules and structure changes, requiring specific patterns, enumerated values, and the presence of the new cluster reference properties.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment thread api/v1alpha1/clusterorder_types.go Outdated
Comment thread api/v1alpha1/clusterorder_types.go Outdated
Comment thread api/v1alpha1/clusterorder_types.go Outdated
@larsks
larsks requested a review from mhrivnak March 26, 2025 16:21
Comment thread api/v1alpha1/clusterorder_types.go Outdated
@larsks

larsks commented Mar 26, 2025

Copy link
Copy Markdown
Member Author

@mhrivnak good catch; I've also marked phase and conditions as optional, which matches e.g. the Pod API.

@larsks
larsks requested a review from mhrivnak March 26, 2025 18:09

@coderabbitai coderabbitai 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
api/v1alpha1/zz_generated.deepcopy.go (1)

1-139: Reminder: This is an auto-generated file

This file is auto-generated by controller-gen as indicated by the comment on line 19. The changes appear to be correctly generated based on the addition of the ClusterReference field to ClusterOrderStatus. In normal circumstances, this file should not be manually edited.

If any modifications are needed to the deep copy behavior, they should be made in the source files defining the types (like clusterorder_types.go), and then the deep copy code should be regenerated.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f02ef9 and 8a67d35.

📒 Files selected for processing (3)
  • api/v1alpha1/clusterorder_types.go (2 hunks)
  • api/v1alpha1/zz_generated.deepcopy.go (2 hunks)
  • config/crd/bases/cloudkit.openshift.io_clusterorders.yaml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • config/crd/bases/cloudkit.openshift.io_clusterorders.yaml
  • api/v1alpha1/clusterorder_types.go
🧰 Additional context used
🧬 Code Definitions (1)
api/v1alpha1/zz_generated.deepcopy.go (1)
api/v1alpha1/clusterorder_types.go (1)
  • ClusterOrderClusterReferenceType (74-79)
🔇 Additional comments (2)
api/v1alpha1/zz_generated.deepcopy.go (2)

55-68: Looks good: DeepCopy methods for ClusterOrderClusterReferenceType

The newly added methods for deep copying the ClusterOrderClusterReferenceType are consistent with the standard auto-generated pattern. Since this struct contains only string fields (as seen in the relevant code snippet), the simple copy implementation is sufficient.


127-127: Correctly handles new ClusterReference field

The update to ClusterOrderStatus.DeepCopyInto correctly adds the handling of the new ClusterReference field, ensuring proper deep copying of the entire status object.

Add a `clusterReference` field to ClusterOrder.status that records the
namespace, cluster name, and service account name created by the controller
in response to a ClusterOrder.

@coderabbitai coderabbitai 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
api/v1alpha1/clusterorder_types.go (1)

73-79: Structured cluster reference type

The new ClusterOrderClusterReferenceType struct provides a clean, structured way to reference the created cluster resources.

One potential improvement would be to add some kubebuilder validation annotations to ensure these fields are required when the ClusterReference is present.

type ClusterOrderClusterReferenceType struct {
	// Namespace that contains the HostedCluster resource
+	// +kubebuilder:validation:Required
	Namespace          string `json:"namespace"`
+	// +kubebuilder:validation:Required
	HostedClusterName  string `json:"hostedClusterName"`
+	// +kubebuilder:validation:Required
	ServiceAccountName string `json:"serviceAccountName"`
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a67d35 and 727d1e7.

📒 Files selected for processing (3)
  • api/v1alpha1/clusterorder_types.go (2 hunks)
  • api/v1alpha1/zz_generated.deepcopy.go (2 hunks)
  • config/crd/bases/cloudkit.openshift.io_clusterorders.yaml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/crd/bases/cloudkit.openshift.io_clusterorders.yaml
🧰 Additional context used
🧬 Code Definitions (1)
api/v1alpha1/zz_generated.deepcopy.go (1)
api/v1alpha1/clusterorder_types.go (1)
  • ClusterOrderClusterReferenceType (74-79)
🔇 Additional comments (6)
api/v1alpha1/zz_generated.deepcopy.go (2)

55-68: The new deep copy functions for ClusterOrderClusterReferenceType look good

The implementation correctly handles deep copying for the new ClusterOrderClusterReferenceType struct. Since this struct only contains primitive string types, the simple *out = *in assignment in DeepCopyInto is sufficient.


127-131: Proper handling of the new ClusterReference field

The conditional update to ClusterOrderStatus.DeepCopyInto correctly handles the new optional ClusterReference field by creating a new instance when the source field is non-nil and copying its contents.

api/v1alpha1/clusterorder_types.go (4)

30-33: Good validation for TemplateID

The added validation annotations for the TemplateID field are appropriate:

  • Making it required ensures every ClusterOrder has a template
  • The pattern validation enforces a valid naming convention (must start with lowercase letter, contain only lowercase letters, numbers, and hyphens, and end with a lowercase letter or number)

84-87: Appropriate enum validation for Phase

The validation annotations for the Phase field properly restrict it to the defined enum values, which matches the constants defined above. Marking it as optional aligns with Kubernetes API conventions for status fields.


90-91: Optional conditions field follows K8s conventions

Making the Conditions field optional aligns with Kubernetes API conventions, as mentioned in the PR comments. This matches how condition fields are handled in other Kubernetes resources like Pods.


93-96: ClusterReference implementation follows best practices

The new ClusterReference field:

  • Is properly marked as optional with both the annotation and pointer type
  • Has a clear comment explaining its purpose
  • Uses a pointer type which follows K8s conventions for optional fields

This implementation satisfies the PR objective of tracking the namespace, cluster name, and service account created by the controller.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants