From 5ba71fd84a3422dcf00f36fa0a62a9acdf4dc93a Mon Sep 17 00:00:00 2001 From: Prateek Pandey Date: Thu, 18 Jul 2019 21:54:44 +0530 Subject: [PATCH] refact(cvc):remove configclass reference from CVC and add validations (#25) Signed-off-by: prateekpandey14 --- .travis.yml | 2 ++ Makefile | 2 +- ci/ci-test.sh | 50 ++++++++++++++++++++++++++---- pkg/service/v1alpha1/controller.go | 14 ++++++--- pkg/utils/v1alpha1/maya.go | 4 +-- 5 files changed, 58 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0cde0930a..60cc427c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,8 @@ script: - JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done - kubectl get deployment - ./buildscripts/travis-build.sh + - sudo apt-get install -y open-iscsi + - sudo service iscsid start - ./ci/ci-test.sh after_success: - make deploy-images diff --git a/Makefile b/Makefile index 9b7b5ca0c..a4a2a4181 100644 --- a/Makefile +++ b/Makefile @@ -145,7 +145,7 @@ csi-driver-image: csi-driver @echo "+ Generating ${CSI_DRIVER} image" @echo "--------------------------------" @cp bin/${CSI_DRIVER}/${CSI_DRIVER} buildscripts/${CSI_DRIVER}/ - cd buildscripts/${CSI_DRIVER} && sudo docker build -t openebs/${CSI_DRIVER}:${IMAGE_TAG} --build-arg BUILD_DATE=${BUILD_DATE} . + cd buildscripts/${CSI_DRIVER} && sudo docker build -t openebs/${CSI_DRIVER}:${IMAGE_TAG} --build-arg BUILD_DATE=${BUILD_DATE} . && docker tag openebs/${CSI_DRIVER}:${IMAGE_TAG} quay.io/openebs/${CSI_DRIVER}:${IMAGE_TAG} @rm buildscripts/${CSI_DRIVER}/${CSI_DRIVER} # Push images diff --git a/ci/ci-test.sh b/ci/ci-test.sh index 1d0691ea1..2e58ae79e 100755 --- a/ci/ci-test.sh +++ b/ci/ci-test.sh @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -#!/bin/bash -set -e +#!/usr/bin/env bash -OPENEBS_OPERATOR=https://openebs.github.io/charts/openebs-operator-0.9.0.yaml +OPENEBS_OPERATOR=https://raw.githubusercontent.com/openebs/openebs/master/k8s/openebs-operator.yaml CSI_OPERATOR=https://raw.githubusercontent.com/openebs/csi/master/deploy/csi-operator.yaml SRC_REPO="https://github.com/openebs/maya.git" @@ -31,10 +30,49 @@ mkdir -p $DST_PATH git clone $SRC_REPO $DST_PATH/maya cd $DST_PATH/maya +function dumpCSINodeLogs() { + LC=$1 + CSINodePOD=$(kubectl get pods -l app=openebs-csi-node -o jsonpath='{.items[0].metadata.name}' -n kube-system) + kubectl logs --tail=${LC} $CSINodePOD -n kube-system -c openebs-csi-plugin + printf "\n\n" +} + +function dumpCSIControllerLogs() { + LC=$1 + CSIControllerPOD=$(kubectl get pods -l app=openebs-csi-controller -o jsonpath='{.items[0].metadata.name}' -n kube-system) + kubectl logs --tail=${LC} $CSIControllerPOD -n kube-system -c openebs-csi-plugin + printf "\n\n" +} + +function dumpMayaAPIServerLogs() { + LC=$1 + MAPIPOD=$(kubectl get pods -o jsonpath='{.items[?(@.spec.containers[0].name=="maya-apiserver")].metadata.name}' -n openebs) + kubectl logs --tail=${LC} $MAPIPOD -n openebs + printf "\n\n" +} + # Run BDD tests for volume provisioning via CSI cd $DST_PATH/maya/tests/csi/cstor/volume ginkgo -v -- -kubeconfig="$HOME/.kube/config" --cstor-replicas=1 --cstor-maxpools=1 -if [[ $? != 0 ]]; then - echo "BDD tests for volume provisioning via CSI failed" - exit 1 + +if [ $? -ne 0 ]; then +echo "******************** CSI Controller logs***************************** " +dumpCSIControllerLogs 1000 + +echo "********************* CSI Node logs *********************************" +dumpCSINodeLogs 1000 + +echo "******************CSI Maya-apiserver logs ********************" +dumpMayaAPIServerLogs 1000 + +echo "get all the pods" +kubectl get pods --all-namespaces + +echo "get pvc and pv details" +kubectl get pvc,pv --all-namespaces + +echo "get cvc details" +kubectl get cvc -n openebs -oyaml + +exit 1 fi diff --git a/pkg/service/v1alpha1/controller.go b/pkg/service/v1alpha1/controller.go index efb29f99b..865674b9b 100644 --- a/pkg/service/v1alpha1/controller.go +++ b/pkg/service/v1alpha1/controller.go @@ -69,7 +69,6 @@ func (cs *controller) CreateVolume( volName := req.GetName() size := req.GetCapacityRange().RequiredBytes - configClass := req.GetParameters()["configClass"] rCount := req.GetParameters()["replicaCount"] spcName := req.GetParameters()["storagePoolClaim"] @@ -79,7 +78,7 @@ func (cs *controller) CreateVolume( goto createVolumeResponse } - err = utils.ProvisionVolume(size, volName, rCount, configClass, spcName) + err = utils.ProvisionVolume(size, volName, rCount, spcName) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -356,10 +355,17 @@ func (cs *controller) validateVolumeCreateReq(req *csi.CreateVolumeRequest) erro ) } - if req.GetParameters()["configClass"] == "" { + if req.GetParameters()["storagePoolClaim"] == "" { return status.Error( codes.InvalidArgument, - "failed to handle create volume request: missing storage class parameter configClass", + "failed to handle create volume request: missing storage class parameter storagePoolClaim", + ) + } + + if req.GetParameters()["replicaCount"] == "" { + return status.Error( + codes.InvalidArgument, + "failed to handle create volume request: missing storage class parameter replicaCount", ) } diff --git a/pkg/utils/v1alpha1/maya.go b/pkg/utils/v1alpha1/maya.go index 4f670d135..b7a937612 100644 --- a/pkg/utils/v1alpha1/maya.go +++ b/pkg/utils/v1alpha1/maya.go @@ -41,13 +41,11 @@ func ProvisionVolume( size int64, volName, replicaCount, - configclass, spcName string, ) error { annotations := map[string]string{ - OpenebsConfigClass: configclass, - OpenebsVolumeID: volName, + OpenebsVolumeID: volName, } labels := map[string]string{