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

Migrate Kubernetes StatefulSet to Advanced StatefulSet automatically #1580

Merged
merged 2 commits into from
Jan 19, 2020

Conversation

cofyc
Copy link
Contributor

@cofyc cofyc commented Jan 17, 2020

Signed-off-by: Yecheng Fu [email protected]

What problem does this PR solve?

fixes #1115

What is changed and how does it work?

Check List

Tests

  • Unit test
  • E2E test
  • Stability test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

  • Has Go code change
  • Has CI related scripts change
  • Has Terraform scripts change

Side effects

  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Does this PR introduce a user-facing change?:

Able to migrate existing Kubernetes StatefulSets to Advanced StatefulSets automatically when AdvancedStatfulSet feature is enabled

@@ -704,7 +704,7 @@ var _ = ginkgo.Describe("[tidb-operator] TiDBCluster", func() {
})

ginkgo.It("should be operable without helm [API]", func() {
tc := fixture.GetTidbCluster(ns, "plain-cr", "v2.1.16")
tc := fixture.GetTidbCluster(ns, "plain-cr", utilimage.TiDBV2Version)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use shared version to reduce the total images we used in e2e

@cofyc
Copy link
Contributor Author

cofyc commented Jan 18, 2020

/run-e2e-tests

1 similar comment
@cofyc
Copy link
Contributor Author

cofyc commented Jan 18, 2020

/run-e2e-tests

Copy link
Contributor

@aylei aylei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest LGTM

Comment on lines 333 to 338
defer func() {
// ginkgo.By("Uninstall tidb-operator")
// oa.CleanOperatorOrDie(ocfg)
// ginkgo.By("Uninstalling CRDs")
// oa.CleanCRDOrDie()
}()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this or add a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I should uncomment these lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 77 to 83
klog.Infof("Upgrader: found %d Kubernetes StatefulSets, trying to migrate one by one", len(stsList.Items))
for _, sts := range stsList.Items {
_, err := helper.Upgrade(u.kubeCli, u.asCli, &sts)
if err != nil {
return err
}
klog.Infof("Upgrader: successfully migrated Kubernetes StatefulSet %s/%s", sts.Namespace, sts.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only migrate statefulset owned by tidbcluster

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in d9f0d8e

@cofyc cofyc requested review from Yisaer and weekface January 19, 2020 01:22
@Yisaer
Copy link
Contributor

Yisaer commented Jan 19, 2020

@cofyc Could add some details to explain how helper.Upgrade work? I think it's the most important information in this request.

@Yisaer
Copy link
Contributor

Yisaer commented Jan 19, 2020

@cofyc Could add some details to explain how helper.Upgrade work? I think it's the most important information in this request.

The Rest LGTM

Copy link
Contributor

@aylei aylei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cofyc
Copy link
Contributor Author

cofyc commented Jan 19, 2020

sure, the basic procedure is like this:

  • remove sts selector labels from controller revisions and set a special annotation for Advanced StatefulSet (can be skipped if Kubernetes cluster has http://issues.k8s.io/84982 fixed)
  • create advanced sts
  • delete sts with DeletePropagationOrphan policy

https://github.com/pingcap/advanced-statefulset/blob/087fc829087b081c91e05af323d82fe4849c510e/pkg/apis/apps/v1/helper/upgrade.go#L32-L116

Copy link
Contributor

@Yisaer Yisaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sre-bot
Copy link
Contributor

sre-bot commented Jan 19, 2020

cherry pick to release-1.1 in PR #1583

cofyc added a commit that referenced this pull request Jan 19, 2020
…1580) (#1583)

* Upgrade to Advanced StatefulSet automatically

Signed-off-by: Yecheng Fu <[email protected]>

* we should only migrate statefulsets owned by tidbcluster

Signed-off-by: Yecheng Fu <[email protected]>

Co-authored-by: Yecheng Fu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

advanced-statefulset: upgrade to advanced-statefulset automatically
4 participants