Skip to content

Conversation

@qiujian16
Copy link
Member

@qiujian16 qiujian16 commented Jan 5, 2026

Replace deprecated +patchMergeKey and +patchStrategy markers with +listType=map and +listMapKey=type for condition arrays across all API versions. This ensures proper strategic merge patch behavior and aligns with current Kubernetes API conventions.

Updates CRD YAML files with corresponding x-kubernetes-list-type and x-kubernetes-list-map-keys annotations.

🤖 Generated with Claude Code

Summary

Related issue(s)

Fixes #

Summary by CodeRabbit

  • Chores
    • Updated internal API schemas across addon, cluster, operator, and work resource types to improve list field merging and validation behavior. These infrastructure-level changes enhance system reliability and consistency without affecting user-facing functionality.

✏️ Tip: You can customize this high-level summary in your review settings.

Replace deprecated +patchMergeKey and +patchStrategy markers with
+listType=map and +listMapKey=type for condition arrays across all
API versions. This ensures proper strategic merge patch behavior and
aligns with current Kubernetes API conventions.

Updates CRD YAML files with corresponding x-kubernetes-list-type
and x-kubernetes-list-map-keys annotations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Signed-off-by: Jian Qiu <[email protected]>
@openshift-ci openshift-ci bot requested review from deads2k and jnpacker January 5, 2026 06:02
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 5, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Jan 5, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

Walkthrough

This PR updates Kubernetes API definitions across multiple modules to standardize list handling by replacing patch-based merge annotations with map-based list semantics. Changes introduce x-kubernetes-list-map-keys and x-kubernetes-list-type: map annotations in CRD YAML files and replace patchMergeKey/patchStrategy markers with listType=map/listMapKey=type in Go type definitions.

Changes

Cohort / File(s) Summary
CRD YAML files - Conditions/List fields
addon/v1alpha1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml, addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml, addon/v1beta1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml, addon/v1beta1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml, cluster/v1/0000_00_clusters.open-cluster-management.io_managedclusters.crd.yaml, cluster/v1beta1/0000_02_clusters.open-cluster-management.io_placements.crd.yaml, operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml, operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml, work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml, work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml
Add x-kubernetes-list-map-keys and x-kubernetes-list-type: map to list fields (conditions, configReferences, supportedConfigs) to enable map-keyed list representation in OpenAPI schemas
Go type files - Conditions field markers
addon/v1alpha1/types_clustermanagementaddon.go, addon/v1alpha1/types_managedclusteraddon.go, addon/v1beta1/types_clustermanagementaddon.go, addon/v1beta1/types_managedclusteraddon.go, cluster/v1/types.go, cluster/v1alpha1/types_addonplacementscore.go, cluster/v1beta1/types_placement.go, operator/v1/types_clustermanager.go, operator/v1/types_klusterlet.go, work/v1/types.go, work/v1alpha1/types_manifestworkreplicaset.go
Replace patchMergeKey=type/patchStrategy=merge markers with listType=map/listMapKey=type on Conditions fields; some files remove obsolete patch annotations

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

lgtm, approved

Suggested reviewers

  • deads2k
  • mdelder

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: updating Kubernetes list type markers for condition arrays, which is the core focus across all modified files.
Description check ✅ Passed The description explains the core change (replacing deprecated markers with new ones) and mentions CRD YAML updates, though it lacks explicit section structure from the template like Related issue(s).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@elgnay
Copy link
Contributor

elgnay commented Jan 5, 2026

/lgtm

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Fix all issues with AI Agents 🤖
In @addon/v1alpha1/types_managedclusteraddon.go:
- Around line 104-107: The Conditions field still includes deprecated struct
tags patchStrategy:"merge" and patchMergeKey:"type"; remove those two tags from
the Conditions field tag so it only keeps json:"conditions,omitempty" (and any
other non-deprecated tags), while leaving the kubebuilder markers (+listType=map
and +listMapKey=type) above the field intact; update the struct field
declaration for Conditions in types_managedclusteraddon.go accordingly.

