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

Stability: only expect upgrade complete when rollback bad conf #1030

Merged
merged 3 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ type OperatorActions interface {
SetPartitionAnnotation(tcName string, nameSpace string, ordinal int) error
CheckManualPauseTiDB(info *TidbClusterConfig) error
CheckManualPauseTiDBOrDie(info *TidbClusterConfig)
CheckUpgradeComplete(info *TidbClusterConfig) error
CheckUpgradeCompleteOrDie(info *TidbClusterConfig)
}

type operatorActions struct {
Expand Down Expand Up @@ -3015,6 +3017,40 @@ func (oa *operatorActions) CheckManualPauseTiDBOrDie(info *TidbClusterConfig) {
}
}

func (oa *operatorActions) CheckUpgradeComplete(info *TidbClusterConfig) error {
ns, tcName := info.Namespace, info.ClusterName
if err := wait.PollImmediate(15*time.Second, DefaultPollTimeout, func() (done bool, err error) {
tc, err := oa.cli.PingcapV1alpha1().TidbClusters(ns).Get(tcName, metav1.GetOptions{})
if err != nil {
glog.Errorf("checkUpgradeComplete, [%s/%s] cannot get tidbcluster, %v", ns, tcName, err)
return false, nil
}
if tc.Status.PD.Phase == v1alpha1.UpgradePhase {
glog.Errorf("checkUpgradeComplete, [%s/%s] PD is still upgrading", ns, tcName)
return false, nil
}
if tc.Status.TiKV.Phase == v1alpha1.UpgradePhase {
glog.Errorf("checkUpgradeComplete, [%s/%s] TiKV is still upgrading", ns, tcName)
return false, nil
}
if tc.Status.TiDB.Phase == v1alpha1.UpgradePhase {
glog.Errorf("checkUpgradeComplete, [%s/%s] TiDB is still upgrading", ns, tcName)
return false, nil
}
return true, nil
}); err != nil {
glog.Errorf("failed to wait upgrade complete [%s/%s], %v", ns, tcName, err)
return err
}
return nil
}

func (oa *operatorActions) CheckUpgradeCompleteOrDie(info *TidbClusterConfig) {
if err := oa.CheckUpgradeComplete(info); err != nil {
slack.NotifyAndPanic(err)
}
}

func StartValidatingAdmissionWebhookServerOrDie(context *apimachinery.CertContext) {
sCert, err := tls.X509KeyPair(context.Cert, context.Key)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions tests/cmd/stability/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ func run() {
time.Sleep(30 * time.Second)
oa.CheckTidbClustersAvailableOrDie([]*tests.TidbClusterConfig{cluster})
// rollback conf
cluster.PDPreStartScript = strconv.Quote("# noop")
cluster.TiKVPreStartScript = strconv.Quote("# noop")
cluster.TiDBPreStartScript = strconv.Quote("# noop")
cluster.PDPreStartScript = strconv.Quote("")
cluster.TiKVPreStartScript = strconv.Quote("")
cluster.TiDBPreStartScript = strconv.Quote("")
oa.UpgradeTidbClusterOrDie(cluster)
// wait upgrade complete
oa.CheckUpgradeOrDie(ctx, cluster)
oa.CheckUpgradeCompleteOrDie(cluster)
oa.CheckTidbClusterStatusOrDie(cluster)

cluster.UpdatePdMaxReplicas(cfg.PDMaxReplicas).
Expand Down