Skip to content

Commit

Permalink
Refactor CLI flags, controller structure and controller configs (#506)
Browse files Browse the repository at this point in the history
* Refactor CLI flags

* Address review comments

* Address review comments from @unmarshall

* refactored handling of flags and setting up of mgr and reconcilers

* [WIP] Minor changes to controllers/secret package, start adding test/utils package

* changes to etcdcopybackuptask controller and refactored some utility methods

* [WIP] Add controllers/etcdcopybackupstask package, adapt tests

* minor refactoring to the secret controller

* minor refactoring of etcdcopybackuptask reconciler

* initial changes for compaction lease controller

* added add-license-headers makefile target

* missed adding addlicenseheader script. Other misc changes

* renamed controller packages

* renamed compactionlease to compaction, parameterized add-license-headers makefile target

* addition changes for compaction controller

* fixed some compilation issues and started to add files for etcd controller

* added refactored code for etcd controller

* Add unit tests for controllers/secret,etcdcopybackupstask packages
Adapt integration tests for controllers/secret,etcdcopybackupstask
Segregate functions into test utils
Clean up reconciler code
Run make add-licence-headers

* Refactor test utils
TODO: re-organise context passing to test utils
Move compaction tests to test/integration/controllers/compaction

* Update golang image versions in CI pipeline

* [WIP] Refactor custodian controller code
Remove pkg/{config,flags}

* Moved to golang 1.19.5
Deleted etcd_controller as it has been moved to its own package
Changed secret reconciler unit test

* Refactor pkg/health packages to not use custodian config
Removed controller_ref_manager.go entirely as it is no longer used
Renamed custodian.EtcdMemberConfig fields

* Create named controllers

* added tests for etcdcopybackupstask and some minor refactoring

* Named controller for compaction

* changed usage of deprecated methods

* restructured api, moved names specific functions to now be directly
defined on etcd struct, removed usage of deprecated methods

* added license headers

* Remove pkg/utils/names.go and adapt related functions

* Move {etcd,custodian}-controller tests to test/integration/controllers/{etcd,custodian} suites
Minor fixes

* Run `make add-license-headers YEAR=2023`

* Fix copy-paste error in custodian controller config

* added tests for pkg/utils/statefulset and other misc changes

* removed deprecated methods

* added unit tests for pkg/utils

* added license headers to new files

* Fix integration tests
Remove deprecated functions from pointer package

* multiple fixes for integration tests

* WIP commit to fix compaction integration tests

* refactored integration tests and adjusted controllers

* small optimization in chart handling in etcd

* fixed etcd reconciler integration tests

* Handle missing objects from etcd charts

* Remove unused functions from test/utils/manager.go

* added docstrings and removed commented code

* Fix integration tests for compaction controller

* Fix `make test`

* Fix controller/secret tests

* Fix test and test-integration CI scripts

* Minor cleanups for integration tests

* Fix copy-paste error for integration/etcdcopybackupstask test

* Resolve linter warnings

* Use namespace string in integration tests instead of testNamespace object

* Adapt sample etcd resource for easier local testing

* Apply suggestions from code review

Review comments from Aaron

Co-authored-by: Aaron Francis Fernandes <[email protected]>

* addressed review comment from aaron, added type for a constant

* corrected compilation error due to accepting partial change from aaron

* Add validation for controller configs derived from CLI flags

* refactored validation, introduced generics

* added license headers to new files

* reordered imports

* addressed review comment from abhishek

* addressed review comments from Shreyas

* Rename AddToManager to RegisterWIthManager; rename files controllers/*/add.go to controllers/*register.go

* Progress sample etcd rpelicas from 1 to 3

* Fix linter errors, cleanup rebase issue

---------

Co-authored-by: Madhav Bhargava <[email protected]>
Co-authored-by: Aaron Francis Fernandes <[email protected]>
  • Loading branch information
3 people authored Mar 10, 2023
1 parent c24548c commit 080f0c7
Show file tree
Hide file tree
Showing 122 changed files with 6,324 additions and 3,904 deletions.
4 changes: 2 additions & 2 deletions .ci/bump_tag
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ set -o errexit
set -o nounset
set -o pipefail

version=$(cat $REPO_DIR/VERSION)
sed -i "s/v[0-9]*.[0-9]*\.[0-9]*/${version}/g" $REPO_DIR/config/default/manager_image_patch.yaml
version=$(cat "$REPO_DIR"/VERSION)
sed -i "s/v[0-9]*.[0-9]*\.[0-9]*/${version}/g" "$REPO_DIR"/config/default/manager_image_patch.yaml
2 changes: 1 addition & 1 deletion .ci/check
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set -o errexit
set -o nounset
set -o pipefail

cd "$(dirname $0)/.."
cd "$(dirname "$0")/.."

git config --global user.email "[email protected]"
git config --global user.name "Gardener CI/CD"
Expand Down
4 changes: 2 additions & 2 deletions .ci/component_descriptor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

chmod +x "$(dirname $0)"/../vendor/github.com/gardener/gardener/hack/.ci/component_descriptor
"$(dirname $0)"/../vendor/github.com/gardener/gardener/hack/.ci/component_descriptor "$(dirname $0)"/..
chmod +x "$(dirname "$0")"/../vendor/github.com/gardener/gardener/hack/.ci/component_descriptor
"$(dirname "$0")"/../vendor/github.com/gardener/gardener/hack/.ci/component_descriptor "$(dirname "$0")"/..
2 changes: 2 additions & 0 deletions .ci/pipeline_definitions
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ etcd-druid:
image: 'golang:1.20.1'
test:
image: 'golang:1.20.1'
test_integration:
image: 'golang:1.20.1'
build:
image: 'golang:1.20.1'
output_dir: 'binary'
Expand Down
2 changes: 1 addition & 1 deletion .ci/set_dependency_version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

"$(dirname $0)"/../vendor/github.com/gardener/gardener/hack/.ci/set_dependency_version
"$(dirname "$0")"/../vendor/github.com/gardener/gardener/hack/.ci/set_dependency_version
33 changes: 33 additions & 0 deletions .ci/test_integration
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Copyright (c) 2023 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -eo pipefail

# For all steps, concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.
if [[ -z "${SOURCE_PATH}" ]]; then
SOURCE_PATH="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")"
else
SOURCE_PATH="$(readlink -f "${SOURCE_PATH}")"
fi
export SOURCE_PATH

source "${SOURCE_PATH}/.ci/common.sh"

###############################################################################

echo "[INFO] Running integration tests."
make test-integration
echo "Finished executing integration tests."
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 SAP SE or an SAP affiliate company
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,15 @@ test-cov-clean: set-permissions
test-e2e: set-permissions $(KUBECTL) $(HELM) $(SKAFFOLD)
@"$(REPO_ROOT)/hack/e2e-test/run-e2e-test.sh" $(PROVIDERS)

.PHONY: test-integration
test-integration: set-permissions $(GINKGO) $(SETUP_ENVTEST) fmt check manifests
@"$(REPO_ROOT)/hack/test.sh" ./test/integration/...

.PHONY: update-dependencies
update-dependencies:
@env GO111MODULE=on go get -u
@make revendor

.PHONY: add-license-headers
add-license-headers: $(GO_ADD_LICENSE)
@./hack/addlicenseheaders.sh ${YEAR}
75 changes: 75 additions & 0 deletions api/v1alpha1/types_common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2023 SAP SE or an SAP affiliate company
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// StorageProvider defines the type of object store provider for storing backups.
type StorageProvider string

// StoreSpec defines parameters related to ObjectStore persisting backups
type StoreSpec struct {
// Container is the name of the container the backup is stored at.
// +optional
Container *string `json:"container,omitempty"`
// Prefix is the prefix used for the store.
// +required
Prefix string `json:"prefix"`
// Provider is the name of the backup provider.
// +optional
Provider *StorageProvider `json:"provider,omitempty"`
// SecretRef is the reference to the secret which used to connect to the backup store.
// +optional
SecretRef *corev1.SecretReference `json:"secretRef,omitempty"`
}

// ConditionType is the type of a condition.
type ConditionType string

// ConditionStatus is the status of a condition.
type ConditionStatus string

const (
// ConditionTrue means a resource is in the condition.
ConditionTrue ConditionStatus = "True"
// ConditionFalse means a resource is not in the condition.
ConditionFalse ConditionStatus = "False"
// ConditionUnknown means Gardener can't decide if a resource is in the condition or not.
ConditionUnknown ConditionStatus = "Unknown"
// ConditionProgressing means the condition was seen true, failed but stayed within a predefined failure threshold.
// In the future, we could add other intermediate conditions, e.g. ConditionDegraded.
ConditionProgressing ConditionStatus = "Progressing"
// ConditionCheckError is a constant for a reason in condition.
ConditionCheckError ConditionStatus = "ConditionCheckError"
)

// Condition holds the information about the state of a resource.
type Condition struct {
// Type of the Etcd condition.
Type ConditionType `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status ConditionStatus `json:"status"`
// Last time the condition transitioned from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
// Last time the condition was updated.
LastUpdateTime metav1.Time `json:"lastUpdateTime"`
// The reason for the condition's last transition.
Reason string `json:"reason"`
// A human readable message indicating details about the transition.
Message string `json:"message"`
}
Loading

0 comments on commit 080f0c7

Please sign in to comment.