Skip to content

Commit b8d756b

Browse files
authored
fix remote object sync by multiple Storage and Database objects (#195)
1 parent 2213de1 commit b8d756b

File tree

17 files changed

+964
-774
lines changed

17 files changed

+964
-774
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ IMG ?= cr.yandex/yc/ydb-operator:latest
1010
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
1111
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
1212
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
13-
ENVTEST_K8S_VERSION = 1.21
13+
ENVTEST_K8S_VERSION = 1.26
1414

1515
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
1616
ifeq (,$(shell go env GOBIN))

api/v1alpha1/remotestoragenodeset_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type RemoteStorageNodeSet struct {
2323
Status RemoteStorageNodeSetStatus `json:"status,omitempty"`
2424
}
2525

26-
// DatabaseNodeSetStatus defines the observed state
26+
// StorageNodeSetStatus defines the observed state
2727
type RemoteStorageNodeSetStatus struct {
2828
State constants.ClusterState `json:"state"`
2929
Conditions []metav1.Condition `json:"conditions,omitempty"`

deploy/ydb-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.5.5
18+
version: 0.5.6
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "0.5.5"
24+
appVersion: "0.5.6"

deploy/ydb-operator/crds/remotestoragenodeset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4498,7 +4498,7 @@ spec:
44984498
status:
44994499
default:
45004500
state: Pending
4501-
description: DatabaseNodeSetStatus defines the observed state
4501+
description: StorageNodeSetStatus defines the observed state
45024502
properties:
45034503
conditions:
45044504
items:

internal/controllers/databasenodeset/controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ type Reconciler struct {
3939
// Reconcile is part of the main kubernetes reconciliation loop which aims to
4040
// move the current state of the cluster closer to the desired state.
4141
func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
42-
logger := log.FromContext(ctx)
42+
r.Log = log.FromContext(ctx)
4343

4444
crDatabaseNodeSet := &v1alpha1.DatabaseNodeSet{}
4545
err := r.Get(ctx, req.NamespacedName, crDatabaseNodeSet)
4646
if err != nil {
4747
if apierrors.IsNotFound(err) {
48-
logger.Info("DatabaseNodeSet resource not found")
48+
r.Log.Info("DatabaseNodeSet resource not found")
4949
return ctrl.Result{Requeue: false}, nil
5050
}
51-
logger.Error(err, "unable to get DatabaseNodeSet")
51+
r.Log.Error(err, "unable to get DatabaseNodeSet")
5252
return ctrl.Result{RequeueAfter: DefaultRequeueDelay}, err
5353
}
5454

internal/controllers/remotedatabasenodeset/controller.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ type Reconciler struct {
5454
//+kubebuilder:rbac:groups=core,resources=secrets/status,verbs=get;update;patch
5555

5656
func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
57-
logger := log.FromContext(ctx)
57+
r.Log = log.FromContext(ctx)
5858

5959
remoteDatabaseNodeSet := &v1alpha1.RemoteDatabaseNodeSet{}
6060
if err := r.RemoteClient.Get(ctx, req.NamespacedName, remoteDatabaseNodeSet); err != nil {
6161
if apierrors.IsNotFound(err) {
62-
logger.Info("RemoteDatabaseNodeSet resource not found on remote cluster")
62+
r.Log.Info("RemoteDatabaseNodeSet resource not found on remote cluster")
6363
return ctrl.Result{Requeue: false}, nil
6464
}
65-
logger.Error(err, "unable to get RemoteDatabaseNodeSet on remote cluster")
65+
r.Log.Error(err, "unable to get RemoteDatabaseNodeSet on remote cluster")
6666
return ctrl.Result{RequeueAfter: DefaultRequeueDelay}, nil
6767
}
6868

@@ -225,29 +225,27 @@ func (r *Reconciler) deleteExternalResources(
225225
ctx context.Context,
226226
crRemoteDatabaseNodeSet *v1alpha1.RemoteDatabaseNodeSet,
227227
) error {
228-
logger := log.FromContext(ctx)
229-
230228
databaseNodeSet := &v1alpha1.DatabaseNodeSet{}
231229
if err := r.Client.Get(ctx, types.NamespacedName{
232230
Name: crRemoteDatabaseNodeSet.Name,
233231
Namespace: crRemoteDatabaseNodeSet.Namespace,
234232
}, databaseNodeSet); err != nil {
235233
if apierrors.IsNotFound(err) {
236-
logger.Info("DatabaseNodeSet not found")
234+
r.Log.Info("DatabaseNodeSet not found")
237235
} else {
238-
logger.Error(err, "unable to get DatabaseNodeSet")
236+
r.Log.Error(err, "unable to get DatabaseNodeSet")
239237
return err
240238
}
241239
} else {
242240
if err := r.Client.Delete(ctx, databaseNodeSet); err != nil {
243-
logger.Error(err, "unable to delete DatabaseNodeSet")
241+
r.Log.Error(err, "unable to delete DatabaseNodeSet")
244242
return err
245243
}
246244
}
247245

248246
remoteDatabaseNodeSet := resources.NewRemoteDatabaseNodeSet(crRemoteDatabaseNodeSet)
249247
if _, _, err := r.removeUnusedRemoteObjects(ctx, &remoteDatabaseNodeSet, []client.Object{}); err != nil {
250-
logger.Error(err, "unable to delete unused remote resources")
248+
r.Log.Error(err, "unable to delete unused remote resources")
251249
return err
252250
}
253251

0 commit comments

Comments
 (0)