Skip to content

Commit 2cb78a8

Browse files
committed
Merge branch 'main' into support/hscale-in-its
2 parents c0e0a66 + 75abb7d commit 2cb78a8

File tree

11 files changed

+83
-3
lines changed

11 files changed

+83
-3
lines changed

apis/apps/v1/componentdefinition_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,11 @@ type ComponentVars struct {
867867
//
868868
// +optional
869869
PodFQDNsForRole *RoledVar `json:"podFQDNsForRole,omitempty"`
870+
871+
// Reference to the service version of the component.
872+
//
873+
// +optional
874+
ServiceVersion *VarOption `json:"serviceVersion,omitempty"`
870875
}
871876

872877
// ClusterVarSelector selects a var from a Cluster.

apis/apps/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/apps.kubeblocks.io_componentdefinitions.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19105,6 +19105,13 @@ spec:
1910519105
- Required
1910619106
- Optional
1910719107
type: string
19108+
serviceVersion:
19109+
description: Reference to the service version of the
19110+
component.
19111+
enum:
19112+
- Required
19113+
- Optional
19114+
type: string
1910819115
shortName:
1910919116
description: Reference to the short name of the Component
1911019117
object.

config/crd/bases/apps.kubeblocks.io_sidecardefinitions.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,13 @@ spec:
17621762
- Required
17631763
- Optional
17641764
type: string
1765+
serviceVersion:
1766+
description: Reference to the service version of the
1767+
component.
1768+
enum:
1769+
- Required
1770+
- Optional
1771+
type: string
17651772
shortName:
17661773
description: Reference to the short name of the Component
17671774
object.

