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

add operator upgrade case #579

Merged
merged 12 commits into from
Jun 21, 2019
31 changes: 28 additions & 3 deletions tests/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type OperatorActions interface {
CleanOperator(info *OperatorConfig) error
CleanOperatorOrDie(info *OperatorConfig)
UpgradeOperator(info *OperatorConfig) error
UpgradeOperatorOrDie(info *OperatorConfig)
DumpAllLogs(info *OperatorConfig, clusterInfos []*TidbClusterConfig) error
DeployTidbCluster(info *TidbClusterConfig) error
DeployTidbClusterOrDie(info *TidbClusterConfig)
Expand Down Expand Up @@ -162,6 +163,7 @@ type OperatorActions interface {
RegisterWebHookAndService(context *apimachinery.CertContext, info *OperatorConfig) error
RegisterWebHookAndServiceOrDie(context *apimachinery.CertContext, info *OperatorConfig)
CleanWebHookAndService(info *OperatorConfig) error
CleanWebHookAndServiceOrDie(info *OperatorConfig)
EventWorker()
EmitEvent(info *TidbClusterConfig, msg string)
BackupRestore(from, to *TidbClusterConfig) error
Expand Down Expand Up @@ -449,14 +451,14 @@ func (oa *operatorActions) CleanOperatorOrDie(info *OperatorConfig) {
}

func (oa *operatorActions) UpgradeOperator(info *OperatorConfig) error {
glog.Infof("upgrading tidb-operator %s", info.ReleaseName)
if err := oa.checkoutTag(info.Tag); err != nil {
return err
}

cmd := fmt.Sprintf(`helm upgrade %s %s
--set operatorImage=%s`,
cmd := fmt.Sprintf("helm upgrade %s %s --set-string %s",
info.ReleaseName, oa.operatorChartPath(info.Tag),
info.Image)
info.OperatorHelmSetString(nil))

res, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput()
if err != nil {
Expand All @@ -465,7 +467,20 @@ func (oa *operatorActions) UpgradeOperator(info *OperatorConfig) error {
return nil
}

func (oa *operatorActions) UpgradeOperatorOrDie(info *OperatorConfig) {
if err := oa.UpgradeOperator(info); err != nil {
slack.NotifyAndPanic(err)
}
}

func (oa *operatorActions) DeployTidbCluster(info *TidbClusterConfig) error {
ns := info.Namespace
tcName := info.ClusterName
if _, err := oa.cli.PingcapV1alpha1().TidbClusters(ns).Get(tcName, metav1.GetOptions{}); err == nil {
// already deployed
return nil
}

glog.Infof("deploying tidb cluster [%s/%s]", info.Namespace, info.ClusterName)
oa.EmitEvent(info, "DeployTidbCluster")

Expand Down Expand Up @@ -750,6 +765,9 @@ func (oa *operatorActions) BeginInsertDataToOrDie(info *TidbClusterConfig) {
}

func (oa *operatorActions) StopInsertDataTo(info *TidbClusterConfig) {
if info.blockWriter == nil {
return
}
oa.EmitEvent(info, "StopInsertData")

info.blockWriter.Stop()
Expand Down Expand Up @@ -2257,6 +2275,13 @@ func (oa *operatorActions) CleanWebHookAndService(info *OperatorConfig) error {
return nil
}

func (oa *operatorActions) CleanWebHookAndServiceOrDie(info *OperatorConfig) {
err := oa.CleanWebHookAndService(info)
if err != nil {
slack.NotifyAndPanic(err)
}
}

type pumpStatus struct {
StatusMap map[string]*nodeStatus
}
Expand Down
Loading