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

Sync TiDB service in control-loop #1242

Merged
merged 11 commits into from
Nov 29, 2019
Merged

Sync TiDB service in control-loop #1242

merged 11 commits into from
Nov 29, 2019

Conversation

aylei
Copy link
Contributor

@aylei aylei commented Nov 27, 2019

Signed-off-by: Aylei [email protected]

What problem does this PR solve?

close #1190

What is changed and how does it work?

Add syncTiDBService in tidb_member_manager

Check List

Tests

  • Unit test
  • E2E test

Does this PR introduce a user-facing change?:

Manage TiDB service in tidb-controller-manager.

@aylei
Copy link
Contributor Author

aylei commented Nov 27, 2019

/run-e2e-in-kind

@@ -122,7 +122,7 @@ func (tmm *tidbMemberManager) syncTiDBHeadlessServiceForTidbCluster(tc *v1alpha1
if !equal {
svc := *oldSvc
svc.Spec = newSvc.Spec
err = SetServiceLastAppliedConfigAnnotation(newSvc)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix an old typo

oldSvc := oldSvcTmp.DeepCopy()

// Adopt orphaned service by simply overriding
if metav1.GetControllerOf(oldSvc) == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adopting orphaned objects is a systematic problem that should be considered at project level in a separate issue, this PR adopts the TiDB service only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if err != nil {
return err
}
annoEqual := isSubMapOf(newSvc.Annotations, oldSvc.Annotations)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Annotation directly added by user will be retained.

@aylei
Copy link
Contributor Author

aylei commented Nov 27, 2019

/run-e2e-in-kind

Spec: corev1.ServiceSpec{
Type: svcSpec.Type,
Ports: ports,
ExternalTrafficPolicy: svcSpec.ExternalTrafficPolicy,
Copy link
Member

Choose a reason for hiding this comment

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

For api server, this should have validation and defaulting.

@@ -93,7 +93,11 @@ func (tmm *tidbMemberManager) Sync(tc *v1alpha1.TidbCluster) error {
}

// Sync Tidb StatefulSet
return tmm.syncTiDBStatefulSetForTidbCluster(tc)
if err := tmm.syncTiDBStatefulSetForTidbCluster(tc); err != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit worried that if something goes wrong with sts synchronization, then the service will not be synchronized too.

Copy link
Contributor Author

@aylei aylei Nov 27, 2019

Choose a reason for hiding this comment

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

Yes, such dangers are everywhere in today's tidb-controller-manager because of synchronized reconciling, this should be a systematic improvement that I'd like to collect efforts in a dedicated ticket

Copy link
Contributor Author

Choose a reason for hiding this comment

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

follow up: #1245

@aylei
Copy link
Contributor Author

aylei commented Nov 27, 2019

/run-e2e-in-kind

1 similar comment
@aylei
Copy link
Contributor Author

aylei commented Nov 27, 2019

/run-e2e-in-kind

@aylei
Copy link
Contributor Author

aylei commented Nov 27, 2019

/run-e2e-in-kind

1 similar comment
@aylei
Copy link
Contributor Author

aylei commented Nov 27, 2019

/run-e2e-in-kind

@aylei
Copy link
Contributor Author

aylei commented Nov 28, 2019

/run-e2e-in-kind

Copy link
Member

@tennix tennix left a comment

Choose a reason for hiding this comment

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

LGTM

@aylei
Copy link
Contributor Author

aylei commented Nov 28, 2019

/run-e2e-in-kind

1 similar comment
@aylei
Copy link
Contributor Author

aylei commented Nov 28, 2019

/run-e2e-in-kind

@aylei
Copy link
Contributor Author

aylei commented Nov 28, 2019

/run-e2e-test

Copy link
Contributor

@DanielZhangQD DanielZhangQD left a comment

Choose a reason for hiding this comment

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

LGTM

@aylei
Copy link
Contributor Author

aylei commented Nov 29, 2019

/run-e2e-test

Copy link
Contributor

@DanielZhangQD DanielZhangQD left a comment

Choose a reason for hiding this comment

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

LGTM

@aylei aylei merged commit f8f4418 into pingcap:master Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sync TiDB service in control-loop
5 participants