Skip to content

Commit

Permalink
Merge branch 'master' into e2e/fake-gcs-server
Browse files Browse the repository at this point in the history
  • Loading branch information
anveshreddy18 authored Jul 25, 2024
2 parents d9927cf + c73cbf9 commit d675613
Show file tree
Hide file tree
Showing 51 changed files with 2,340 additions and 1,891 deletions.
33 changes: 14 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

ENSURE_GARDENER_MOD := $(shell go get github.com/gardener/gardener@$$(go list -m -f "{{.Version}}" github.com/gardener/gardener))
GARDENER_HACK_DIR := $(shell go list -m -f "{{.Dir}}" github.com/gardener/gardener)/hack
VERSION := $(shell cat VERSION)
REPO_ROOT := $(shell dirname "$(realpath $(lastword $(MAKEFILE_LIST)))")
HACK_DIR := $(REPO_ROOT)/hack
Expand All @@ -22,7 +20,6 @@ IMG ?= ${IMAGE_REPOSITORY}:${IMAGE_BUILD_TAG}
#########################################

TOOLS_DIR := $(HACK_DIR)/tools
include $(GARDENER_HACK_DIR)/tools.mk
include $(HACK_DIR)/tools.mk

#####################################################################
Expand All @@ -32,12 +29,10 @@ include $(HACK_DIR)/tools.mk
.PHONY: tidy
tidy:
@env GO111MODULE=on go mod tidy
@GARDENER_HACK_DIR=$(GARDENER_HACK_DIR) bash $(HACK_DIR)/update-github-templates.sh
@cp $(GARDENER_HACK_DIR)/cherry-pick-pull.sh $(HACK_DIR)/cherry-pick-pull.sh && chmod +xw $(HACK_DIR)/cherry-pick-pull.sh

.PHONY: clean
clean:
@bash $(GARDENER_HACK_DIR)/clean.sh ./api/... ./internal/...
@$(HACK_DIR)/clean.sh ./api/... ./internal/...

.PHONY: update-dependencies
update-dependencies:
Expand All @@ -46,7 +41,7 @@ update-dependencies:

.PHONY: add-license-headers
add-license-headers: $(GO_ADD_LICENSE)
@bash $(HACK_DIR)/addlicenseheaders.sh ${YEAR}
@$(HACK_DIR)/addlicenseheaders.sh ${YEAR}

# Run go fmt against code
.PHONY: fmt
Expand All @@ -56,11 +51,11 @@ fmt:
# Check packages
.PHONY: check
check: $(GOLANGCI_LINT) $(GOIMPORTS) fmt manifests
@REPO_ROOT=$(REPO_ROOT) bash $(GARDENER_HACK_DIR)/check.sh --golangci-lint-config=./.golangci.yaml ./api/... ./internal/...
@$(HACK_DIR)/check.sh --golangci-lint-config=./.golangci.yaml ./api/... ./internal/...

.PHONY: check-generate
check-generate:
@bash $(GARDENER_HACK_DIR)/check-generate.sh "$(REPO_ROOT)"
@$(HACK_DIR)/check-generate.sh "$(REPO_ROOT)"

# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
Expand Down Expand Up @@ -102,11 +97,11 @@ test-integration: $(GINKGO) $(SETUP_ENVTEST) $(GOTESTFMT)

.PHONY: test-cov
test-cov: $(GINKGO) $(SETUP_ENVTEST)
@TEST_COV="true" bash $(HACK_DIR)/test.sh --skip-package=./test/e2e
@TEST_COV="true" $(HACK_DIR)/test.sh --skip-package=./test/e2e

.PHONY: test-cov-clean
test-cov-clean:
@bash $(GARDENER_HACK_DIR)/test-cover-clean.sh
@$(HACK_DIR)/test-cover-clean.sh