In @addon/v1beta1/types_clustermanagementaddon.go:
- Around line 175-178: The Conditions field on the Clustermanagementaddon type
still has legacy struct tags; remove the old patchStrategy:"merge" and
patchMergeKey:"type" tags from the Conditions []metav1.Condition
`json:"conditions,omitempty"  patchStrategy:"merge" patchMergeKey:"type"`
declaration so only the new markers (+listType=map and +listMapKey=type) and the
json tag remain; update the Conditions field signature to use
`json:"conditions,omitempty"` (keeping the existing markers above the field) to
complete the migration.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5102852 and 1bbb883.

📒 Files selected for processing (21)
  • addon/v1alpha1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml
  • addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml
  • addon/v1alpha1/types_clustermanagementaddon.go
  • addon/v1alpha1/types_managedclusteraddon.go
  • addon/v1beta1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml
  • addon/v1beta1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml
  • addon/v1beta1/types_clustermanagementaddon.go
  • addon/v1beta1/types_managedclusteraddon.go
  • cluster/v1/0000_00_clusters.open-cluster-management.io_managedclusters.crd.yaml
  • cluster/v1/types.go
  • cluster/v1alpha1/types_addonplacementscore.go
  • cluster/v1beta1/0000_02_clusters.open-cluster-management.io_placements.crd.yaml
  • cluster/v1beta1/types_placement.go
  • operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml
  • operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml
  • operator/v1/types_clustermanager.go
  • operator/v1/types_klusterlet.go
  • work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml
  • work/v1/types.go
  • work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml
  • work/v1alpha1/types_manifestworkreplicaset.go
💤 Files with no reviewable changes (1)
  • cluster/v1alpha1/types_addonplacementscore.go
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-01T01:10:01.745Z
Learnt from: haoqing0110
Repo: open-cluster-management-io/api PR: 407
File: addon/v1beta1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml:17-778
Timestamp: 2025-12-01T01:10:01.745Z
Learning: In the open-cluster-management-io/api repository, CRD files for addon resources (like ManagedClusterAddOn and ClusterManagementAddOn) intentionally omit conversion webhook configuration in their base definitions. The registration-operator patches these CRDs at deployment time with the appropriate webhook clientConfig and CA bundle. This is a deliberate architectural pattern to separate schema definitions from deployment-specific webhook configuration.

Applied to files:

  • addon/v1beta1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml
  • addon/v1alpha1/types_managedclusteraddon.go
  • addon/v1beta1/types_managedclusteraddon.go
  • addon/v1beta1/types_clustermanagementaddon.go
  • addon/v1alpha1/types_clustermanagementaddon.go
  • addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml
  • cluster/v1/0000_00_clusters.open-cluster-management.io_managedclusters.crd.yaml
  • work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml
  • work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml
  • operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml
  • addon/v1alpha1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml
  • addon/v1beta1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml
  • operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml
  • cluster/v1beta1/0000_02_clusters.open-cluster-management.io_placements.crd.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: integration
  • GitHub Check: verify
🔇 Additional comments (27)
work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml (3)

215-217: LGTM! Correct list-type annotations for conditionRules.

The annotations properly configure conditionRules as a map keyed by the condition field, enabling strategic merge patch semantics. This aligns with Kubernetes API conventions for list fields with unique identifiers.


456-458: LGTM! Standard Kubernetes condition list-type annotations.

The annotations correctly configure the conditions array as a map keyed by type, which is the standard pattern for Kubernetes condition arrays. This ensures proper strategic merge behavior when updating ManifestWork status.


538-540: LGTM! Consistent condition list-type annotations for manifest status.

The annotations correctly configure the nested conditions array as a map keyed by type, maintaining consistency with the top-level status conditions. This ensures proper merge behavior for per-manifest condition updates.

addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml (1)

195-197: LGTM! Proper list type annotations for conditions array.

The addition of x-kubernetes-list-map-keys and x-kubernetes-list-type: map correctly enables map-based list semantics for the conditions array, replacing the deprecated patch strategy. This ensures proper strategic merge patch behavior where conditions are keyed by their type field.

operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml (1)

853-855: LGTM! Consistent list type annotations for ClusterManager conditions.

