Skip to content

Commit

Permalink
refact(cvc):remove configclass reference from CVC and add validations (
Browse files Browse the repository at this point in the history
…#25)

Signed-off-by: prateekpandey14 <[email protected]>
  • Loading branch information
prateekpandey14 authored and vishnuitta committed Jul 18, 2019
1 parent 71d9f26 commit 5ba71fd
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 44 additions & 6 deletions ci/ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
14 changes: 10 additions & 4 deletions pkg/service/v1alpha1/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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())
}
Expand Down Expand Up @@ -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",
)
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/utils/v1alpha1/maya.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 5ba71fd

Please sign in to comment.