Skip to content

Commit 85cda66

Browse files
authored
Fix do not retry when GetMemberReady fail (#6293) (#6297)
1 parent f586249 commit 85cda66

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

pkg/controllers/pd/tasks/ctx.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package tasks
1717
import (
1818
"context"
1919

20-
"github.com/go-logr/logr"
2120
"k8s.io/apimachinery/pkg/api/errors"
2221

2322
"github.com/pingcap/tidb-operator/api/v2/core/v1alpha1"
@@ -70,11 +69,9 @@ func TaskContextInfoFromPD(state *ReconcileContext, cm pdm.PDClientManager) task
7069
state.MemberID = m.ID
7170
state.IsLeader = m.IsLeader
7271

73-
logger := logr.FromContextOrDiscard(ctx)
7472
ready, err := state.PDClient.Underlay().GetMemberReady(ctx, getPDURL(ck, pd), pd.Spec.Version)
75-
if err != nil {
76-
// Do not return error here, because the pd pod may not be created yet.
77-
logger.Error(err, "failed to get member ready")
73+
if err != nil || !ready {
74+
return task.Retry(task.DefaultRequeueAfter).With("failed to get member ready (err: %w) or pd is not ready", err)
7875
}
7976

8077
// set available and trust health info only when member info is valid

tests/e2e/tidb/tidb.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ GRANT ALL PRIVILEGES ON *.* TO '%s'@'%s';`, sub, iss, email, sub, "%")
103103
})
104104

105105
ginkgo.Context("Scale and Update", label.P0, func() {
106-
ginkgo.It("support scale TiDB form 3 to 5", label.Scale, func(ctx context.Context) {
106+
ginkgo.It("support scale TiDB from 1 to 4", label.Scale, func(ctx context.Context) {
107107
pdg := f.MustCreatePD(ctx)
108108
kvg := f.MustCreateTiKV(ctx)
109109
dbg := f.MustCreateTiDB(ctx,
110-
data.WithReplicas[*runtime.TiDBGroup](3),
110+
data.WithReplicas[*runtime.TiDBGroup](1),
111111
)
112112

113113
ginkgo.By("Wait for Cluster Ready")
@@ -116,14 +116,14 @@ GRANT ALL PRIVILEGES ON *.* TO '%s'@'%s';`, sub, iss, email, sub, "%")
116116
f.WaitForTiDBGroupReady(ctx, dbg)
117117

118118
patch := client.MergeFrom(dbg.DeepCopy())
119-
dbg.Spec.Replicas = ptr.To[int32](5)
119+
dbg.Spec.Replicas = ptr.To[int32](4)
120120

121121
ginkgo.By("Change replica of the TiDBGroup")
122122
f.Must(f.Client.Patch(ctx, dbg, patch))
123123
f.WaitForTiDBGroupReady(ctx, dbg)
124124
})
125125

126-
ginkgo.It("support scale TiDB form 5 to 3", label.Scale, func(ctx context.Context) {
126+
ginkgo.It("support scale TiDB from 5 to 3", label.Scale, func(ctx context.Context) {
127127
pdg := f.MustCreatePD(ctx)
128128
kvg := f.MustCreateTiKV(ctx)
129129
dbg := f.MustCreateTiDB(ctx,
@@ -263,7 +263,7 @@ GRANT ALL PRIVILEGES ON *.* TO '%s'@'%s';`, sub, iss, email, sub, "%")
263263
}),
264264
)
265265

266-
ginkgo.It("support scale TiDB form 5 to 3 and rolling update at same time", label.Scale, label.Update, func(ctx context.Context) {
266+
ginkgo.It("support scale TiDB from 5 to 3 and rolling update at same time", label.Scale, label.Update, func(ctx context.Context) {
267267
pdg := f.MustCreatePD(ctx)
268268
kvg := f.MustCreateTiKV(ctx)
269269
dbg := f.MustCreateTiDB(ctx,

0 commit comments

Comments
 (0)