Skip to content
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

Add etcd-only/control-plane-only server test and fix control-plane-only server crash #8638

Merged
merged 2 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1372,8 +1372,17 @@ func (e *ETCD) GetMembersNames(ctx context.Context) ([]string, error) {
return memberNames, nil
}

// RemoveSelf will remove the member if it exists in the cluster
// RemoveSelf will remove the member if it exists in the cluster. This should
// only be called on a node that may have previously run etcd, but will not
// currently run etcd, to ensure that it is not a member of the cluster.
// This is also called by tests to do cleanup between runs.
func (e *ETCD) RemoveSelf(ctx context.Context) error {
if e.client == nil {
if err := e.startClient(ctx); err != nil {
return err
}
}

if err := e.RemovePeer(ctx, e.name, e.address, true); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-helpers
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ provision-cluster() {
provision-server
timeout --foreground 120s bash -c "wait-for-kubeconfig $i"
done
export KUBECONFIG=$TEST_DIR/servers/1/kubeconfig.yaml
export KUBECONFIG=$TEST_DIR/servers/${KUBECONFIG_SERVER:-1}/kubeconfig.yaml

if [ $NUM_AGENTS -gt 0 ]; then
for _ in $(seq 1 $NUM_AGENTS); do
Expand Down
11 changes: 11 additions & 0 deletions scripts/test-run-etcd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ LABEL="ETCD-JOIN-BASIC" SERVER_ARGS="" run-test
# --- create a basic cluster to test joining a managed etcd cluster with --agent-token set
LABEL="ETCD-JOIN-AGENTTOKEN" SERVER_ARGS="--agent-token ${RANDOM}${RANDOM}${RANDOM}" run-test

# --- create a cluster with one etcd-only server, one control-plane-only server, and one agent
server-post-hook() {
if [ $1 -eq 1 ]; then
local url=$(cat $TEST_DIR/servers/1/metadata/url)
export SERVER_ARGS="${SERVER_ARGS} --server $url"
fi
}
export -f server-post-hook
LABEL="ETCD-SPLIT-ROLE" NUM_AGENTS=1 KUBECONFIG_SERVER=2 SERVER_1_ARGS="--cluster-init --disable-apiserver --disable-controller-manager --disable-scheduler" SERVER_2_ARGS="--disable-etcd" run-test


# The following tests deploy clusters of mixed versions. The traefik helm chart may not deploy
# correctly until all servers have been upgraded to the same release, so don't wait for it.
all_services=(
Expand Down