Skip to content

Commit

Permalink
Merge pull request #844 from makhov/remove-left-etcdmember
Browse files Browse the repository at this point in the history
Remove etcdmember that left the cluster
  • Loading branch information
makhov authored Dec 10, 2024
2 parents b9319b3 + 88b1ebc commit 726cd89
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/controller/controlplane/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ func (c *K0sController) checkMachineLeft(ctx context.Context, name string, clien
for _, condition := range conditions {
conditionMap := condition.(map[string]interface{})
if conditionMap["type"] == etcdMemberConditionTypeJoined && conditionMap["status"] == "False" {
err = clientset.RESTClient().
Delete().
AbsPath("/apis/etcd.k0sproject.io/v1beta1/etcdmembers/" + name).
Do(ctx).
Into(&etcdMember)
if err != nil && !apierrors.IsNotFound(err) {
return false, fmt.Errorf("error deleting etcd member %s: %w", name, err)
}

return true, nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ func (s *CAPIDockerMachineChangeTemplate) TestCAPIControlPlaneDockerDownScaling(
Into(&obj)
s.Require().NoError(err)
s.Require().Equal("docker-test-cp-template-new-2", obj.GetAnnotations()[clusterv1.TemplateClonedFromNameAnnotation])

err = wait.PollUntilContextCancel(s.ctx, 1*time.Second, true, func(ctx context.Context) (bool, error) {
b, _ := s.client.RESTClient().
Get().
AbsPath("/healthz").
DoRaw(context.Background())

return string(b) == "ok", nil
})
s.Require().NoError(err)
}

func (s *CAPIDockerMachineChangeTemplate) applyClusterObjects() {
Expand Down

0 comments on commit 726cd89

Please sign in to comment.