#################################################################
# Rules related to binary build, Docker image build and release #
Expand Down Expand Up @@ -138,7 +133,7 @@ kind-up kind-down ci-e2e-kind ci-e2e-kind-azure deploy-localstack deploy-fakegcs
.PHONY: kind-up
kind-up: $(KIND)
@printf "\n\033[0;33m📌 NOTE: To target the newly created KinD cluster, please run the following command:\n\n export KUBECONFIG=$(KUBECONFIG_PATH)\n\033[0m\n"
@GARDENER_HACK_DIR=$(GARDENER_HACK_DIR) bash $(HACK_DIR)/kind-up.sh
@$(HACK_DIR)/kind-up.sh

.PHONY: kind-down
kind-down: $(KIND)
Expand Down Expand Up @@ -180,28 +175,28 @@ undeploy: $(SKAFFOLD) $(HELM)

.PHONY: deploy-localstack
deploy-localstack: $(KUBECTL)
@bash $(HACK_DIR)/deploy-localstack.sh
@$(HACK_DIR)/deploy-localstack.sh

.PHONY: deploy-azurite
deploy-azurite: $(KUBECTL)
$(HACK_DIR)/deploy-azurite.sh
@$(HACK_DIR)/deploy-azurite.sh

.PHONY: deploy-fakegcs
deploy-fakegcs: $(KUBECTL)
@bash $(HACK_DIR)/deploy-fakegcs.sh
@$(HACK_DIR)/deploy-fakegcs.sh

.PHONY: test-e2e
test-e2e: $(KUBECTL) $(HELM) $(SKAFFOLD) $(KUSTOMIZE)
@bash $(HACK_DIR)/e2e-test/run-e2e-test.sh $(PROVIDERS)
@$(HACK_DIR)/e2e-test/run-e2e-test.sh $(PROVIDERS)

.PHONY: ci-e2e-kind
ci-e2e-kind:
@BUCKET_NAME=$(BUCKET_NAME) bash $(HACK_DIR)/ci-e2e-kind.sh
@BUCKET_NAME=$(BUCKET_NAME) $(HACK_DIR)/ci-e2e-kind.sh

.PHONY: ci-e2e-kind-azure
ci-e2e-kind-azure:
@BUCKET_NAME=$(BUCKET_NAME) bash $(HACK_DIR)/ci-e2e-kind-azure.sh
@BUCKET_NAME=$(BUCKET_NAME) $(HACK_DIR)/ci-e2e-kind-azure.sh

.PHONY: ci-e2e-kind-gcs
ci-e2e-kind-gcs:
BUCKET_NAME=$(BUCKET_NAME) bash $(HACK_DIR)/ci-e2e-kind-gcs.sh
@BUCKET_NAME=$(BUCKET_NAME) $(HACK_DIR)/ci-e2e-kind-gcs.sh
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

