diff --git a/pkg/apis/pingcap/v1alpha1/tidbcluster.go b/pkg/apis/pingcap/v1alpha1/tidbcluster.go index 18fad29d9a..8f4698f002 100644 --- a/pkg/apis/pingcap/v1alpha1/tidbcluster.go +++ b/pkg/apis/pingcap/v1alpha1/tidbcluster.go @@ -43,6 +43,7 @@ const ( // defaultTiCDCGracefulShutdownTimeout is the timeout limit of graceful // shutdown a TiCDC pod. defaultTiCDCGracefulShutdownTimeout = 10 * time.Minute + defaultPDStartTimeout = 30 // the latest version versionLatest = "latest" @@ -1250,3 +1251,10 @@ func (tc *TidbCluster) StartScriptVersion() StartScriptVersion { return StartScriptV1 } } + +func (tc *TidbCluster) PDStartTimeout() int { + if tc.Spec.PD != nil && tc.Spec.PD.StartTimeout != 0 { + return tc.Spec.PD.StartTimeout + } + return defaultPDStartTimeout +} diff --git a/pkg/manager/member/startscript/v1/render_script.go b/pkg/manager/member/startscript/v1/render_script.go index fdb2844df0..ca79d5481b 100644 --- a/pkg/manager/member/startscript/v1/render_script.go +++ b/pkg/manager/member/startscript/v1/render_script.go @@ -65,7 +65,7 @@ func RenderPDStartScript(tc *v1alpha1.TidbCluster) (string, error) { }, Scheme: tc.Scheme(), DataDir: filepath.Join(constants.PDDataVolumeMountPath, tc.Spec.PD.DataSubDir), - PDStartTimeout: tc.Spec.PD.StartTimeout, + PDStartTimeout: tc.PDStartTimeout(), } if tc.Spec.PD.StartUpScriptVersion == "v1" { model.CheckDomainScript = checkDNSV1 diff --git a/pkg/manager/member/startscript/v1/template_test.go b/pkg/manager/member/startscript/v1/template_test.go index 8a7281070e..6fb0edce73 100644 --- a/pkg/manager/member/startscript/v1/template_test.go +++ b/pkg/manager/member/startscript/v1/template_test.go @@ -1227,9 +1227,7 @@ exec /pd-server ${ARGS} tc := &v1alpha1.TidbCluster{ Spec: v1alpha1.TidbClusterSpec{ - PD: &v1alpha1.PDSpec{ - StartTimeout: 30, - }, + PD: &v1alpha1.PDSpec{}, }, } tc.Name = "test-pd" diff --git a/pkg/manager/member/startscript/v2/pd_start_script.go b/pkg/manager/member/startscript/v2/pd_start_script.go index 7fdbb9c865..d5398c5d22 100644 --- a/pkg/manager/member/startscript/v2/pd_start_script.go +++ b/pkg/manager/member/startscript/v2/pd_start_script.go @@ -67,7 +67,7 @@ func RenderPDStartScript(tc *v1alpha1.TidbCluster) (string, error) { m.DiscoveryAddr = fmt.Sprintf("%s-discovery.%s:10261", tcName, tcNS) - m.PDStartTimeout = tc.Spec.PD.StartTimeout + m.PDStartTimeout = tc.PDStartTimeout() return renderTemplateFunc(pdStartScriptTpl, m) } diff --git a/pkg/manager/member/startscript/v2/pd_start_script_test.go b/pkg/manager/member/startscript/v2/pd_start_script_test.go index f9666b47de..fc0b838348 100644 --- a/pkg/manager/member/startscript/v2/pd_start_script_test.go +++ b/pkg/manager/member/startscript/v2/pd_start_script_test.go @@ -543,9 +543,7 @@ exec /pd-server ${ARGS} tc := &v1alpha1.TidbCluster{ Spec: v1alpha1.TidbClusterSpec{ - PD: &v1alpha1.PDSpec{ - StartTimeout: 30, - }, + PD: &v1alpha1.PDSpec{}, }, } tc.Name = "start-script-test"