Skip to content

Commit

Permalink
Merge branch 'master' into release-1.1.0-beta.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yisaer committed Feb 26, 2020
2 parents a2067ff + 0d40d9c commit 4a495b9
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
14 changes: 14 additions & 0 deletions hack/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Environments:
KUBECONFIG path to the kubeconfig file, defaults: ~/.kube/config
SKIP_BUILD skip building binaries
SKIP_IMAGE_BUILD skip build and push images
SKIP_IMAGE_LOAD skip load images
SKIP_UP skip starting the cluster
SKIP_DOWN skip shutting down the cluster
SKIP_TEST skip running the test
Expand All @@ -75,6 +76,7 @@ Environments:
GINKGO_PARALLEL if set to `y`, will run specs in parallel, the number of nodes will be the number of cpus
GINKGO_NO_COLOR if set to `y`, suppress color output in default reporter
RUNNER_SUITE_NAME the suite name of runner
SKIP_GINKGO if set to `y`, skip ginkgo
Examples:
Expand Down Expand Up @@ -177,6 +179,7 @@ CLUSTER=${CLUSTER:-tidb-operator}
KUBECONFIG=${KUBECONFIG:-~/.kube/config}
SKIP_BUILD=${SKIP_BUILD:-}
SKIP_IMAGE_BUILD=${SKIP_IMAGE_BUILD:-}
SKIP_IMAGE_LOAD=${SKIP_IMAGE_LOAD:-}
SKIP_UP=${SKIP_UP:-}
SKIP_DOWN=${SKIP_DOWN:-}
SKIP_TEST=${SKIP_TEST:-}
Expand All @@ -196,6 +199,7 @@ KUBE_WORKERS=${KUBE_WORKERS:-3}
DOCKER_IO_MIRROR=${DOCKER_IO_MIRROR:-}
GCR_IO_MIRROR=${GCR_IO_MIRROR:-}
QUAY_IO_MIRROR=${QUAY_IO_MIRROR:-}
SKIP_GINKGO=${SKIP_GINKGO:-}
RUNNER_SUITE_NAME=${RUNNER_SUITE_NAME:-}

echo "PROVIDER: $PROVIDER"
Expand Down Expand Up @@ -481,12 +485,22 @@ else
exit 1
fi

if [ "${HOSTNAME:-}" == "tidb-operator-dev" -a ! -f /usr/local/bin/helm ]; then
ln -s $OUTPUT_BIN/helm /usr/local/bin/helm
fi

if [ "${HOSTNAME:-}" == "tidb-operator-dev" -a ! -f /usr/local/bin/kind ]; then
ln -s $KIND_BIN /usr/local/bin/kind
fi

# Environments for hack/run-e2e.sh
export PROVIDER
export CLUSTER
export KUBECONFIG
export GCP_PROJECT
export IMAGE_TAG
export SKIP_GINKGO
export SKIP_IMAGE_LOAD
export TIDB_OPERATOR_IMAGE=$DOCKER_REGISTRY/pingcap/tidb-operator:${IMAGE_TAG}
export E2E_IMAGE=$DOCKER_REGISTRY/pingcap/tidb-operator-e2e:${IMAGE_TAG}
export PATH=$PATH:$OUTPUT_BIN
Expand Down
12 changes: 11 additions & 1 deletion hack/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ PROVIDER=${PROVIDER:-}
CLUSTER=${CLUSTER:-}
GCP_PROJECT=${GCP_PROJECT:-}
IMAGE_TAG=${IMAGE_TAG:-}
SKIP_IMAGE_LOAD=${SKIP_IMAGE_LOAD:-}
TIDB_OPERATOR_IMAGE=${TIDB_OPERATOR_IMAGE:-localhost:5000/pingcap/tidb-operator:latest}
E2E_IMAGE=${E2E_IMAGE:-localhost:5000/pingcap/tidb-operator-e2e:latest}
KUBECONFIG=${KUBECONFIG:-$HOME/.kube/config}
Expand All @@ -38,6 +39,7 @@ GINKGO_PARALLEL=${GINKGO_PARALLEL:-n} # set to 'y' to run tests in parallel
# in parallel
GINKGO_NO_COLOR=${GINKGO_NO_COLOR:-n}
GINKGO_STREAM=${GINKGO_STREAM:-y}
SKIP_GINKGO=${SKIP_GINKGO:-}

if [ -z "$KUBECONFIG" ]; then
echo "error: KUBECONFIG is required"
Expand Down Expand Up @@ -261,10 +263,18 @@ if [ -z "$KUBECONTEXT" ]; then
echo "info: KUBECONTEXT is not set, current context $KUBECONTEXT is used"
fi

e2e::image_load
if [ -z "$SKIP_IMAGE_LOAD" ]; then
e2e::image_load
fi

e2e::setup_local_pvs
e2e::setup_helm_server

if [ -n "$SKIP_GINKGO" ]; then
echo "info: skipping ginkgo"
exit 0
fi

echo "info: start to run e2e process"

ginkgo_args=()
Expand Down
22 changes: 18 additions & 4 deletions pkg/manager/member/tidb_discovery_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package member

import (
"encoding/json"

"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1"
"github.com/pingcap/tidb-operator/pkg/controller"
"github.com/pingcap/tidb-operator/pkg/label"
Expand Down Expand Up @@ -81,8 +83,11 @@ func (m *realTidbDiscoveryManager) Reconcile(tc *v1alpha1.TidbCluster) error {
if err != nil {
return controller.RequeueErrorf("error creating or updating discovery rolebinding: %v", err)
}

deploy, err := m.ctrl.CreateOrUpdateDeployment(tc, getTidbDiscoveryDeployment(tc))
d, err := getTidbDiscoveryDeployment(tc)
if err != nil {
return controller.RequeueErrorf("error generating discovery deployment: %v", err)
}
deploy, err := m.ctrl.CreateOrUpdateDeployment(tc, d)
if err != nil {
return controller.RequeueErrorf("error creating or updating discovery service: %v", err)
}
Expand Down Expand Up @@ -111,9 +116,9 @@ func getTidbDiscoveryService(tc *v1alpha1.TidbCluster, deploy *appsv1.Deployment
}
}

func getTidbDiscoveryDeployment(tc *v1alpha1.TidbCluster) *appsv1.Deployment {
func getTidbDiscoveryDeployment(tc *v1alpha1.TidbCluster) (*appsv1.Deployment, error) {
meta, l := getDiscoveryMeta(tc, controller.DiscoveryMemberName)
return &appsv1.Deployment{
d := &appsv1.Deployment{
ObjectMeta: meta,
Spec: appsv1.DeploymentSpec{
Replicas: controller.Int32Ptr(1),
Expand Down Expand Up @@ -150,6 +155,15 @@ func getTidbDiscoveryDeployment(tc *v1alpha1.TidbCluster) *appsv1.Deployment {
},
},
}
b, err := json.Marshal(d.Spec.Template.Spec)
if err != nil {
return nil, err
}
if d.Annotations == nil {
d.Annotations = map[string]string{}
}
d.Annotations[controller.LastAppliedPodTemplate] = string(b)
return d, nil
}

func getDiscoveryMeta(tc *v1alpha1.TidbCluster, nameFunc func(string) string) (metav1.ObjectMeta, label.Label) {
Expand Down
6 changes: 5 additions & 1 deletion pkg/monitor/monitor/monitor_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ func (mm *MonitorManager) syncTidbMonitorDeployment(monitor *v1alpha1.TidbMonito
return err
}

deployment := getMonitorDeployment(sa, cm, secret, monitor, tc)
deployment, err := getMonitorDeployment(sa, cm, secret, monitor, tc)
if err != nil {
klog.Errorf("tm[%s/%s]'s deployment failed to generate,err: %v", monitor.Namespace, monitor.Name, err)
return err
}
_, err = mm.typedControl.CreateOrUpdateDeployment(monitor, deployment)
if err != nil {
klog.Errorf("tm[%s/%s]'s deployment failed to sync,err: %v", monitor.Namespace, monitor.Name, err)
Expand Down
13 changes: 11 additions & 2 deletions pkg/monitor/monitor/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package monitor

import (
"encoding/json"
"fmt"
"strconv"

Expand Down Expand Up @@ -206,7 +207,7 @@ func getMonitorRoleBinding(sa *core.ServiceAccount, role *rbac.Role, monitor *v1
}
}

func getMonitorDeployment(sa *core.ServiceAccount, config *core.ConfigMap, secret *core.Secret, monitor *v1alpha1.TidbMonitor, tc *v1alpha1.TidbCluster) *apps.Deployment {
func getMonitorDeployment(sa *core.ServiceAccount, config *core.ConfigMap, secret *core.Secret, monitor *v1alpha1.TidbMonitor, tc *v1alpha1.TidbCluster) (*apps.Deployment, error) {
deployment := getMonitorDeploymentSkeleton(sa, monitor)
initContainer := getMonitorInitContainer(monitor, tc)
deployment.Spec.Template.Spec.InitContainers = append(deployment.Spec.Template.Spec.InitContainers, initContainer)
Expand All @@ -219,7 +220,15 @@ func getMonitorDeployment(sa *core.ServiceAccount, config *core.ConfigMap, secre
}
volumes := getMonitorVolumes(config, monitor, tc)
deployment.Spec.Template.Spec.Volumes = volumes
return deployment
b, err := json.Marshal(deployment.Spec.Template.Spec)
if err != nil {
return nil, err
}
if deployment.Annotations == nil {
deployment.Annotations = map[string]string{}
}
deployment.Annotations[controller.LastAppliedPodTemplate] = string(b)
return deployment, nil
}

func getMonitorDeploymentSkeleton(sa *core.ServiceAccount, monitor *v1alpha1.TidbMonitor) *apps.Deployment {
Expand Down

0 comments on commit 4a495b9

Please sign in to comment.