Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into yinliang/modify-b…
Browse files Browse the repository at this point in the history
…r-tls
  • Loading branch information
shuijing198799 committed Mar 23, 2020
2 parents 029f661 + cd4302a commit 23fe800
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 34 deletions.
2 changes: 2 additions & 0 deletions charts/tidb-cluster/templates/tidb-initializer-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ spec:
fi
done
echo "info: successfully connected to $host:$port, able to initialize TiDB now"
resources:
{{ toYaml .Values.tidb.initializer.resources | indent 10 }}
containers:
- name: mysql-client
image: {{ .Values.mysqlClient.image }}
Expand Down
12 changes: 6 additions & 6 deletions charts/tidb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,12 @@ tidb:

initializer:
resources: {}
# limits:
# cpu: 100m
# memory: 100Mi
# requests:
# cpu: 100m
# memory: 100Mi
# limits:
# cpu: 100m
# memory: 100Mi
# requests:
# cpu: 100m
# memory: 100Mi

# tidb plugin configuration
plugin:
Expand Down
2 changes: 1 addition & 1 deletion deploy/modules/aliyun/tidb-operator/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
terraform {
required_version = ">= 0.12"
required_providers {
alicloud = "~> 1.56"
alicloud = ">= 1.56, < 1.75"
external = "~> 1.2"
helm = "~> 0.10"
null = "~> 2.1"
Expand Down
18 changes: 9 additions & 9 deletions hack/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@ e2e_args=(
--
--clean-start=true
--delete-namespace-on-failure=false
--repo-root=$ROOT
--repo-root="$ROOT"
# tidb-operator e2e flags
--operator-tag=e2e
--operator-image=${TIDB_OPERATOR_IMAGE}
--e2e-image=${E2E_IMAGE}
--operator-image="${TIDB_OPERATOR_IMAGE}"
--e2e-image="${E2E_IMAGE}"
# two tidb versions can be configuraed: <defaultVersion>,<upgradeToVersion>
--tidb-versions=v3.0.7,v3.0.8
--chart-dir=/charts
Expand All @@ -354,18 +354,18 @@ docker_args=(
if [ "$PROVIDER" == "eks" ]; then
e2e_args+=(
--provider=aws
--gce-zone ${AWS_REGION}
--gce-zone="${AWS_REGION}"
)
# aws credential is required to get token for EKS
docker_args+=(
-v $HOME/.aws:/root/.aws
)
elif [ "$PROVIDER" == "gke" ]; then
e2e_args+=(
--provider=${PROVIDER}
--gce-project ${GCP_PROJECT}
--gce-region ${GCP_REGION}
--gce-zone ${GCP_ZONE}
--provider="${PROVIDER}"
--gce-project="${GCP_PROJECT}"
--gce-region="${GCP_REGION}"
--gce-zone="${GCP_ZONE}"
)
docker_args+=(
-v ${GCP_CREDENTIALS}:${GCP_CREDENTIALS}
Expand All @@ -382,7 +382,7 @@ elif [ "$PROVIDER" == "gke" ]; then
)
else
e2e_args+=(
--provider=${PROVIDER}
--provider="${PROVIDER}"
)
fi

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/pod_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (rpc *realPodControl) DeletePod(tc *v1alpha1.TidbCluster, pod *corev1.Pod)
ns := tc.GetNamespace()
tcName := tc.GetName()
podName := pod.GetName()
preconditions := metav1.Preconditions{UID: &pod.UID}
preconditions := metav1.Preconditions{UID: &pod.UID, ResourceVersion: &pod.ResourceVersion}
deleteOptions := metav1.DeleteOptions{Preconditions: &preconditions}
err := rpc.kubeCli.CoreV1().Pods(ns).Delete(podName, &deleteOptions)
if err != nil {
Expand Down
24 changes: 12 additions & 12 deletions pkg/manager/member/orphan_pods_cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1"
"github.com/pingcap/tidb-operator/pkg/controller"
"github.com/pingcap/tidb-operator/pkg/label"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand All @@ -26,12 +25,12 @@ import (
)

const (
skipReasonOrphanPodsCleanerIsNotPDOrTiKV = "orphan pods cleaner: member type is not pd or tikv"
skipReasonOrphanPodsCleanerPVCNameIsEmpty = "orphan pods cleaner: pvcName is empty"
skipReasonOrphanPodsCleanerPVCIsFound = "orphan pods cleaner: pvc is found"
skipReasonOrphanPodsCleanerPodIsNotPending = "orphan pods cleaner: pod is not pending"
skipReasonOrphanPodsCleanerPodIsNotFound = "orphan pods cleaner: pod does not exist anymore"
skipReasonOrphanPodsCleanerPodChanged = "orphan pods cleaner: pod changed before deletion"
skipReasonOrphanPodsCleanerIsNotPDOrTiKV = "orphan pods cleaner: member type is not pd or tikv"
skipReasonOrphanPodsCleanerPVCNameIsEmpty = "orphan pods cleaner: pvcName is empty"
skipReasonOrphanPodsCleanerPVCIsFound = "orphan pods cleaner: pvc is found"
skipReasonOrphanPodsCleanerPodHasBeenScheduled = "orphan pods cleaner: pod has been scheduled"
skipReasonOrphanPodsCleanerPodIsNotFound = "orphan pods cleaner: pod does not exist anymore"
skipReasonOrphanPodsCleanerPodChanged = "orphan pods cleaner: pod changed before deletion"
)

// OrphanPodsCleaner implements the logic for cleaning the orphan pods(has no pvc)
Expand Down Expand Up @@ -88,8 +87,8 @@ func (opc *orphanPodsCleaner) Clean(tc *v1alpha1.TidbCluster) (map[string]string
continue
}

if pod.Status.Phase != v1.PodPending {
skipReason[podName] = skipReasonOrphanPodsCleanerPodIsNotPending
if len(pod.Spec.NodeName) > 0 {
skipReason[podName] = skipReasonOrphanPodsCleanerPodHasBeenScheduled
continue
}

Expand Down Expand Up @@ -128,7 +127,7 @@ func (opc *orphanPodsCleaner) Clean(tc *v1alpha1.TidbCluster) (map[string]string
}

// 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
// pod has not been scheduled, delete it and let the stateful
// controller to create the pod and its PVC(s) again
apiPod, err := opc.kubeCli.CoreV1().Pods(ns).Get(podName, metav1.GetOptions{})
if errors.IsNotFound(err) {
Expand All @@ -138,8 +137,9 @@ func (opc *orphanPodsCleaner) Clean(tc *v1alpha1.TidbCluster) (map[string]string
if err != nil {
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+
// In pre-1.14, kube-apiserver does not support
// deleteOption.Preconditions.ResourceVersion, we try our best to avoid
// deleting wrong object in apiserver.
if apiPod.UID != pod.UID || apiPod.ResourceVersion != pod.ResourceVersion {
skipReason[podName] = skipReasonOrphanPodsCleanerPodChanged
continue
Expand Down
10 changes: 5 additions & 5 deletions pkg/manager/member/orphan_pods_cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ func TestOrphanPodsCleanerClean(t *testing.T) {
},
},
{
name: "pvc is not found but pod is not pending",
// in theory, this is is possible because we can't check the PVC
// and pod in an atomic operation.
name: "pvc is not found but pod has been scheduled",
pods: []*corev1.Pod{
{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -246,17 +248,15 @@ func TestOrphanPodsCleanerClean(t *testing.T) {
},
},
},
},
Status: corev1.PodStatus{
Phase: corev1.PodRunning,
NodeName: "foobar",
},
},
},
pvcs: []*corev1.PersistentVolumeClaim{},
expectFn: func(g *GomegaWithT, skipReason map[string]string, opc *orphanPodsCleaner, err error) {
g.Expect(err).NotTo(HaveOccurred())
g.Expect(len(skipReason)).To(Equal(1))
g.Expect(skipReason["pod-1"]).To(Equal(skipReasonOrphanPodsCleanerPodIsNotPending))
g.Expect(skipReason["pod-1"]).To(Equal(skipReasonOrphanPodsCleanerPodHasBeenScheduled))
},
},
{
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

e2econfig "github.com/pingcap/tidb-operator/tests/e2e/config"
"k8s.io/klog"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework/config"
"k8s.io/kubernetes/test/e2e/framework/testfiles"
Expand Down Expand Up @@ -52,6 +53,10 @@ func TestMain(m *testing.M) {
// Register test flags, then parse flags.
handleFlags()

flag.CommandLine.VisitAll(func(flag *flag.Flag) {
klog.V(1).Infof("FLAG: --%s=%q", flag.Name, flag.Value)
})

// Now that we know which Viper config (if any) was chosen,
// parse it and update those options which weren't already set via command line flags
// (which have higher priority).
Expand Down

0 comments on commit 23fe800

Please sign in to comment.