From e7f3144e5126e3796c6c9f82c6bad0347125ec59 Mon Sep 17 00:00:00 2001 From: onlymellb Date: Mon, 25 Nov 2019 11:34:19 +0800 Subject: [PATCH] fix e2e nil point dereference (#1221) * fix e2e nil point dereference * get pv more accurately * fix the judgment condition of ci script --- ci/pingcap_tidb_operator_build_kind.groovy | 4 +-- tests/actions.go | 31 +++++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ci/pingcap_tidb_operator_build_kind.groovy b/ci/pingcap_tidb_operator_build_kind.groovy index 9e41436b8c..1fc6b6efb3 100644 --- a/ci/pingcap_tidb_operator_build_kind.groovy +++ b/ci/pingcap_tidb_operator_build_kind.groovy @@ -140,7 +140,7 @@ def call(BUILD_BRANCH, CREDENTIALS_ID, CODECOV_CREDENTIALS_ID) { } } - if ( BUILD_BRANCH !=~ /[a-z0-9]{40}/) { + if ( !(BUILD_BRANCH ==~ /[a-z0-9]{40}/) ) { stage('upload tidb-operator binary and charts'){ //upload binary and charts sh """ @@ -177,7 +177,7 @@ def call(BUILD_BRANCH, CREDENTIALS_ID, CODECOV_CREDENTIALS_ID) { return } - if ( BUILD_BRANCH !=~ /[a-z0-9]{40}/ ){ + if ( !(BUILD_BRANCH ==~ /[a-z0-9]{40}/) ){ slackmsg = "${slackmsg}" + "\n" + "Binary Download URL:" + "\n" + "${UCLOUD_OSS_URL}/builds/pingcap/operator/${GITHASH}/centos7/tidb-operator.tar.gz" diff --git a/tests/actions.go b/tests/actions.go index a00b160d2e..533b0b914f 100644 --- a/tests/actions.go +++ b/tests/actions.go @@ -1320,7 +1320,15 @@ func (oa *operatorActions) pdMembersReadyFn(tc *v1alpha1.TidbCluster) (bool, err ns, pdSetName, pdSet.Status.ReadyReplicas, pdSet.Status.Replicas) return false, nil } - if c, ok := getMemberContainer(oa.kubeCli, ns, pdSetName); !ok || tc.Spec.PD.Image != c.Image { + + c, found := getMemberContainer(oa.kubeCli, ns, pdSetName) + if !found { + glog.Infof("statefulset: %s/%s not found containers[name=pd] or pod %s-0", + ns, pdSetName, pdSetName) + return false, nil + } + + if tc.Spec.PD.Image != c.Image { glog.Infof("statefulset: %s/%s .spec.template.spec.containers[name=pd].image(%s) != %s", ns, pdSetName, c.Image, tc.Spec.PD.Image) return false, nil @@ -1385,7 +1393,15 @@ func (oa *operatorActions) tikvMembersReadyFn(tc *v1alpha1.TidbCluster) (bool, e ns, tikvSetName, tikvSet.Status.ReadyReplicas, tikvSet.Status.Replicas) return false, nil } - if c, ok := getMemberContainer(oa.kubeCli, ns, tikvSetName); !ok || tc.Spec.TiKV.Image != c.Image { + + c, found := getMemberContainer(oa.kubeCli, ns, tikvSetName) + if !found { + glog.Infof("statefulset: %s/%s not found containers[name=tikv] or pod %s-0", + ns, tikvSetName, tikvSetName) + return false, nil + } + + if tc.Spec.TiKV.Image != c.Image { glog.Infof("statefulset: %s/%s .spec.template.spec.containers[name=tikv].image(%s) != %s", ns, tikvSetName, c.Image, tc.Spec.TiKV.Image) return false, nil @@ -1445,7 +1461,14 @@ func (oa *operatorActions) tidbMembersReadyFn(tc *v1alpha1.TidbCluster) (bool, e return false, nil } - if c, ok := getMemberContainer(oa.kubeCli, ns, tidbSetName); !ok || tc.Spec.TiDB.Image != c.Image { + c, found := getMemberContainer(oa.kubeCli, ns, tidbSetName) + if !found { + glog.Infof("statefulset: %s/%s not found containers[name=tidb] or pod %s-0", + ns, tidbSetName, tidbSetName) + return false, nil + } + + if tc.Spec.TiDB.Image != c.Image { glog.Infof("statefulset: %s/%s .spec.template.spec.containers[name=tidb].image(%s) != %s", ns, tidbSetName, c.Image, tc.Spec.TiDB.Image) return false, nil @@ -1821,7 +1844,7 @@ func (oa *operatorActions) getComponentPVList(tc *v1alpha1.TidbCluster, componen listOptions := metav1.ListOptions{ LabelSelector: labels.SelectorFromSet( - label.New().Instance(tcName).Component(component).Labels()).String(), + label.New().Instance(tcName).Component(component).Namespace(ns).Labels()).String(), } pvList, err := oa.kubeCli.CoreV1().PersistentVolumes().List(listOptions)