The annotations correctly configure map-based list semantics for the conditions array, consistent with the pattern applied across other CRDs in this PR. This aligns with current Kubernetes API conventions for condition arrays.

addon/v1alpha1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml (1)

527-529: LGTM! Proper list annotations for installProgressions conditions.

The annotations correctly enable map-based list semantics for the conditions array within installProgressions. This maintains consistency with the broader pattern of updating condition arrays across the API.

operator/v1/types_clustermanager.go (1)

502-504: LGTM! Clean migration to new list type markers.

The kubebuilder markers are correctly added without any deprecated struct tag markers, demonstrating a complete and clean migration. This is the correct pattern for updating list type annotations.

cluster/v1/types.go (2)

148-150: LGTM! Correct list type markers for Conditions.

The addition of +listType=map and +listMapKey=type markers to ManagedClusterStatus.Conditions correctly replaces the deprecated patch markers and aligns with current Kubernetes API conventions for Condition arrays.


219-221: LGTM! Correct list type markers for Conditions.

The addition of +listType=map and +listMapKey=type markers to ClusterSetManagedNamespaceConfig.Conditions correctly replaces the deprecated patch markers and aligns with current Kubernetes API conventions for Condition arrays.

work/v1alpha1/types_manifestworkreplicaset.go (1)

82-84: LGTM! Correct list type markers for Conditions.

The addition of +listType=map and +listMapKey=type markers to ManifestWorkReplicaSetStatus.Conditions correctly replaces the deprecated patch markers and aligns with current Kubernetes API conventions for Condition arrays.

cluster/v1beta1/types_placement.go (1)

441-444: LGTM! Correct list type markers for Conditions.

The addition of +listType=map and +listMapKey=type markers to PlacementStatus.Conditions correctly replaces the deprecated patch markers and aligns with current Kubernetes API conventions for Condition arrays.

cluster/v1/0000_00_clusters.open-cluster-management.io_managedclusters.crd.yaml (2)

265-267: LGTM! Correct CRD annotations for map-type list.

The addition of x-kubernetes-list-map-keys and x-kubernetes-list-type: map annotations to the status.conditions array correctly implements the map-type list semantics in the CRD schema, corresponding to the kubebuilder markers added in the Go type definitions.


336-338: LGTM! Correct CRD annotations for map-type list.

The addition of x-kubernetes-list-map-keys and x-kubernetes-list-type: map annotations to the managedNamespaces[].conditions array correctly implements the map-type list semantics in the CRD schema, corresponding to the kubebuilder markers added in the Go type definitions.

work/v1/types.go (2)

473-475: LGTM! Correct list type markers for Conditions.

The addition of +listType=map and +listMapKey=type markers to ManifestWorkStatus.Conditions correctly replaces the deprecated patch markers and aligns with current Kubernetes API conventions for Condition arrays.


543-545: LGTM! Correct list type markers for Conditions.

The addition of +listType=map and +listMapKey=type markers to ManifestCondition.Conditions correctly replaces the deprecated patch markers and aligns with current Kubernetes API conventions for Condition arrays.

operator/v1/types_klusterlet.go (1)

361-363: LGTM! Standard Kubernetes API convention applied correctly.

The addition of +listType=map and +listMapKey=type markers is the correct approach for Condition arrays, replacing deprecated patch merge markers and aligning with current Kubernetes API conventions.

work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml (1)

726-728: LGTM! CRD schema correctly updated for map-based list semantics.

The addition of x-kubernetes-list-type: map and x-kubernetes-list-map-keys annotations ensures proper strategic merge patch behavior for the conditions array.

addon/v1alpha1/types_clustermanagementaddon.go (1)

214-217: LGTM! Markers updated correctly while preserving struct tags.

The new +listType=map and +listMapKey=type comment markers are correctly added for CRD generation, while the existing struct tags are properly retained for JSON encoding.

addon/v1beta1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml (2)

527-529: LGTM! v1alpha1 CRD schema correctly updated.

The map-based list annotations are properly added to the conditions field in the v1alpha1 version.


1104-1106: LGTM! v1beta1 CRD schema consistently updated.

The v1beta1 version correctly mirrors the same map-based list semantics as v1alpha1, ensuring consistency across API versions.

