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

cluster: remove tombstone nodes on pd when prune #2044

Merged
merged 9 commits into from
Jun 25, 2024
10 changes: 10 additions & 0 deletions pkg/cluster/api/pdapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ var (
pdStoreURI = "pd/api/v1/store"
pdStoresURI = "pd/api/v1/stores"
pdStoresLimitURI = "pd/api/v1/stores/limit"
pdRemoveTombstone = "pd/api/v1/stores/remove-tombstone"
pdRegionsCheckURI = "pd/api/v1/regions/check"
)

Expand Down Expand Up @@ -839,6 +840,15 @@ func (pc *PDClient) DelStore(host string, retryOpt *utils.RetryOption) error {
return nil
}

func (pc *PDClient) RemoveTombstone() error {
endpoints := pc.getEndpoints(pdRemoveTombstone)
_, err := tryURLs(endpoints, func(endpoint string) ([]byte, error) {
_, _, err := pc.httpClient.Delete(pc.ctx, endpoint, nil)
return nil, err
})
return err
}

func (pc *PDClient) updateConfig(url string, body io.Reader) error {
endpoints := pc.getEndpoints(url)
_, err := tryURLs(endpoints, func(endpoint string) ([]byte, error) {
Expand Down
10 changes: 10 additions & 0 deletions pkg/cluster/manager/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ import (
"context"
"errors"
"fmt"
"time"

"github.com/fatih/color"
"github.com/joomcode/errorx"
perrs "github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/cluster/api"
"github.com/pingcap/tiup/pkg/cluster/clusterutil"
"github.com/pingcap/tiup/pkg/cluster/ctxt"
operator "github.com/pingcap/tiup/pkg/cluster/operation"
Expand Down Expand Up @@ -175,6 +177,14 @@ func (m *Manager) DestroyTombstone(
ParallelStep("+ Refresh instance configs", gOpt.Force, regenConfigTasks...).
ParallelStep("+ Reload prometheus and grafana", gOpt.Force,
buildReloadPromAndGrafanaTasks(metadata.GetTopology(), m.logger, gOpt)...).
Func("RemoveTomestoneNodesInPD", func(ctx context.Context) (err error) {
pdEndpoints := make([]string, 0)
for _, pd := range cluster.PDServers {
pdEndpoints = append(pdEndpoints, fmt.Sprintf("%s:%d", pd.Host, pd.ClientPort))
}
pdAPI := api.NewPDClient(ctx, pdEndpoints, time.Second*time.Duration(gOpt.APITimeout), tlsCfg)
return pdAPI.RemoveTombstone()
}).
Build()

if err := t.Execute(ctx); err != nil {
Expand Down
Loading