[![REUSE status](https://api.reuse.software/badge/github.com/gardener/etcd-druid)](https://api.reuse.software/info/github.com/gardener/etcd-druid)
[![CI Build status](https://concourse.ci.gardener.cloud/api/v1/teams/gardener/pipelines/etcd-druid-master/jobs/master-head-update-job/badge)](https://concourse.ci.gardener.cloud/teams/gardener/pipelines/etcd-druid-master/jobs/master-head-update-job)
[![Go Report Card](https://goreportcard.com/badge/github.com/gardener/gardener)](https://goreportcard.com/report/github.com/gardener/etcd-druid)
[![Go Report Card](https://goreportcard.com/badge/github.com/gardener/etcd-druid)](https://goreportcard.com/report/github.com/gardener/etcd-druid)
[![Go Reference](https://pkg.go.dev/badge/github.com/gardener/etcd-druid.svg)](https://pkg.go.dev/github.com/gardener/etcd-druid)

## Background

[Etcd](https://github.com/etcd-io/etcd) in the control plane of Kubernetes clusters which are managed by Gardener is deployed as a StatefulSet. The statefulset has replica of a pod containing two containers namely, etcd and [backup-restore](https://github.com/gardener/etcd-backup-restore). The etcd container calls components in etcd-backup-restore via REST api to perform data validation before etcd is started. If this validation fails etcd data is restored from the latest snapshot stored in the cloud-provider's object store. Once etcd has started, the etcd-backup-restore periodically creates full and delta snapshots. It also performs defragmentation of etcd data periodically.

The etcd-backup-restore needs as input the cloud-provider information comprising of security credentials to access the object store, the object store bucket name and prefix for the directory used to store snapshots. Currently, for operations like migration and validation, the bash script has to be updated to initiate the operation.
The etcd-backup-restore needs as input the cloud-provider information comprising security credentials to access the object store, the object store bucket name and prefix for the directory used to store snapshots. Currently, for operations like migration and validation, the bash script has to be updated to initiate the operation.

## Goals

Expand Down Expand Up @@ -129,4 +129,4 @@ As first step implement defragmentation during maintenance windows. Subsequently
## Local Setup
To setup Etcd-druid locally as a pod running inside a [kind](https://kind.sigs.k8s.io/) cluster, follow this [document](docs/development/getting-started-locally.md)
To set up Etcd-druid locally as a pod running inside a [kind](https://kind.sigs.k8s.io/) cluster, follow this [document](docs/development/getting-started-locally.md)
2 changes: 2 additions & 0 deletions api/v1alpha1/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestIsBackupStoreEnabled(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
etcd.Spec.Backup = test.backup
g.Expect(etcd.IsBackupStoreEnabled()).To(Equal(test.expected))
})
Expand Down Expand Up @@ -106,6 +107,7 @@ func TestIsReconciliationInProgress(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
etcd := createEtcd("foo", "default")
etcd.Status.LastOperation = test.lastOp
g.Expect(etcd.IsReconciliationInProgress()).To(Equal(test.expected))
Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha1/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func TestGetSuspendEtcdSpecReconcileAnnotationKey(t *testing.T) {
t.Parallel()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
etcdObjMeta := createEtcdObjectMetadata(uuid.NewUUID(), test.annotations, nil, false)
annotationKey := GetSuspendEtcdSpecReconcileAnnotationKey(etcdObjMeta)
g.Expect(annotationKey).To(Equal(test.expectedAnnotationKey))
Expand Down Expand Up @@ -172,6 +173,7 @@ func TestAreManagedResourcesProtected(t *testing.T) {
t.Parallel()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
etcdObjMeta := createEtcdObjectMetadata(uuid.NewUUID(), test.annotations, nil, false)
resourceProtection := AreManagedResourcesProtected(etcdObjMeta)
g.Expect(resourceProtection).To(Equal(test.expectedResourceProtection))
Expand Down Expand Up @@ -225,6 +227,7 @@ func TestIsEtcdMarkedForDeletion(t *testing.T) {
t.Parallel()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
etcdObjMeta := createEtcdObjectMetadata(uuid.NewUUID(), nil, nil, test.markedForDeletion)
isMarkedForDeletion := IsEtcdMarkedForDeletion(etcdObjMeta)
g.Expect(isMarkedForDeletion).To(Equal(test.expectedIsMarkedForDeletion))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
controller-gen.kubebuilder.io/version: v0.14.0
name: etcdcopybackupstasks.druid.gardener.cloud
spec:
group: druid.gardener.cloud
Expand All @@ -25,14 +25,19 @@ spec:
source to a target store.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand All @@ -41,9 +46,9 @@ spec:
backups task.
properties:
maxBackupAge:
description: MaxBackupAge is the maximum age in days that a backup
must have in order to be copied. By default all backups will be
copied.
description: |-
MaxBackupAge is the maximum age in days that a backup must have in order to be copied.
By default all backups will be copied.
format: int32
type: integer
maxBackups:
Expand Down Expand Up @@ -122,8 +127,8 @@ spec:
snapshot before copying backups.
type: boolean
timeout:
description: Timeout is the timeout for waiting for a final full
snapshot. When this timeout expires, the copying of backups
description: |-
Timeout is the timeout for waiting for a final full snapshot. When this timeout expires, the copying of backups
will be performed anyway. No timeout or 0 means wait forever.
type: string
required:
Expand Down
Loading

0 comments on commit d675613

Please sign in to comment.