addon/v1beta1/types_managedclusteraddon.go (1)

136-139: LGTM! Correctly updated with proper marker and tag separation.

The +listType=map and +listMapKey=type markers are correctly added for CRD schema generation, while the struct tags for JSON encoding are appropriately retained.

cluster/v1beta1/0000_02_clusters.open-cluster-management.io_placements.crd.yaml (1)

604-606: LGTM!

The CRD schema annotations correctly specify map-based list semantics for the conditions array, enabling proper strategic merge patch behavior with type as the map key.

operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml (1)

594-596: LGTM!

The CRD schema annotations are correctly applied to the status.conditions array, consistent with the pattern used across other CRDs in this PR.

addon/v1beta1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml (4)

195-197: LGTM!

The CRD schema annotations correctly implement map-based list semantics for the v1alpha1 status.conditions array.


393-396: LGTM!

The supportedConfigs array correctly uses composite map keys (group and resource) for map-based merging, which aligns with the ConfigGroupResource structure.


551-553: LGTM!

The CRD schema annotations correctly implement map-based list semantics for the v1beta1 status.conditions array, consistent with the v1alpha1 version.


764-767: LGTM!

The supportedConfigs array in v1beta1 correctly uses composite map keys (group and resource), maintaining consistency with the v1alpha1 version.

Comment on lines +104 to 107
// +listType=map
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove deprecated struct tag markers.

The struct field still contains the deprecated patchStrategy:"merge" and patchMergeKey:"type" in the struct tag. Since you've added the new kubebuilder markers (+listType=map and +listMapKey=type), the old struct tag markers should be removed for consistency.

🔎 Proposed fix
 // conditions describe the state of the managed and monitored components for the operator.
 // +listType=map
 // +listMapKey=type
 // +optional
-Conditions []metav1.Condition `json:"conditions,omitempty"  patchStrategy:"merge" patchMergeKey:"type"`
+Conditions []metav1.Condition `json:"conditions,omitempty"`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// +listType=map
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
// +listType=map
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
🤖 Prompt for AI Agents
In @addon/v1alpha1/types_managedclusteraddon.go around lines 104-107, The
Conditions field still includes deprecated struct tags patchStrategy:"merge" and
patchMergeKey:"type"; remove those two tags from the Conditions field tag so it
only keeps json:"conditions,omitempty" (and any other non-deprecated tags),
while leaving the kubebuilder markers (+listType=map and +listMapKey=type) above
the field intact; update the struct field declaration for Conditions in
types_managedclusteraddon.go accordingly.

Comment on lines +175 to 178
// +listType=map
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for other Conditions fields in the codebase to check the pattern
rg -n -A1 -B1 'Conditions\s+\[\]metav1\.Condition' --type=go

Repository: open-cluster-management-io/api

Length of output: 3360


Remove old struct tags now that new markers are in place.

The new markers +listType=map and +listMapKey=type have been added, but the old struct tags patchStrategy:"merge" patchMergeKey:"type" remain. This file is the only one in the codebase mixing both approaches. The rest of the codebase uses only the new markers (e.g., work/v1, operator/v1, cluster/v1) or only the old tags (other addon files not yet migrated). Remove the old struct tags to align with the modern Kubernetes API conventions and complete the migration to the new markers.

🤖 Prompt for AI Agents
In @addon/v1beta1/types_clustermanagementaddon.go around lines 175-178, The
Conditions field on the Clustermanagementaddon type still has legacy struct
tags; remove the old patchStrategy:"merge" and patchMergeKey:"type" tags from
the Conditions []metav1.Condition `json:"conditions,omitempty" 
patchStrategy:"merge" patchMergeKey:"type"` declaration so only the new markers
(+listType=map and +listMapKey=type) and the json tag remain; update the
Conditions field signature to use `json:"conditions,omitempty"` (keeping the
existing markers above the field) to complete the migration.

@openshift-merge-bot openshift-merge-bot bot merged commit 7b34437 into open-cluster-management-io:main Jan 5, 2026
12 checks passed
@qiujian16 qiujian16 deleted the update-list-type-markers branch January 5, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants