-
Notifications
You must be signed in to change notification settings - Fork 39
feat(controller, e2e): Refactor reconcile loop and add E2E tests for scaling and promotion #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ballista01 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @ballista01. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
baf8e00
to
59d969f
Compare
/ok-to-test |
…scaling and promotion Signed-off-by: Wenxue Zhao <[email protected]>
Bumps the k8s group with 3 updates: [k8s.io/api](https://github.com/kubernetes/api), [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) and [k8s.io/client-go](https://github.com/kubernetes/client-go). Updates `k8s.io/api` from 0.33.1 to 0.33.2 - [Commits](kubernetes/api@v0.33.1...v0.33.2) Updates `k8s.io/apimachinery` from 0.33.1 to 0.33.2 - [Commits](kubernetes/apimachinery@v0.33.1...v0.33.2) Updates `k8s.io/client-go` from 0.33.1 to 0.33.2 - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](kubernetes/client-go@v0.33.1...v0.33.2) --- updated-dependencies: - dependency-name: k8s.io/api dependency-version: 0.33.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s - dependency-name: k8s.io/apimachinery dependency-version: 0.33.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s - dependency-name: k8s.io/client-go dependency-version: 0.33.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Wenxue Zhao <[email protected]>
This commit will implement the interface functions required for cert-manager certificate provider. Signed-off-by: ArkaSaha30 <[email protected]> Signed-off-by: Wenxue Zhao <[email protected]>
Signed-off-by: ArkaSaha30 <[email protected]> Signed-off-by: Wenxue Zhao <[email protected]>
Bumps [github.com/cert-manager/cert-manager](https://github.com/cert-manager/cert-manager) from 1.17.2 to 1.18.1. - [Release notes](https://github.com/cert-manager/cert-manager/releases) - [Changelog](https://github.com/cert-manager/cert-manager/blob/master/RELEASE.md) - [Commits](cert-manager/cert-manager@v1.17.2...v1.18.1) --- updated-dependencies: - dependency-name: github.com/cert-manager/cert-manager dependency-version: 1.18.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Wenxue Zhao <[email protected]>
Signed-off-by: Wenxue Zhao <[email protected]>
Signed-off-by: Wenxue Zhao <[email protected]>
dffb919
to
fa7f810
Compare
Summary
This pull request introduces two main improvements:
EtcdClusterReconciler
's mainReconcile
loop to improve its structure and testability.The E2E test additions are motivated by the need to validate controller logic that depends on a functional Kubernetes environment with DNS and networking, which is not feasible at the unit test level without privileged operations (e.g.,
/etc/hosts
modification).1. Reconciliation Loop Refactoring (
internal/controller/etcdcluster_controller.go
)The primary
Reconcile
function has been decomposed into four distinct, sequential phases, each with a clear responsibility:fetchAndValidateState
: Retrieves and validates the primary and associated resources.syncPrimitives
: Ensures the existence of foundational Kubernetes objects (StatefulSet
,Service
).performHealthChecks
: Gathers health and membership status from the etcd cluster.reconcileClusterState
: Executes the core scaling and membership management logic.A
reconcileState
struct is now used to pass the collected state through these phases, standardizing the data flow within a single reconciliation cycle.2. E2E Test Suite Additions (
test/e2e/
)New E2E tests have been added to verify the operator's behavior in a
kind
environment.New Test Scenarios:
TestScaleUpFrom1To3
: Verifies the process of scaling a cluster from 1 to 3 members.TestScaleDownFrom3To1
: Verifies the process of scaling a cluster from 3 to 1 member.TestPromoteReadyLearner
: Verifies the operator's ability to handle a cluster with a pre-existinglearner
member. It confirms the operator can bring the cluster to the desired state (spec.size: 3
) and successfully promote the learner.Testing Framework Enhancements:
test/e2e/helpers.go
file has been introduced to provide reusable test utilities.execInPod
, is included. This function allows tests to executeetcdctl
commands directly within the etcd pods to assert against the internal state of the etcd cluster, such as the output ofetcdctl member list
.3. Evolution of Unit Tests (
internal/controller/etcdcluster_controller_test.go
)sudo
privileges for/etc/hosts
modifications have been superseded.TestWaitForUnreadyLearner
which simulates a lagging learner) have been preserved, as they cover edge cases that are difficult to reproduce reliably in an E2E environment.