controllers/operations/opsrequest_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ func (r *OpsRequestReconciler) parseRunningOpsRequests(ctx context.Context, obje
434434
if cluster.IsDeleting() {
435435
// if the cluster is deleting, we should enqueue all the opsRequests in this cluster.
436436
opsList := &opsv1alpha1.OpsRequestList{}
437-
_ = r.Client.List(ctx, opsList, client.InNamespace(cluster.Namespace), client.MatchingFields{
437+
_ = r.Client.List(ctx, opsList, client.InNamespace(cluster.Namespace), client.MatchingLabels{
438438
constant.AppInstanceLabelKey: cluster.Name,
439439
})
440440
var requests []reconcile.Request

deploy/helm/crds/apps.kubeblocks.io_componentdefinitions.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19105,6 +19105,13 @@ spec:
1910519105
- Required
1910619106
- Optional
1910719107
type: string
19108+
serviceVersion:
19109+
description: Reference to the service version of the
19110+
component.
19111+
enum:
19112+
- Required
19113+
- Optional
19114+
type: string
1910819115
shortName:
1910919116
description: Reference to the short name of the Component
1911019117
object.

deploy/helm/crds/apps.kubeblocks.io_sidecardefinitions.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,13 @@ spec:
17621762
- Required
17631763
- Optional
17641764
type: string
1765+
serviceVersion:
1766+
description: Reference to the service version of the
1767+
component.
1768+
enum:
1769+
- Required
1770+
- Optional
1771+
type: string
17651772
shortName:
17661773
description: Reference to the short name of the Component
17671774
object.

docs/developer_docs/api-reference/cluster.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7165,6 +7165,20 @@ RoledVar
71657165
The value will be presented in the following format: FQDN1,FQDN2,&hellip;</p>
71667166
</td>
71677167
</tr>
7168+
<tr>
7169+
<td>
7170+
<code>serviceVersion</code><br/>
7171+
<em>
7172+
<a href="#apps.kubeblocks.io/v1.VarOption">
7173+
VarOption
7174+
</a>
7175+
</em>
7176+
</td>
7177+
<td>
7178+
<em>(Optional)</em>
7179+
<p>Reference to the service version of the component.</p>
7180+
</td>
7181+
</tr>
71687182
</tbody>
71697183
</table>
71707184
<h3 id="apps.kubeblocks.io/v1.ComponentVersionCompatibilityRule">ComponentVersionCompatibilityRule

pkg/controller/component/vars.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,8 @@ func resolveComponentVarRef(ctx context.Context, cli client.Reader, synthesizedC
11451145
resolveFunc = resolveComponentPodsRef
11461146
case selector.PodNamesForRole != nil || selector.PodFQDNsForRole != nil:
11471147
resolveFunc = resolveComponentPodsForRoleRef
1148+
case selector.ServiceVersion != nil:
1149+
resolveFunc = resolveComponentServiceVersionRef
11481150
default:
11491151
return nil, nil, nil
11501152
}
@@ -1296,6 +1298,15 @@ func componentVarPodsWithRoleGetter(ctx context.Context, cli client.Reader,
12961298
return strings.Join(names, ","), nil
12971299
}
12981300

1301+
func resolveComponentServiceVersionRef(ctx context.Context, cli client.Reader, synthesizedComp *SynthesizedComponent,
1302+
defineKey string, selector appsv1.ComponentVarSelector) ([]*corev1.EnvVar, []*corev1.EnvVar, error) {
1303+
resolveServiceVersion := func(obj any) (*corev1.EnvVar, *corev1.EnvVar, error) {
1304+
comp := obj.(*appsv1.Component)
1305+
return &corev1.EnvVar{Name: defineKey, Value: comp.Spec.ServiceVersion}, nil, nil
1306+
}
1307+
return resolveComponentVarRefLow(ctx, cli, synthesizedComp, selector.ClusterObjectReference, selector.ServiceVersion, resolveServiceVersion)
1308+
}
1309+
12991310
func resolveComponentVarRefLow(ctx context.Context, cli client.Reader, synthesizedComp *SynthesizedComponent,
13001311
objRef appsv1.ClusterObjectReference, option *appsv1.VarOption, resolveVar func(any) (*corev1.EnvVar, *corev1.EnvVar, error)) ([]*corev1.EnvVar, []*corev1.EnvVar, error) {
13011312
resolveObjs := func() (map[string]any, error) {

pkg/controller/component/vars_test.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,20 @@ var _ = Describe("vars", func() {
18551855
},
18561856
},
18571857
},
1858+
{
1859+
Name: "serviceVersion",
1860+
ValueFrom: &appsv1.VarSource{
1861+
ComponentVarRef: &appsv1.ComponentVarSelector{
1862+
ClusterObjectReference: appsv1.ClusterObjectReference{
1863+
CompDef: synthesizedComp.CompDefName,
1864+
Optional: required(),
1865+
},
1866+
ComponentVars: appsv1.ComponentVars{
1867+
ServiceVersion: &appsv1.VarRequired,
1868+
},
1869+
},
1870+
},
1871+
},
18581872
}
18591873
podName := func(suffix string) string {
18601874
return fmt.Sprintf("%s-%s", constant.GenerateClusterComponentName(synthesizedComp.ClusterName, synthesizedComp.Name), suffix)
@@ -1868,8 +1882,9 @@ var _ = Describe("vars", func() {
18681882
Name: constant.GenerateClusterComponentName(synthesizedComp.ClusterName, synthesizedComp.Name),
18691883
},
18701884
Spec: appsv1.ComponentSpec{
1871-
CompDef: synthesizedComp.CompDefName,
1872-
Replicas: 3,
1885+
CompDef: synthesizedComp.CompDefName,
1886+
Replicas: 3,
1887+
ServiceVersion: "v3.6.5",
18731888
},
18741889
},
18751890
&corev1.Pod{
@@ -1936,6 +1951,7 @@ var _ = Describe("vars", func() {
19361951
checkEnvVarWithValue(envVars, "podFQDNs", strings.Join(fqdnList(), ","))
19371952
checkEnvVarWithValue(envVars, "podFQDNs4Leader",
19381953
intctrlutil.PodFQDN(synthesizedComp.Namespace, synthesizedComp.FullCompName, podName("leader")))
1954+
checkEnvVarWithValue(envVars, "serviceVersion", "v3.6.5")
19391955
})
19401956
})
19411957

0 commit comments

Comments
 (0)