Skip to content

Commit

Permalink
Deploy statefulset as component.
Browse files Browse the repository at this point in the history
  • Loading branch information
abdasgupta committed Jul 15, 2022
1 parent 3d721af commit cc812fb
Show file tree
Hide file tree
Showing 12 changed files with 1,889 additions and 652 deletions.
9 changes: 4 additions & 5 deletions controllers/compaction_lease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
druidv1alpha1 "github.com/gardener/etcd-druid/api/v1alpha1"
controllersconfig "github.com/gardener/etcd-druid/controllers/config"
"github.com/gardener/etcd-druid/pkg/common"
componentlease "github.com/gardener/etcd-druid/pkg/component/etcd/lease"
druidpredicates "github.com/gardener/etcd-druid/pkg/predicate"
"github.com/gardener/etcd-druid/pkg/utils"
"github.com/gardener/gardener/pkg/utils/imagevector"
Expand Down Expand Up @@ -119,7 +118,7 @@ func (lc *CompactionLeaseController) Reconcile(ctx context.Context, req ctrl.Req

// Get full and delta snapshot lease to check the HolderIdentity value to take decision on compaction job
fullLease := &coordinationv1.Lease{}
if err := lc.Get(ctx, kutil.Key(etcd.Namespace, componentlease.GetFullSnapshotLeaseName(etcd)), fullLease); err != nil {
if err := lc.Get(ctx, kutil.Key(etcd.Namespace, utils.GetFullSnapshotLeaseName(etcd)), fullLease); err != nil {
logger.Info("Couldn't fetch full snap lease because: " + err.Error())

return ctrl.Result{
Expand All @@ -128,7 +127,7 @@ func (lc *CompactionLeaseController) Reconcile(ctx context.Context, req ctrl.Req
}

deltaLease := &coordinationv1.Lease{}
if err := lc.Get(ctx, kutil.Key(etcd.Namespace, componentlease.GetDeltaSnapshotLeaseName(etcd)), deltaLease); err != nil {
if err := lc.Get(ctx, kutil.Key(etcd.Namespace, utils.GetDeltaSnapshotLeaseName(etcd)), deltaLease); err != nil {
logger.Info("Couldn't fetch delta snap lease because: " + err.Error())

return ctrl.Result{
Expand Down Expand Up @@ -491,8 +490,8 @@ func getCompactJobCommands(etcd *druidv1alpha1.Etcd) []string {
command = append(command, "--data-dir=/var/etcd/data")
command = append(command, "--snapstore-temp-directory=/var/etcd/data/tmp")
command = append(command, "--enable-snapshot-lease-renewal=true")
command = append(command, "--full-snapshot-lease-name="+componentlease.GetFullSnapshotLeaseName(etcd))
command = append(command, "--delta-snapshot-lease-name="+componentlease.GetDeltaSnapshotLeaseName(etcd))
command = append(command, "--full-snapshot-lease-name="+utils.GetFullSnapshotLeaseName(etcd))
command = append(command, "--delta-snapshot-lease-name="+utils.GetDeltaSnapshotLeaseName(etcd))

var quota int64 = DefaultETCDQuota
if etcd.Spec.Etcd.Quota != nil {
Expand Down
9 changes: 4 additions & 5 deletions controllers/compaction_lease_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"time"

druidv1alpha1 "github.com/gardener/etcd-druid/api/v1alpha1"
componentlease "github.com/gardener/etcd-druid/pkg/component/etcd/lease"
"github.com/gardener/etcd-druid/pkg/utils"
"github.com/gardener/gardener/pkg/controllerutils"
"github.com/gardener/gardener/pkg/utils/test/matchers"
Expand Down Expand Up @@ -406,8 +405,8 @@ func validateEtcdForCmpctJob(instance *druidv1alpha1.Etcd, j *batchv1.Job) {
"--data-dir=/var/etcd/data": Equal("--data-dir=/var/etcd/data"),
"--snapstore-temp-directory=/var/etcd/data/tmp": Equal("--snapstore-temp-directory=/var/etcd/data/tmp"),
"--enable-snapshot-lease-renewal=true": Equal("--enable-snapshot-lease-renewal=true"),
fmt.Sprintf("%s=%s", "--full-snapshot-lease-name", componentlease.GetFullSnapshotLeaseName(instance)): Equal(fmt.Sprintf("%s=%s", "--full-snapshot-lease-name", componentlease.GetFullSnapshotLeaseName(instance))),
fmt.Sprintf("%s=%s", "--delta-snapshot-lease-name", componentlease.GetDeltaSnapshotLeaseName(instance)): Equal(fmt.Sprintf("%s=%s", "--delta-snapshot-lease-name", componentlease.GetDeltaSnapshotLeaseName(instance))),
fmt.Sprintf("%s=%s", "--full-snapshot-lease-name", utils.GetFullSnapshotLeaseName(instance)): Equal(fmt.Sprintf("%s=%s", "--full-snapshot-lease-name", utils.GetFullSnapshotLeaseName(instance))),
fmt.Sprintf("%s=%s", "--delta-snapshot-lease-name", utils.GetDeltaSnapshotLeaseName(instance)): Equal(fmt.Sprintf("%s=%s", "--delta-snapshot-lease-name", utils.GetDeltaSnapshotLeaseName(instance))),
fmt.Sprintf("%s=%s", "--store-prefix", instance.Spec.Backup.Store.Prefix): Equal(fmt.Sprintf("%s=%s", "--store-prefix", instance.Spec.Backup.Store.Prefix)),
fmt.Sprintf("%s=%s", "--storage-provider", store): Equal(fmt.Sprintf("%s=%s", "--storage-provider", store)),
fmt.Sprintf("%s=%s", "--store-container", *instance.Spec.Backup.Store.Container): Equal(fmt.Sprintf("%s=%s", "--store-container", *instance.Spec.Backup.Store.Container)),
Expand Down Expand Up @@ -757,7 +756,7 @@ func fullLeaseIsCorrectlyReconciled(c client.Client, instance *druidv1alpha1.Etc
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
defer cancel()
req := types.NamespacedName{
Name: componentlease.GetFullSnapshotLeaseName(instance),
Name: utils.GetFullSnapshotLeaseName(instance),
Namespace: instance.Namespace,
}

Expand All @@ -775,7 +774,7 @@ func deltaLeaseIsCorrectlyReconciled(c client.Client, instance *druidv1alpha1.Et
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
defer cancel()
req := types.NamespacedName{
Name: componentlease.GetDeltaSnapshotLeaseName(instance),
Name: utils.GetDeltaSnapshotLeaseName(instance),
Namespace: instance.Namespace,
}

Expand Down
Loading

0 comments on commit cc812fb

Please sign in to comment.