Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/workloads/v1alpha1/rolebasedgroupset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type RoleBasedGroupSetStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas
// +kubebuilder:storageversion

Choose a reason for hiding this comment

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

critical

By marking v1alpha1 as the storage version, you are establishing it as the hub for API conversions. The newly introduced v1alpha2 version has significant structural differences compared to v1alpha1, particularly in RoleBasedGroupSpec and RoleSpec.

For example:

  • v1alpha1.RoleBasedGroupSpec contains PodGroupPolicy and CoordinationRequirements, which are absent in v1alpha2.RoleBasedGroupSpec.
  • v1alpha1.RoleSpec uses TemplateSource, TemplatePatch, and LeaderWorkerSet directly, while v1alpha2.RoleSpec refactors this into an inlined Pattern struct with StandalonePattern and LeaderWorkerPattern.

Without implementing conversion webhooks, these structural differences will lead to data loss when converting between versions. For example, if a user creates a v1alpha1 resource with PodGroupPolicy and then retrieves it as v1alpha2, that field will be lost.

You need to implement the conversion.Hub and conversion.Convertible interfaces for the v1alpha1 and v1alpha2 types respectively to handle the conversion between these versions. Please add the conversion logic as part of this PR to ensure data integrity across API versions.

// +kubebuilder:printcolumn:name="DESIRED",type="string",JSONPath=".status.replicas",description="desired replicas"
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.readyReplicas",description="ready replicas"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
Expand Down
86 changes: 86 additions & 0 deletions api/workloads/v1alpha2/rolebasedgroupset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
Copyright 2025.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// RoleBasedGroupSetSpec defines the desired state of RoleBasedGroupSet.
type RoleBasedGroupSetSpec struct {
// Replicas is the number of RoleBasedGroup that will be created.
// +kubebuilder:default=1
Replicas *int32 `json:"replicas,omitempty"`

// Template describes the RoleBasedGroup that will be created.
Template RoleBasedGroupSpec `json:"template"`
}

type RoleBasedGroupSetConditionType string

const (
RoleBasedGroupSetReady RoleBasedGroupSetConditionType = "Ready"
)

// RoleBasedGroupSetStatus defines the observed state of RoleBasedGroupSet.
type RoleBasedGroupSetStatus struct {
// The generation observed by the deployment controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`

// +optional
Replicas int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"`

// +optional
ReadyReplicas int32 `json:"readyReplicas" protobuf:"varint,3,opt,name=readyReplicas"`

// Conditions track the condition of the rbgs
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas
// +kubebuilder:printcolumn:name="DESIRED",type="string",JSONPath=".status.replicas",description="desired replicas"
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.readyReplicas",description="ready replicas"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:resource:shortName={rbgs}

// RoleBasedGroupSet is the Schema for the rolebasedgroupsets API.
type RoleBasedGroupSet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec RoleBasedGroupSetSpec `json:"spec,omitempty"`
Status RoleBasedGroupSetStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// RoleBasedGroupSetList contains a list of RoleBasedGroupSet.
type RoleBasedGroupSetList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RoleBasedGroupSet `json:"items"`
}

func init() {
SchemeBuilder.Register(&RoleBasedGroupSet{}, &RoleBasedGroupSetList{})
}
102 changes: 102 additions & 0 deletions api/workloads/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions client-go/applyconfiguration/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading