Skip to content

Commit

Permalink
fix PD StartTimeout if no CRD updated (#5096)
Browse files Browse the repository at this point in the history
  • Loading branch information
csuzhangxc authored Jun 26, 2023
1 parent 054aeae commit ebb269d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
8 changes: 8 additions & 0 deletions pkg/apis/pingcap/v1alpha1/tidbcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion pkg/manager/member/startscript/v1/render_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions pkg/manager/member/startscript/v1/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/member/startscript/v2/pd_start_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/manager/member/startscript/v2/pd_start_script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ebb269d

Please sign in to comment.