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

fix some orphan pods cleaner bugs #878

Merged
merged 9 commits into from
Sep 5, 2019
Merged

Conversation

cofyc
Copy link
Contributor

@cofyc cofyc commented Sep 5, 2019

What problem does this PR solve?

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 Helm charts change
  • Has Go code change
  • Has CI related scripts change
  • Has documents 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?:

NONE


// Start informer factories after all controller are initializated.
informerFactory.Start(controllerCtx.Done())
kubeInformerFactory.Start(controllerCtx.Done())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Start will start a new goroutine, so no need to use go ... here.

aylei
aylei previously approved these changes Sep 5, 2019
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

@@ -89,6 +118,9 @@ func (opc *orphanPodsCleaner) Clean(tc *v1alpha1.TidbCluster) (map[string]string
return skipReason, err
}

// if the PVC is not found in apiserver (also informer cache) and the
// phrase of the Pod is Pending, delete it and let the stateful
// controller to create the pod and its PVC(s) again
err = opc.podControl.DeletePod(tc, pod)
Copy link
Contributor

Choose a reason for hiding this comment

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

only delete pod if the pod status is Pending

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I forgot it...added in 9791178

@cofyc
Copy link
Contributor Author

cofyc commented Sep 5, 2019

/run-e2e-in-kind

pkg/manager/member/orphan_pods_cleaner.go Outdated Show resolved Hide resolved
pkg/manager/member/orphan_pods_cleaner.go Outdated Show resolved Hide resolved
pkg/manager/member/orphan_pods_cleaner.go Outdated Show resolved Hide resolved
onlymellb
onlymellb previously approved these changes Sep 5, 2019
Copy link
Contributor

@onlymellb onlymellb left a comment

Choose a reason for hiding this comment

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

LGTM

weekface
weekface previously approved these changes Sep 5, 2019
@weekface
Copy link
Contributor

weekface commented Sep 5, 2019

/run-e2e-in-kind

@cofyc cofyc dismissed stale reviews from weekface and onlymellb via 017bd4e September 5, 2019 09:49
tennix
tennix previously approved these changes Sep 5, 2019
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

// if the PVC is not found in apiserver (also informer cache) and the
// phase of the Pod is Pending, delete it and let the stateful
// controller to create the pod and its PVC(s) again
apiPod, err := opc.kubeCli.CoreV1().Pods(pod.Namespace).Get(pod.Name, metav1.GetOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Use ns and podName instead of pod.Namespace and pod.Name

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

@cofyc
Copy link
Contributor Author

cofyc commented Sep 5, 2019

/run-e2e-in-kind

return skipReason, err
}
// try our best to avoid deleting wrong object in apiserver
// TODO upgrade to use deleteOption.Preconditions.ResourceVersion in client-go 1.14+
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cofyc
Copy link
Contributor Author

cofyc commented Sep 5, 2019

/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.

LGTM

@cofyc
Copy link
Contributor Author

cofyc commented Sep 5, 2019

/run-e2e-in-kind

@cofyc
Copy link
Contributor Author

cofyc commented Sep 5, 2019

/run-e2e-tests

@cofyc
Copy link
Contributor Author

cofyc commented Sep 5, 2019

/run-e2e-in-kind

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

@cofyc
Copy link
Contributor Author

cofyc commented Sep 5, 2019

/run-e2e-in-kind

@weekface
Copy link
Contributor

weekface commented Sep 5, 2019

/run-e2e-tests

1 similar comment
@tennix
Copy link
Member

tennix commented Sep 5, 2019

/run-e2e-tests

@tennix tennix merged commit 038b0c9 into pingcap:master Sep 5, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Sep 5, 2019

cherry pick to release-1.0 failed

cofyc added a commit to cofyc/tidb-operator that referenced this pull request Sep 6, 2019
* fix some orphan pods cleaner bugs

* pod pending check

* reword

* fix typo

* fast path

* double check pod in apiserver
cofyc added a commit to cofyc/tidb-operator that referenced this pull request Sep 6, 2019
* fix some orphan pods cleaner bugs

* pod pending check

* reword

* fix typo

* fast path

* double check pod in apiserver
cofyc added a commit that referenced this pull request Sep 6, 2019
* fix some orphan pods cleaner bugs

* pod pending check

* reword

* fix typo

* fast path

* double check pod in apiserver
tennix pushed a commit that referenced this pull request Sep 6, 2019
* fix some orphan pods cleaner bugs

* pod pending check

* reword

* fix typo

* fast path

* double check pod in apiserver
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.

7 participants