-
Notifications
You must be signed in to change notification settings - Fork 25
CSI-2625 create driver ci #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 7 commits
1ac05dc
6aff2f7
1fe56d8
572dddc
88672c3
0eb3674
1e6d6be
34f9715
057884f
683a5a2
90add39
364b42b
782645f
e6a4b96
1ea7d40
605d016
ed661c5
12050f8
c2fba0b
d640b79
31438ff
6d906c0
31d711b
0827d76
2ba9b3a
36d7a6e
e3aa5d6
f854cb0
b4300ee
7e6c394
684aecc
1c9a227
0477825
3496a4a
a04194b
90f3e06
fb1f865
a4b84c1
8ff6f1c
3b3c0b9
fadd666
cda5430
43aabe1
9bc70b5
a05503f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,200 @@ | ||||||
name: CSI IBM Driver CI | ||||||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
on: | ||||||
push: | ||||||
branches: | ||||||
- develop | ||||||
- master | ||||||
pull_request: | ||||||
branches: | ||||||
- develop | ||||||
- master | ||||||
jobs: | ||||||
prepare_env: | ||||||
name: "prepare env" | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- name: Checkout code | ||||||
uses: actions/checkout@v2 | ||||||
- name: Set up Python | ||||||
uses: actions/setup-python@v2 | ||||||
with: | ||||||
python-version: '3.x' | ||||||
- name: Setup dependencies | ||||||
run: | | ||||||
scripts/ci/setup_ci_dependencies.sh | ||||||
- uses: actions/cache@v2 | ||||||
with: | ||||||
path: ${{ env.pythonLocation }} | ||||||
key: ${{ env.pythonLocation }}-${{ hashFiles('dev-requirements.txt') }} | ||||||
- name: Save dependencies files | ||||||
uses: actions/upload-artifact@v2 | ||||||
with: | ||||||
name: ci-dependencies | ||||||
path: | | ||||||
/home/runner/.bash_profile | ||||||
retention-days: 1 | ||||||
- uses: FranzDiebold/github-env-vars-action@v2 | ||||||
CSI-controller-static_code_analysis: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and align all with the stage names accordingly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me clarify - e.g. I personally prefer whitespace over btw, I know the example yamls dir is currently under a "deploy" dir, but "k8s yamls validation" is not "CSI deployment", it's more "CSI configuration" (the true deployment dir is on the operator side), but I think "k8s yamls validation" is enough There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the case of the first letter is still not unified in the job "keys". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I aligned all the keys now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still see this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I got it right now, I think I was confused from all the comments There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps I wasn't specific enough (though I don't think I should link to every relevant line): |
||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- name: Checkout | ||||||
uses: actions/checkout@v2 | ||||||
- name: CSI-controller- static code analysis | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(same for unit testing, etc...) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would also mean: |
||||||
run: | | ||||||
./scripts/run_static_code_analysis.sh | ||||||
Unit_testing_coverage: | ||||||
runs-on: ubuntu-latest | ||||||
name: "Unit testing + coverage ${{ matrix.csiblock-component }}" | ||||||
strategy: | ||||||
matrix: | ||||||
include: | ||||||
- csiblock-component: controller | ||||||
command-to-run: "./scripts/run_unitests.sh" | ||||||
- csiblock-component: node | ||||||
command-to-run: "make test-xunit-in-container" | ||||||
steps: | ||||||
- name: Checkout | ||||||
uses: actions/checkout@v2 | ||||||
- name: CSI-${{ matrix.csiblock-component }}- Unit testing + coverage | ||||||
run: | | ||||||
mkdir -p build/reports && chmod 777 build/reports | ||||||
$command_to_run `pwd`/build/reports | ||||||
env: | ||||||
command_to_run: ${{ matrix.command-to-run }} | ||||||
|
||||||
CSI-deployment-k8s_yamls_validation: | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- name: Checkout | ||||||
uses: actions/checkout@v2 | ||||||
- name: CSI-deployment- k8s yamls validation | ||||||
run: | | ||||||
./scripts/run_yamlcheck.sh | ||||||
CSI-Build-and-push-images: | ||||||
runs-on: ubuntu-latest | ||||||
needs: | ||||||
- CSI-controller-static_code_analysis | ||||||
- Unit_testing_coverage | ||||||
- CSI-deployment-k8s_yamls_validation | ||||||
strategy: | ||||||
matrix: | ||||||
image_type: ['node', 'controller'] | ||||||
steps: | ||||||
- name: Checkout | ||||||
uses: actions/checkout@v2 | ||||||
- name: Set up QEMU | ||||||
uses: docker/setup-qemu-action@v1 | ||||||
- name: Set up Docker Buildx | ||||||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
id: buildx | ||||||
uses: docker/[email protected] | ||||||
- uses: FranzDiebold/github-env-vars-action@v2 | ||||||
- name: Login to DockerHub | ||||||
uses: docker/login-action@v1 | ||||||
with: | ||||||
username: 'csiblock1' | ||||||
password: '${{ secrets.CSIBLOCK_DOCKERHUB_PASSWORD }}' | ||||||
- name: Cache Docker layers | ||||||
uses: actions/cache@v2 | ||||||
with: | ||||||
path: /tmp/.buildx-${{ matrix.image_type }} | ||||||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||||||
restore-keys: | | ||||||
${{ runner.os }}-buildx- | ||||||
- name: Create github branch parameter | ||||||
id: tested_github_branch | ||||||
run: | | ||||||
docker_image_branch_tag=`echo $CI_ACTION_REF_NAME| sed 's|/|.|g'` | ||||||
echo "::set-output name=docker_image_branch_tag::${docker_image_branch_tag}" | ||||||
- name: Build and push ${{ matrix.image_type }} | ||||||
uses: docker/build-push-action@v2 | ||||||
with: | ||||||
context: . | ||||||
platforms: linux/amd64,linux/ppc64le,linux/s390x | ||||||
push: true | ||||||
tags: | | ||||||
csiblock1/ibm-block-csi-${{ matrix.image_type }}:${{ steps.tested_github_branch.outputs.docker_image_branch_tag }}_${{ github.run_number }} | ||||||
csiblock1/ibm-block-csi-${{ matrix.image_type }}:${{ steps.tested_github_branch.outputs.docker_image_branch_tag }} | ||||||
csiblock1/ibm-block-csi-${{ matrix.image_type }}:latest | ||||||
file: Dockerfile-csi-${{ matrix.image_type }} | ||||||
cache-from: type=local,src=/tmp/.buildx-${{ matrix.image_type }} | ||||||
cache-to: type=local,dest=/tmp/.buildx-new-${{ matrix.image_type }} | ||||||
# Temp fix | ||||||
# https://github.com/docker/build-push-action/issues/252 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you check if this is still needed? |
||||||
# https://github.com/moby/buildkit/issues/1896 | ||||||
zingero marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
- name: Move cache | ||||||
run: | | ||||||
[[ -G /tmp/.buildx-${{ matrix.image_type }} ]] && rm -rf /tmp/.buildx-${{ matrix.image_type }} | ||||||
mv /tmp/.buildx-new-${{ matrix.image_type }} /tmp/.buildx-${{ matrix.image_type }} | ||||||
outputs: | ||||||
driver_images_tag: "${{ steps.tested_github_branch.outputs.docker_image_branch_tag }}_${{ github.run_number }}" | ||||||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
create-cluster: | ||||||
runs-on: ubuntu-latest | ||||||
needs: CSI-Build-and-push-images | ||||||
env: | ||||||
csiblock_dockerhub_password: ${{ secrets.CSIBLOCK_DOCKERHUB_PASSWORD }} | ||||||
controller_repository_for_test: csiblock1/ibm-block-csi-controller | ||||||
node_repository_for_test: csiblock1/ibm-block-csi-node | ||||||
operator_image_repository_for_test: csiblock1/ibm-block-csi-operator | ||||||
timeout-minutes: 30 | ||||||
steps: | ||||||
- name: Checkout | ||||||
uses: actions/checkout@v2 | ||||||
with: | ||||||
path: driver | ||||||
- uses: FranzDiebold/github-env-vars-action@v2 | ||||||
- name: Retrieve ci dependencies | ||||||
uses: actions/download-artifact@v2 | ||||||
with: | ||||||
name: ci-dependencies | ||||||
path: /home/runner | ||||||
- name: Set up Python | ||||||
uses: actions/setup-python@v2 | ||||||
with: | ||||||
python-version: '3.x' | ||||||
- uses: actions/cache@v2 | ||||||
with: | ||||||
path: ${{ env.pythonLocation }} | ||||||
key: ${{ env.pythonLocation }}-${{ hashFiles('dev-requirements.txt') }} | ||||||
- name: Get the operator github branch | ||||||
zingero marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
id: operator_github_branch | ||||||
run: | | ||||||
driver/scripts/ci/get_operator_github_branch.sh | ||||||
env: | ||||||
github_token: ${{ secrets.CSIBLOCK_GITHUB_TOKEN }} | ||||||
- name: Create k8s Kind Cluster | ||||||
uses: helm/[email protected] | ||||||
with: | ||||||
version: v0.11.1 | ||||||
- name: Wait for k8s cluster to be ready | ||||||
run: | | ||||||
driver/scripts/ci/wait_for_k8s_ready.sh | ||||||
- name: Checkout | ||||||
uses: actions/checkout@v2 | ||||||
with: | ||||||
repository: IBM/ibm-block-csi-operator | ||||||
ref: "${{ steps.operator_github_branch.outputs.operator_branch }}" | ||||||
path: operator | ||||||
- name: Deploy ibm block csi driver | ||||||
run: | | ||||||
driver/scripts/ci/deploy_driver.sh | ||||||
env: | ||||||
driver_images_tag: "${{ needs.CSI-Build-and-push-images.outputs.driver_images_tag }}" | ||||||
operator_image_tag_for_test: "${{ steps.operator_github_branch.outputs.docker_image_branch_tag }}" | ||||||
operator_file: "operator/deploy/installer/generated/ibm-block-csi-operator.yaml" | ||||||
cr_file: "operator/deploy/crds/csi.ibm.com_v1_ibmblockcsi_cr.yaml" | ||||||
- name: Wait for csi ibm block driver to be ready | ||||||
run: | | ||||||
driver/scripts/ci/wait_for_driver_to_be_ready.sh | ||||||
- name: Save driver pods logs | ||||||
if: always() | ||||||
run: | | ||||||
driver/scripts/ci/save_driver_pods_logs.sh | ||||||
- name: Upload driver pods logs | ||||||
if: always() | ||||||
uses: actions/upload-artifact@v2 | ||||||
with: | ||||||
name: Driver logs | ||||||
path: | | ||||||
/tmp/driver_*.txt | ||||||
retention-days: 7 | ||||||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash -xel | ||
set +o pipefail | ||
|
||
if [ "$operator_image_tag_for_test" == "develop" ]; then | ||
operator_image_tag_for_test=latest | ||
fi | ||
operator_image_for_test=$operator_image_repository_for_test:$operator_image_tag_for_test | ||
|
||
kind_node_name=`docker ps --format "{{.Names}}"` | ||
docker exec -i $kind_node_name apt-get update | ||
docker exec -i $kind_node_name apt -y install open-iscsi | ||
|
||
cd $(dirname $cr_file) | ||
yq eval ".spec.controller.repository |= env(controller_repository_for_test)" $(basename $cr_file) -i | ||
yq eval ".spec.controller.tag |= env(driver_images_tag)" $(basename $cr_file) -i | ||
yq eval ".spec.node.repository |= env(node_repository_for_test)" $(basename $cr_file) -i | ||
yq eval ".spec.node.tag |= env(driver_images_tag)" $(basename $cr_file) -i | ||
cd - | ||
|
||
cd $(dirname $operator_file) | ||
operator_image_in_branch=`yq eval '(.spec.template.spec.containers[0].image | select(. == "*ibmcom*"))' $(basename $operator_file)` | ||
sed -i "s+$operator_image_in_branch+$operator_image_for_test+g" $(basename $operator_file) | ||
cd - | ||
|
||
cat $operator_file | grep image: | ||
cat $cr_file | grep repository: | ||
cat $cr_file | grep tag: | ||
|
||
kubectl apply -f $operator_file | ||
kubectl apply -f $cr_file |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash -xe | ||
set +o pipefail | ||
|
||
does_operator_branch_has_image=false | ||
operator_branch=develop | ||
DOCKER_HUB_USERNAME=csiblock1 | ||
DOCKER_HUB_PASSWORD=$csiblock_dockerhub_password | ||
wanted_image_tag=`echo $CI_ACTION_REF_NAME | sed 's|/|.|g'` | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
export image_tags=`docker-hub tags --orgname csiblock1 --reponame ibm-block-csi-operator --all-pages | grep $wanted_image_tag | awk '{print$2}'` | ||
|
||
for tag in $image_tags | ||
do | ||
if [[ "$tag" == "$wanted_image_tag" ]]; then | ||
does_operator_branch_has_image=true | ||
fi | ||
done | ||
|
||
if [ $does_operator_branch_has_image == "true" ]; then | ||
operator_branches=`curl -H "Authorization: token $github_token" https://api.github.com/repos/IBM/ibm-block-csi-operator/branches | jq -c '.[]' | jq -r .name` | ||
for branch_name in $operator_branches | ||
do | ||
if [ "$branch_name" == "$CI_ACTION_REF_NAME" ]; then | ||
operator_branch=$CI_ACTION_REF_NAME | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fi | ||
|
||
done | ||
fi | ||
|
||
docker_image_branch_tag=`echo $operator_branch| sed 's|/|.|g'` | ||
echo "::set-output name=docker_image_branch_tag::${docker_image_branch_tag}" | ||
echo "::set-output name=operator_branch::${operator_branch}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash -x | ||
|
||
kubectl logs $(kubectl get pod -l csi | grep controller | awk '{print$1}') -c ibm-block-csi-controller > /tmp/driver_$(kubectl get pod -l csi | grep controller | awk '{print$1}')_logs.txt | ||
kubectl logs $(kubectl get pod -l csi | grep node | awk '{print$1}') -c ibm-block-csi-node > /tmp/driver_$(kubectl get pod -l csi | grep node | awk '{print$1}')_logs.txt | ||
kubectl logs $(kubectl get pod -l csi | grep operator | awk '{print$1}') > /tmp/driver_$(kubectl get pod -l csi | grep operator | awk '{print$1}')_logs.txt | ||
|
||
kubectl describe pod $(kubectl get pod -l csi | grep controller | awk '{print$1}') > /tmp/driver_$(kubectl get pod -l csi | grep controller | awk '{print$1}')_events.txt | ||
kubectl describe pod $(kubectl get pod -l csi | grep node | awk '{print$1}') > /tmp/driver_$(kubectl get pod -l csi | grep node | awk '{print$1}')_events.txt | ||
kubectl describe pod $(kubectl get pod -l csi | grep operator | awk '{print$1}') > /tmp/driver_$(kubectl get pod -l csi | grep operator | awk '{print$1}')_events.txt | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash -xe | ||
set +o pipefail | ||
|
||
python -m pip install --upgrade pip docker-hub==2.2.0 | ||
echo yq > dev-requirements.txt | ||
|
||
echo $'yq() {\n docker run --rm -e operator_image_for_test=$operator_image_for_test -e controller_repository_for_test=$controller_repository_for_test -e node_repository_for_test=$node_repository_for_test -e driver_images_tag=$driver_images_tag -i -v "${PWD}":/workdir mikefarah/yq:4 "$@"\n}' >> /home/runner/.bash_profile | ||
zingero marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash -xe | ||
set +o pipefail | ||
|
||
driver_is_ready=false | ||
amount_of_seconds_that_driver_pods_are_running=0 | ||
amount_of_seconds_that_driver_pods_should_be_running=10 | ||
while [ "$(kubectl get pod -A -l csi | grep controller | wc -l)" -eq 0 ]; do | ||
echo "The controller is not deployed" | ||
sleep 1 | ||
done | ||
while [ $driver_is_ready == "false" ]; do | ||
if [ "$(kubectl get pod -A -l csi | grep -iv running | grep -iv name | wc -l)" -eq 0 ]; then | ||
((amount_of_seconds_that_driver_pods_are_running=amount_of_seconds_that_driver_pods_are_running+1)) | ||
if [ $amount_of_seconds_that_driver_pods_are_running -eq $amount_of_seconds_that_driver_pods_should_be_running ]; then | ||
driver_is_ready=true | ||
fi | ||
else | ||
amount_of_seconds_that_driver_pods_are_running=0 | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fi | ||
kubectl get pod -A -l csi | ||
sleep 1 | ||
done | ||
echo Driver is running | ||
kubectl get pod -A -l csi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash -xe | ||
set +o pipefail | ||
|
||
echo "Wait for all the pods to be in running state" | ||
while [ "$(kubectl get pod -A | grep 0/ | grep -iv name | wc -l)" -gt 0 ]; do | ||
echo Some pods did not start thier containers | ||
kubectl get pod -A | grep 0/ | grep -iv name | ||
sleep 5 | ||
done | ||
while [ "$(kubectl get pod -A | grep -iv running | grep -iv name | wc -l)" -gt 0 ]; do | ||
echo Some pods are still not in running state | ||
kubectl get pod -A | grep -iv running | grep -iv name | ||
sleep 5 | ||
done | ||
echo Cluster is ready | ||
kubectl get pod -A |
Uh oh!
There was an error while loading. Please reload this page.