Skip to content

Commit 916068d

Browse files
committed
chore: fix the bug of dynamically setting the flat instance ordinal
1 parent 2350293 commit 916068d

File tree

13 files changed

+32
-20
lines changed

13 files changed

+32
-20
lines changed

apis/apps/v1/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ type InstanceTemplate struct {
778778
// then the instance names generated under this InstanceTemplate would be
779779
// $(cluster.name)-$(component.name)-$(template.name)-0、$(cluster.name)-$(component.name)-$(template.name)-1 and
780780
// $(cluster.name)-$(component.name)-$(template.name)-7
781+
//
782+
// +optional
781783
Ordinals Ordinals `json:"ordinals,omitempty"`
782784

783785
// Specifies a map of key-value pairs to be merged into the Pod's existing annotations.

apis/operations/v1alpha1/opsrequest_validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ func (r *OpsRequest) getSCNameByPvcAndCheckStorageSize(ctx context.Context,
747747
}
748748
var pvc *corev1.PersistentVolumeClaim
749749
for _, pvcItem := range pvcList.Items {
750-
if targetInsTPLName == pvcItem.Labels[constant.KBAppComponentInstanceTemplateLabelKey] {
750+
if targetInsTPLName == pvcItem.Labels[constant.KBAppInstanceTemplateLabelKey] {
751751
pvc = &pvcItem
752752
break
753753
}

apis/workloads/v1/instanceset_types.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ const (
3838
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas
3939
// +kubebuilder:storageversion
4040
// +kubebuilder:resource:categories={kubeblocks},shortName=its
41-
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.readyReplicas",description="ready replicas."
4241
// +kubebuilder:printcolumn:name="DESIRED",type="string",JSONPath=".spec.replicas",description="desired replicas."
4342
// +kubebuilder:printcolumn:name="UP-TO-DATE",type="string",JSONPath=".status.updatedReplicas",description="updated replicas."
43+
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.readyReplicas",description="ready replicas."
4444
// +kubebuilder:printcolumn:name="AVAILABLE",type="string",JSONPath=".status.availableReplicas",description="available replicas, which are ready for at least minReadySeconds."
4545
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
4646

@@ -266,11 +266,14 @@ type InstanceSetStatus struct {
266266
Replicas int32 `json:"replicas"`
267267

268268
// Ordinals is the ordinals used by the instances of the InstanceSet except the template instances.
269+
//
269270
// +optional
270271
Ordinals []int32 `json:"ordinals,omitempty"`
271272

272273
// readyReplicas is the number of instances created for this InstanceSet with a Ready Condition.
273-
ReadyReplicas int32 `json:"readyReplicas,omitempty"`
274+
//
275+
// +optional
276+
ReadyReplicas int32 `json:"readyReplicas"`
274277

275278
// currentReplicas is the number of instances created by the InstanceSet controller from the InstanceSet version
276279
// indicated by CurrentRevisions.

config/crd/bases/workloads.kubeblocks.io_instancesets.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ spec:
2020
scope: Namespaced
2121
versions:
2222
- additionalPrinterColumns:
23-
- description: ready replicas.
24-
jsonPath: .status.readyReplicas
25-
name: READY
26-
type: string
2723
- description: desired replicas.
2824
jsonPath: .spec.replicas
2925
name: DESIRED
@@ -32,6 +28,10 @@ spec:
3228
jsonPath: .status.updatedReplicas
3329
name: UP-TO-DATE
3430
type: string
31+
- description: ready replicas.
32+
jsonPath: .status.readyReplicas
33+
name: READY
34+
type: string
3535
- description: available replicas, which are ready for at least minReadySeconds.
3636
jsonPath: .status.availableReplicas
3737
name: AVAILABLE

controllers/apps/cluster/transformer_cluster_component.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ func copyAndMergeComponent(oldCompObj, newCompObj *appsv1.Component) *appsv1.Com
277277
compObjCopy.Spec.SchedulingPolicy = compProto.Spec.SchedulingPolicy
278278
compObjCopy.Spec.TLSConfig = compProto.Spec.TLSConfig
279279
compObjCopy.Spec.Instances = compProto.Spec.Instances
280+
compObjCopy.Spec.FlatInstanceOrdinal = compProto.Spec.FlatInstanceOrdinal
280281
compObjCopy.Spec.OfflineInstances = compProto.Spec.OfflineInstances
281282
compObjCopy.Spec.RuntimeClassName = compProto.Spec.RuntimeClassName
282283
compObjCopy.Spec.DisableExporter = compProto.Spec.DisableExporter

controllers/apps/component/transformer_component_workload.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ func copyAndMergeITS(oldITS, newITS *workloads.InstanceSet) *workloads.InstanceS
349349
itsObjCopy.Spec.MembershipReconfiguration = itsProto.Spec.MembershipReconfiguration
350350
itsObjCopy.Spec.TemplateVars = itsProto.Spec.TemplateVars
351351
itsObjCopy.Spec.Instances = itsProto.Spec.Instances
352+
itsObjCopy.Spec.FlatInstanceOrdinal = itsProto.Spec.FlatInstanceOrdinal
352353
itsObjCopy.Spec.OfflineInstances = itsProto.Spec.OfflineInstances
353354
itsObjCopy.Spec.MinReadySeconds = itsProto.Spec.MinReadySeconds
354355
itsObjCopy.Spec.VolumeClaimTemplates = itsProto.Spec.VolumeClaimTemplates

controllers/apps/shardingdefinition_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ func (r *ShardingDefinitionReconciler) Reconcile(ctx context.Context, req ctrl.R
8585
}
8686

8787
if err := r.validate(r.Client, reqCtx, shardingDef); err != nil {
88-
fmt.Printf("error: %v\n", err)
8988
if err1 := r.unavailable(reqCtx, shardingDef, err); err1 != nil {
9089
return intctrlutil.CheckedRequeueWithError(err1, reqCtx.Log, "")
9190
}

deploy/helm/crds/workloads.kubeblocks.io_instancesets.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ spec:
2020
scope: Namespaced
2121
versions:
2222
- additionalPrinterColumns:
23-
- description: ready replicas.
24-
jsonPath: .status.readyReplicas
25-
name: READY
26-
type: string
2723
- description: desired replicas.
2824
jsonPath: .spec.replicas
2925
name: DESIRED
@@ -32,6 +28,10 @@ spec:
3228
jsonPath: .status.updatedReplicas
3329
name: UP-TO-DATE
3430
type: string
31+
- description: ready replicas.
32+
jsonPath: .status.readyReplicas
33+
name: READY
34+
type: string
3535
- description: available replicas, which are ready for at least minReadySeconds.
3636
jsonPath: .status.availableReplicas
3737
name: AVAILABLE

docs/developer_docs/api-reference/cluster.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7964,6 +7964,7 @@ Ordinals
79647964
</em>
79657965
</td>
79667966
<td>
7967+
<em>(Optional)</em>
79677968
<p>Specifies the desired Ordinals of this InstanceTemplate.
79687969
The Ordinals used to specify the ordinal of the instance (pod) names to be generated under this InstanceTemplate.
79697970
If Ordinals are defined, their number must be equal to or more than the corresponding replicas.</p>
@@ -30538,6 +30539,7 @@ int32
3053830539
</em>
3053930540
</td>
3054030541
<td>
30542+
<em>(Optional)</em>
3054130543
<p>readyReplicas is the number of instances created for this InstanceSet with a Ready Condition.</p>
3054230544
</td>
3054330545
</tr>

pkg/constant/labels.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ const (
4444
KBAppComponentLabelKey = "apps.kubeblocks.io/component-name"
4545
KBAppShardingNameLabelKey = "apps.kubeblocks.io/sharding-name"
4646

47-
KBAppComponentInstanceTemplateLabelKey = "apps.kubeblocks.io/instance-template"
48-
PVCNameLabelKey = "apps.kubeblocks.io/pvc-name"
49-
VolumeClaimTemplateNameLabelKey = "apps.kubeblocks.io/vct-name"
50-
KBAppPodNameLabelKey = "apps.kubeblocks.io/pod-name"
47+
KBAppInstanceTemplateLabelKey = "apps.kubeblocks.io/instance-template"
48+
PVCNameLabelKey = "apps.kubeblocks.io/pvc-name"
49+
VolumeClaimTemplateNameLabelKey = "apps.kubeblocks.io/vct-name"
50+
KBAppPodNameLabelKey = "apps.kubeblocks.io/pod-name"
5151

5252
RoleLabelKey = "kubeblocks.io/role" // RoleLabelKey consensusSet and replicationSet role label key
5353
KBAppServiceVersionKey = "apps.kubeblocks.io/service-version"

0 commit comments

Comments
 (0)