Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ca9099d
immutable statefulSet selectorLabels
kobzonega Jan 22, 2024
ef1a161
bump helm chart version
kobzonega Jan 23, 2024
35341d7
Merge branch 'master' into YDBOPS-7162
kobzonega Jan 24, 2024
ce7d09a
Update label.go
kobzonega Jan 24, 2024
2faa8b1
Update storage_statefulset.go
kobzonega Jan 24, 2024
063996c
Merge remote-tracking branch 'origin' into YDBOPS-7162
kobzonega May 10, 2024
4891105
statefulset labels and annotations in resourceBuilder params
kobzonega May 10, 2024
897687c
remove generation label
kobzonega May 13, 2024
21c2396
YDBOPS-9635 use configMap from Storage if Database .spec.configuratio…
kobzonega May 13, 2024
ab5f716
bump chart version for PR #199 (#206)
kobzonega May 13, 2024
876aace
YDBOPS-9613 conditions for NodeSet objects (#197)
kobzonega May 13, 2024
75ae125
YDBOPS-9612 conditions for Storage and Database objects (#204)
kobzonega May 13, 2024
f34083f
YDBOPS-9680 node `--label` command line args `deployment` and `shared…
kobzonega May 14, 2024
d90e12e
YDBOPS-9691 fix GRPC TLS certificates in dynnodes (#207)
kobzonega May 14, 2024
f0fa619
YDBOPS-9691 use global ca-certificates.crt for database (#208)
kobzonega May 14, 2024
b3343c8
bump golang to version 1.20 (#216)
kobzonega Jun 14, 2024
5b2caca
YDBOPS-9722 fillMissingSections for ConfigMap on operator upgrade (#210)
kobzonega Jun 14, 2024
f7f0c5a
fix golang library versions for github workflow (#218)
kobzonega Jun 14, 2024
7c30d3b
single quotation go version (#219)
kobzonega Jun 14, 2024
2d61532
Fix home env GitHub runner (#220)
kobzonega Jun 14, 2024
29ada6b
add TLS support for status service (#215)
nikitka Jun 17, 2024
4648683
bump e2e tests timeout to 1 hour (#222)
kobzonega Jun 17, 2024
5e1e99a
oauth2 token exchange credentials (#213)
kobzonega Jun 17, 2024
7a506de
YDBOPS-9608 support dynconfig (#200)
kobzonega Jun 17, 2024
dd9eec1
Merge remote-tracking branch 'origin' into YDBOPS-7162
kobzonega Jun 25, 2024
6cdfd93
fixe nodeSet labels
kobzonega Jun 25, 2024
ce24aa0
compare maps without reflect
kobzonega Jun 25, 2024
4287a42
waitForStatefulSet label selector match
kobzonega Jun 26, 2024
b3a278a
bump helm chart
kobzonega Jun 26, 2024
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
4 changes: 2 additions & 2 deletions deploy/ydb-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.5.15
version: 0.5.16

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.5.15"
appVersion: "0.5.16"
28 changes: 9 additions & 19 deletions internal/controllers/database/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,42 +322,32 @@ func (r *Reconciler) waitForStatefulSetToScale(
r.Recorder.Event(
database,
corev1.EventTypeWarning,
"ProvisioningFailed",
fmt.Sprintf("Failed to get StatefulSets: %s", err),
"ControllerError",
fmt.Sprintf("Failed to get StatefulSet: %s", err),
)
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
}

podLabels := labels.Common(database.Name, make(map[string]string))
podLabels.Merge(map[string]string{
labels.ComponentKey: labels.DynamicComponent,
})

matchingLabels := client.MatchingLabels{}
for k, v := range podLabels {
matchingLabels[k] = v
}

podList := &corev1.PodList{}
opts := []client.ListOption{
client.InNamespace(database.Namespace),
matchingLabels,
client.MatchingLabels{labels.StatefulsetComponent: database.Name},
}

err = r.List(ctx, podList, opts...)
if err != nil {
r.Recorder.Event(
database,
corev1.EventTypeWarning,
"ProvisioningFailed",
fmt.Sprintf("Failed to list cluster pods: %s", err),
"ControllerError",
fmt.Sprintf("Failed to list StatefulSet pods: %s", err),
)
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
}

runningPods := 0
for _, e := range podList.Items {
if e.Status.Phase == "Running" {
if resources.PodIsReady(e) {
runningPods++
}
}
Expand All @@ -367,13 +357,13 @@ func (r *Reconciler) waitForStatefulSetToScale(
database,
corev1.EventTypeNormal,
string(DatabaseProvisioning),
fmt.Sprintf("Waiting for number of running dynamic pods to match expected: %d != %d", runningPods, database.Spec.Nodes),
fmt.Sprintf("Waiting for number of running pods to match expected: %d != %d", runningPods, database.Spec.Nodes),
)
meta.SetStatusCondition(&database.Status.Conditions, metav1.Condition{
Type: DatabaseProvisionedCondition,
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
Message: fmt.Sprintf("Number of running dynamic pods does not match expected: %d != %d", runningPods, database.Spec.Nodes),
Message: fmt.Sprintf("Number of running pods does not match expected: %d != %d", runningPods, database.Spec.Nodes),
})
return r.updateStatus(ctx, database, DefaultRequeueDelay)
}
Expand All @@ -383,7 +373,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Type: DatabaseProvisionedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
Message: "Successfully scaled to desired number of nodes",
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", database.Spec.Nodes),
})
return r.updateStatus(ctx, database, StatusUpdateRequeueDelay)
}
Expand Down
22 changes: 12 additions & 10 deletions internal/controllers/databasenodeset/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants" //nolint:revive,stylecheck
"github.com/ydb-platform/ydb-kubernetes-operator/internal/labels"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/resources"
)

Expand Down Expand Up @@ -213,15 +214,15 @@ func (r *Reconciler) waitForStatefulSetToScale(
r.Recorder.Event(
databaseNodeSet,
corev1.EventTypeWarning,
"Syncing",
fmt.Sprintf("Failed to found StatefulSet: %s", err),
"ProvisioningFailed",
fmt.Sprintf("StatefulSet with name %s was not found: %s", databaseNodeSet.Name, err),
)
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, nil
}
r.Recorder.Event(
databaseNodeSet,
corev1.EventTypeWarning,
"Syncing",
"ControllerError",
fmt.Sprintf("Failed to get StatefulSets: %s", err),
)
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
Expand All @@ -235,21 +236,22 @@ func (r *Reconciler) waitForStatefulSetToScale(
podList := &corev1.PodList{}
opts := []client.ListOption{
client.InNamespace(databaseNodeSet.Namespace),
matchingLabels,
client.MatchingLabels{labels.StatefulsetComponent: databaseNodeSet.Name},
}
if err = r.List(ctx, podList, opts...); err != nil {
err = r.List(ctx, podList, opts...)
if err != nil {
r.Recorder.Event(
databaseNodeSet,
corev1.EventTypeWarning,
"Syncing",
fmt.Sprintf("Failed to list databaseNodeSet pods: %s", err),
"ControllerError",
fmt.Sprintf("Failed to list StatefulSet pods: %s", err),
)
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
}

runningPods := 0
for _, e := range podList.Items {
if e.Status.Phase == "Running" {
if resources.PodIsReady(e) {
runningPods++
}
}
Expand All @@ -259,7 +261,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
databaseNodeSet,
corev1.EventTypeNormal,
string(DatabaseNodeSetProvisioning),
fmt.Sprintf("Waiting for number of running databaseNodeSet pods to match expected: %d != %d", runningPods, databaseNodeSet.Spec.Nodes),
fmt.Sprintf("Waiting for number of running nodes to match expected: %d != %d", runningPods, databaseNodeSet.Spec.Nodes),
)
meta.SetStatusCondition(&databaseNodeSet.Status.Conditions, metav1.Condition{
Type: NodeSetProvisionedCondition,
Expand All @@ -275,7 +277,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Type: NodeSetProvisionedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
Message: fmt.Sprintf("Scaled DatabaseNodeSet to %d successfully", databaseNodeSet.Spec.Nodes),
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", databaseNodeSet.Spec.Nodes),
})
return r.updateStatus(ctx, databaseNodeSet, StatusUpdateRequeueDelay)
}
Expand Down
55 changes: 46 additions & 9 deletions internal/controllers/storage/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"path/filepath"
"strconv"
"strings"
"testing"

Expand Down Expand Up @@ -114,8 +113,7 @@ var _ = Describe("Storage controller medium tests", func() {
}
Expect(foundVolume).To(BeTrue())

By("Check that label and annotation propagated to pods...", func() {
podLabels := storageSS.Spec.Template.Labels
By("Check that configuration checksum annotation propagated to pods...", func() {
podAnnotations := storageSS.Spec.Template.Annotations

foundStorage := v1alpha1.Storage{}
Expand All @@ -124,12 +122,6 @@ var _ = Describe("Storage controller medium tests", func() {
Namespace: testobjects.YdbNamespace,
}, &foundStorage)).Should(Succeed())

foundStorageGenerationLabel := false
if podLabels[labels.StorageGeneration] == strconv.FormatInt(foundStorage.ObjectMeta.Generation, 10) {
foundStorageGenerationLabel = true
}
Expect(foundStorageGenerationLabel).To(BeTrue())

foundConfigurationChecksumAnnotation := false
if podAnnotations[annotations.ConfigurationChecksum] == resources.GetConfigurationChecksum(foundStorage.Spec.Configuration) {
foundConfigurationChecksumAnnotation = true
Expand All @@ -150,5 +142,50 @@ var _ = Describe("Storage controller medium tests", func() {
Expect(labelArgKey).Should(BeEquivalentTo(v1alpha1.LabelDeploymentKey))
Expect(labelArgValue).Should(BeEquivalentTo(v1alpha1.LabelDeploymentValueKubernetes))
})

By("Check that statefulset podTemplate labels remain immutable...", func() {
testLabelKey := "ydb-label"
testLabelValue := "test"
By("set additional labels to Storage...")
Eventually(func() error {
foundStorage := v1alpha1.Storage{}
Expect(k8sClient.Get(ctx, types.NamespacedName{
Name: storageSample.Name,
Namespace: testobjects.YdbNamespace,
}, &foundStorage))
additionalLabels := resources.CopyDict(foundStorage.Spec.AdditionalLabels)
additionalLabels[testLabelKey] = testLabelValue
foundStorage.Spec.AdditionalLabels = additionalLabels
return k8sClient.Update(ctx, &foundStorage)
}, test.Timeout, test.Interval).ShouldNot(HaveOccurred())

By("check that additional labels was added...")
foundStatefulSets := appsv1.StatefulSetList{}
Eventually(func() error {
err := k8sClient.List(ctx, &foundStatefulSets,
client.InNamespace(testobjects.YdbNamespace),
)
if err != nil {
return err
}
value, exist := foundStatefulSets.Items[0].Labels[testLabelKey]
if !exist {
return fmt.Errorf("label key `ydb-label` does not exist in StatefulSet. Current labels: %s", foundStatefulSets.Items[0].Labels)
}
if value != testLabelValue {
return fmt.Errorf("label value `ydb-label` in StatefulSet does not equal `test`. Current labels: %s", foundStatefulSets.Items[0].Labels)
}
return nil
}, test.Timeout, test.Interval).ShouldNot(HaveOccurred())

By("check that StatefulSet selector was not updated...")
Expect(*foundStatefulSets.Items[0].Spec.Selector).Should(BeEquivalentTo(
metav1.LabelSelector{
MatchLabels: map[string]string{
labels.StatefulsetComponent: storageSample.Name,
},
},
))
})
})
})
26 changes: 8 additions & 18 deletions internal/controllers/storage/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,42 +142,32 @@ func (r *Reconciler) waitForStatefulSetToScale(
r.Recorder.Event(
storage,
corev1.EventTypeWarning,
"ProvisioningFailed",
fmt.Sprintf("Failed to get StatefulSets: %s", err),
"ControllerError",
fmt.Sprintf("Failed to get StatefulSet: %s", err),
)
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
}

podLabels := labels.Common(storage.Name, make(map[string]string))
podLabels.Merge(map[string]string{
labels.ComponentKey: labels.StorageComponent,
})

matchingLabels := client.MatchingLabels{}
for k, v := range podLabels {
matchingLabels[k] = v
}

podList := &corev1.PodList{}
opts := []client.ListOption{
client.InNamespace(storage.Namespace),
matchingLabels,
client.MatchingLabels{labels.StatefulsetComponent: storage.Name},
}

err = r.List(ctx, podList, opts...)
if err != nil {
r.Recorder.Event(
storage,
corev1.EventTypeWarning,
"ProvisioningFailed",
fmt.Sprintf("Failed to list cluster pods: %s", err),
"ControllerError",
fmt.Sprintf("Failed to list StatefulSet pods: %s", err),
)
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
}

runningPods := 0
for _, e := range podList.Items {
if e.Status.Phase == "Running" {
if resources.PodIsReady(e) {
runningPods++
}
}
Expand All @@ -187,7 +177,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
storage,
corev1.EventTypeNormal,
string(StorageProvisioning),
fmt.Sprintf("Waiting for number of running storage pods to match expected: %d != %d", runningPods, storage.Spec.Nodes),
fmt.Sprintf("Waiting for number of running nodes to match expected: %d != %d", runningPods, storage.Spec.Nodes),
)
meta.SetStatusCondition(&storage.Status.Conditions, metav1.Condition{
Type: StorageProvisionedCondition,
Expand All @@ -203,7 +193,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Type: StorageProvisionedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
Message: "Successfully scaled to desired number of nodes",
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", storage.Spec.Nodes),
})
return r.updateStatus(ctx, storage, StatusUpdateRequeueDelay)
}
Expand Down
36 changes: 14 additions & 22 deletions internal/controllers/storagenodeset/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants" //nolint:revive,stylecheck
"github.com/ydb-platform/ydb-kubernetes-operator/internal/labels"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/resources"
)

Expand Down Expand Up @@ -213,49 +214,40 @@ func (r *Reconciler) waitForStatefulSetToScale(
r.Recorder.Event(
storageNodeSet,
corev1.EventTypeWarning,
"Syncing",
fmt.Sprintf("Failed to found StatefulSet: %s", err),
"ProvisioningFailed",
fmt.Sprintf("StatefulSet with name %s was not found: %s", storageNodeSet.Name, err),
)
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
}
r.Recorder.Event(
storageNodeSet,
corev1.EventTypeWarning,
"Syncing",
fmt.Sprintf("Failed to get StatefulSets: %s", err),
"ControllerError",
fmt.Sprintf("Failed to get StatefulSet: %s", err),
)
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
}

matchingLabels := client.MatchingLabels{}
for k, v := range storageNodeSet.Labels {
matchingLabels[k] = v
}

podList := &corev1.PodList{}
opts := []client.ListOption{
client.InNamespace(storageNodeSet.Namespace),
matchingLabels,
client.MatchingLabels{labels.StatefulsetComponent: storageNodeSet.Name},
}
if err = r.List(ctx, podList, opts...); err != nil {

err = r.List(ctx, podList, opts...)
if err != nil {
r.Recorder.Event(
storageNodeSet,
corev1.EventTypeWarning,
"Syncing",
fmt.Sprintf("Failed to list storageNodeSet pods: %s", err),
"ControllerError",
fmt.Sprintf("Failed to list StatefulSet pods: %s", err),
)
meta.SetStatusCondition(&storageNodeSet.Status.Conditions, metav1.Condition{
Type: NodeSetProvisionedCondition,
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
Message: "Failed to check Pods .status.phase",
})
return Stop, ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
}

runningPods := 0
for _, e := range podList.Items {
if e.Status.Phase == "Running" {
if resources.PodIsReady(e) {
runningPods++
}
}
Expand All @@ -265,7 +257,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
storageNodeSet,
corev1.EventTypeNormal,
string(StorageNodeSetProvisioning),
fmt.Sprintf("Waiting for number of running storageNodeSet pods to match expected: %d != %d", runningPods, storageNodeSet.Spec.Nodes),
fmt.Sprintf("Waiting for number of running nodes to match expected: %d != %d", runningPods, storageNodeSet.Spec.Nodes),
)
meta.SetStatusCondition(&storageNodeSet.Status.Conditions, metav1.Condition{
Type: NodeSetProvisionedCondition,
Expand All @@ -281,7 +273,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Type: NodeSetProvisionedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
Message: fmt.Sprintf("Scaled StorageNodeSet to %d successfully", storageNodeSet.Spec.Nodes),
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", storageNodeSet.Spec.Nodes),
})
return r.updateStatus(ctx, storageNodeSet, StatusUpdateRequeueDelay)
}
Expand Down
Loading