-
Notifications
You must be signed in to change notification settings - Fork 16
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
CSI-2625 add CSI IBM Driver operator CI #189
Draft
matancarmeli7
wants to merge
72
commits into
develop
Choose a base branch
from
task/CSI-2625_add_another_stage_before_the_merge
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
782cf90
add CSI IBM Driver operator CI
matancarmeli7 ccd312e
change wait for driver script
matancarmeli7 3881a4e
change does_the_docker_image_has_tag
matancarmeli7 11658a1
add docker-hub command
matancarmeli7 b32d494
not fail on getting the image tags
matancarmeli7 0cf1015
add break in does_the_docker_image_has_tag
matancarmeli7 b6dd4ec
add permissions to edit cr files
matancarmeli7 205dfcc
Merge branch 'develop' into task/CSI-2625_add_another_stage_before_th…
matancarmeli7 9546870
change olm verification to olm validation
matancarmeli7 a420bee
remove sudo from changing the cr files
matancarmeli7 359459b
answer some code review comments
matancarmeli7 564df3e
change the image tag
matancarmeli7 8dad6ff
change the directory that it will check the image_version
matancarmeli7 80b68d9
change the image_version check to certified dir
matancarmeli7 69cd690
change saving driver logs script
matancarmeli7 bba693e
use run_action_on_pod function
matancarmeli7 5ded798
fix save logs
matancarmeli7 0485341
cahnge the edit of the cr file
matancarmeli7 d30934d
fix some problems
matancarmeli7 0f5f33c
create github_actions firectory
matancarmeli7 4081c49
fix syntax errors in wait for k8s cluster
matancarmeli7 e6d3c1d
fix is_pod_ready function
matancarmeli7 5e00875
fix some syntax errors in deploy driver
matancarmeli7 f7b7c6b
change the node ripository yaml path
matancarmeli7 ed5a5a4
remove cluster setup from driver repository
matancarmeli7 4314f6a
add build_number env variable
matancarmeli7 fd7fa44
fix setup ci dependencies
matancarmeli7 2306ea5
change are_pods_ready in wait for k8s
matancarmeli7 0f39210
add edit_operator_yaml_image function
matancarmeli7 949bdcf
change get_image_tags_from_branch script name
matancarmeli7 4df43a6
help the deer readers to read wait for driver
matancarmeli7 9c6da84
add is_wanted_image_in_pod
matancarmeli7 df5f840
add driver_images_tag env to wait for driver
matancarmeli7 ccdd46d
fix wait for driver
matancarmeli7 a0e8eb4
fix function is_expected_image_in_pod
matancarmeli7 fcffa32
answer some code review comments
matancarmeli7 3cb03f3
remove variables from yq command
matancarmeli7 16e7869
change commit sha parameter
matancarmeli7 5e4ecaa
fix operator image branch for test parameter
matancarmeli7 a38ca6d
change CSI_Build_and_push_images variable
matancarmeli7 d6f412f
fix the assert for images function
matancarmeli7 38f2573
change the image_in_pod command
matancarmeli7 c97bade
Merge branch 'develop' into task/CSI-2625_add_another_stage_before_th…
matancarmeli7 d2a3d02
change driver logs artifactes upload
matancarmeli7 5f36254
Merge branch 'develop' into task/CSI-2625_add_another_stage_before_th…
matancarmeli7 4963b9b
add get_pod_images_by_type function
matancarmeli7 0b6be16
code review comments
matancarmeli7 8bc6d03
fix spelling problem
matancarmeli7 4d9db61
add parameter to wiat for driver
matancarmeli7 32eaf69
change get driver branch script name
matancarmeli7 55f17ea
fix save logs with describe
matancarmeli7 46ecb71
change github_actions/operator directory to driver
matancarmeli7 ea0e064
add action_name parameter to run_action_and_save_output
matancarmeli7 d51d2ac
add csiblock1 secret
matancarmeli7 773eada
add deploy operator
matancarmeli7 55bfc12
move deploy_operator to operator dir
matancarmeli7 512c38c
change deploy_objects path
matancarmeli7 96860e2
use docker manifest to search for tags
matancarmeli7 dd9b171
change deploy_objects to deployment
matancarmeli7 fcf3bda
Merge branch 'develop' into task/CSI-2625_add_another_stage_before_th…
matancarmeli7 98159ca
remove cds
matancarmeli7 914818a
change build_and_push_images stage
matancarmeli7 e480a64
insert specific python version and pip version
matancarmeli7 aba7bb0
add setup_yq.sh
matancarmeli7 ab28403
add pr comments answer
matancarmeli7 3642121
edit get_driver_image script
matancarmeli7 3ee4e46
remove backticks
matancarmeli7 f9c7828
change names of parameters
matancarmeli7 3ff23d6
align setup_ci with driver
matancarmeli7 1ed494f
fix spacing problem
matancarmeli7 8cea7ba
Merge branch 'develop' into task/CSI-2625_add_another_stage_before_th…
matancarmeli7 c0b3acd
test stuff
matancarmeli7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
name: Operator Build | ||
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.9.7' | ||
- uses: FranzDiebold/github-env-vars-action@v2 | ||
- name: Setup dependencies | ||
id: setup_dependencies | ||
run: | | ||
build/ci/github_actions/setup_ci_dependencies.sh | ||
env: | ||
build_number: "${{ github.run_number }}" | ||
- 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 | ||
outputs: | ||
branch_image_tag: "${{ steps.setup_dependencies.outputs.branch_image_tag }}" | ||
operator_specific_tag_for_test: "${{ steps.setup_dependencies.outputs.operator_specific_tag_for_test }}" | ||
|
||
unit_testing: | ||
runs-on: ubuntu-latest | ||
name: "Unit testing" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Run unit tests | ||
run: | | ||
mkdir -p build/_output/reports && chmod 777 build/_output/reports | ||
./build/ci/run_unittests.sh | ||
|
||
run_olm_validation: | ||
runs-on: ubuntu-latest | ||
name: "Run OLM validation" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Run OLM validation | ||
run: | | ||
./build/ci/run_olm_validation.sh | ||
|
||
build_and_push_images: | ||
name: "Build and push images" | ||
runs-on: ubuntu-latest | ||
needs: | ||
- unit_testing | ||
- run_olm_validation | ||
- prepare_env | ||
strategy: | ||
matrix: | ||
image_type: ['operator'] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/[email protected] | ||
- uses: FranzDiebold/github-env-vars-action@v2 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: '${{ secrets.CSIBLOCK_DOCKER_REGISTRY_USERNAME }}' | ||
password: '${{ secrets.CSIBLOCK_DOCKER_REGISTRY_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: Build and push ${{ matrix.image_type }} | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/ppc64le,linux/s390x | ||
push: true | ||
tags: | | ||
${{ secrets.CSIBLOCK_DOCKER_REGISTRY_USERNAME }}/ibm-block-csi-${{ matrix.image_type }}:${{ needs.prepare_env.outputs.operator_specific_tag_for_test }} | ||
${{ secrets.CSIBLOCK_DOCKER_REGISTRY_USERNAME }}/ibm-block-csi-${{ matrix.image_type }}:${{ needs.prepare_env.outputs.branch_image_tag }} | ||
file: build/Dockerfile.${{ 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 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
- 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: | ||
operator_specific_tag_for_test: "${{ needs.prepare_env.outputs.operator_specific_tag_for_test }}" | ||
|
||
deploy_csi_on_cluster: | ||
runs-on: ubuntu-latest | ||
name: "Deploy csi on cluster" | ||
needs: build_and_push_images | ||
env: | ||
csiblock_docker_registry_username: ${{ secrets.CSIBLOCK_DOCKER_REGISTRY_USERNAME }} | ||
controller_repository_for_test: '${{ secrets.CSIBLOCK_DOCKER_REGISTRY_USERNAME }}/ibm-block-csi-controller' | ||
node_repository_for_test: '${{ secrets.CSIBLOCK_DOCKER_REGISTRY_USERNAME }}/ibm-block-csi-node' | ||
operator_image_repository_for_test: '${{ secrets.CSIBLOCK_DOCKER_REGISTRY_USERNAME }}/ibm-block-csi-operator' | ||
operator_specific_tag_for_test: "${{ needs.build_and_push_images.outputs.operator_specific_tag_for_test }}" | ||
operator_image_for_test: "${{ secrets.CSIBLOCK_DOCKER_REGISTRY_USERNAME }}/ibm-block-csi-operator:${{ needs.build_and_push_images.outputs.operator_specific_tag_for_test }}" | ||
operator_yaml: "deploy/installer/generated/ibm-block-csi-operator.yaml" | ||
cr_yaml: "config/samples/csi.ibm.com_v1_ibmblockcsi_cr.yaml" | ||
timeout-minutes: 7 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- 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 driver images tag from branch | ||
id: driver_images_tag_from_branch | ||
run: | | ||
build/ci/github_actions/driver/get_driver_images_tag_from_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: | | ||
build/ci/github_actions/wait_for_k8s_ready.sh | ||
- name: Deploy ibm block csi operator | ||
run: | | ||
build/ci/github_actions/operator/deploy_operator.sh | ||
- name: Deploy ibm block csi driver | ||
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. why is this under |
||
run: | | ||
build/ci/github_actions/driver/deploy_driver.sh | ||
env: | ||
driver_images_tag: "${{ steps.driver_images_tag_from_branch.outputs.branch_image_tag }}" | ||
- name: Save driver pods logs to artifacts | ||
if: always() | ||
run: | | ||
build/ci/github_actions/driver/save_driver_logs_to_artifacts.sh | ||
- name: Upload driver pods logs | ||
if: always() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: driver_logs | ||
path: | | ||
/tmp/*.txt | ||
retention-days: 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash -xe | ||
GIT_BRANCH=$1 | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
IMAGE_VERSION=$2 | ||
BUILD_NUMBER=$3 | ||
COMMIT_HASH=${4:0:7} | ||
branch_image_tag=$(echo $GIT_BRANCH| sed 's|/|.|g') #not sure if docker accept / in the version | ||
specific_tag="${IMAGE_VERSION}_b${BUILD_NUMBER}_${COMMIT_HASH}_${branch_image_tag}" | ||
echo $specific_tag | ||
echo $branch_image_tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/bin/bash -xe | ||
set +o pipefail | ||
|
||
is_driver_ready=false | ||
actual_driver_running_time_in_seconds=0 | ||
minimum_driver_running_time_in_seconds=10 | ||
containers_prefix=ibm-block-csi | ||
declare -a driver_pods_types=( | ||
"controller" | ||
"node" | ||
) | ||
|
||
get_csi_pods (){ | ||
kubectl get pod -A -l csi | ||
} | ||
|
||
get_operator_pod (){ | ||
kubectl get pod -A -l app.kubernetes.io/name=ibm-block-csi-operator | ||
} | ||
|
||
get_image_pod_by_type (){ | ||
pod_type=$1 | ||
component_to_check=$2 | ||
containers_images=$(kubectl get pods $(get_csi_pods | grep $pod_type | awk '{print$2}') -o jsonpath='{range .spec.containers[*]}{.name},{.image} {end}') | ||
for containers_image in $containers_images | ||
do | ||
if [[ "$containers_image" =~ "$component_to_check," ]]; then | ||
echo $containers_image | awk -F , '{print$2}' | ||
break | ||
fi | ||
done | ||
} | ||
|
||
wait_for_pod_to_start (){ | ||
driver_pod_type=$1 | ||
while [ "$(get_csi_pods | grep $driver_pod_type | wc -l)" -eq 0 ]; do | ||
echo "The $driver_pod_type is not deployed" | ||
sleep 1 | ||
done | ||
} | ||
|
||
wait_for_driver_deployment_to_start (){ | ||
for driver_pods_type in "${driver_pods_types[@]}" | ||
do | ||
wait_for_pod_to_start $driver_pods_type | ||
done | ||
} | ||
|
||
wait_for_driver_deployment_to_finish (){ | ||
wait_for_pods_to_finish get_csi_pods | ||
} | ||
|
||
wait_for_operator_deployment_to_finish (){ | ||
wait_for_pods_to_finish get_operator_pod | ||
} | ||
|
||
|
||
wait_for_pods_to_finish (){ | ||
get_pods_command=$1 | ||
while [ $is_driver_ready == "false" ]; do | ||
if [ "$($get_pods_command | grep -iv running | grep -iv name | wc -l)" -eq 0 ]; then | ||
((++actual_driver_running_time_in_seconds)) | ||
if [ $actual_driver_running_time_in_seconds -eq $minimum_driver_running_time_in_seconds ]; then | ||
is_driver_ready=true | ||
fi | ||
else | ||
actual_driver_running_time_in_seconds=0 | ||
fi | ||
get_csi_pods | ||
sleep 1 | ||
done | ||
} | ||
|
||
assert_expected_image_in_pod (){ | ||
pod_type=$1 | ||
expected_pod_image=$2 | ||
component_to_check=$containers_prefix-$pod_type | ||
image_in_pod=$(get_image_pod_by_type $pod_type $component_to_check) | ||
if [[ $image_in_pod != $expected_pod_image ]]; then | ||
echo "$pod_type's image ($image_in_pod) is not the expected image ($expected_pod_image)" | ||
exit 1 | ||
fi | ||
} | ||
|
||
assert_driver_images_in_pods (){ | ||
expected_node_image=$1 | ||
expected_controller_image=$2 | ||
declare -A drivers_components_in_k8s=( | ||
["controller"]="$expected_controller_image" | ||
["node"]="$expected_node_image" | ||
) | ||
for driver_component in ${!drivers_components_in_k8s[@]}; do | ||
driver_component_expected_image=${drivers_components_in_k8s[${driver_component}]} | ||
assert_expected_image_in_pod $driver_component $driver_component_expected_image | ||
done | ||
} | ||
|
||
assert_operator_image_in_pod (){ | ||
operator_image_for_test=$1 | ||
kubectl apply -f $operator_yaml | ||
wait_for_pod_to_start "operator" | ||
assert_expected_image_in_pod "operator" $operator_image_for_test | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash -xel | ||
set +o pipefail | ||
|
||
expected_node_image=$node_repository_for_test:$driver_images_tag | ||
expected_controller_image=$controller_repository_for_test:$driver_images_tag | ||
|
||
install_worker_prerequisites() { | ||
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 | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
edit_cr_images (){ | ||
chmod 547 $cr_yaml | ||
declare -A cr_image_fields=( | ||
[".spec.controller.repository"]="$controller_repository_for_test" | ||
[".spec.controller.tag"]="$driver_images_tag" | ||
[".spec.node.repository"]="$node_repository_for_test" | ||
[".spec.node.tag"]="$driver_images_tag" | ||
) | ||
for image_field in ${!cr_image_fields[@]}; do | ||
cr_image_value=${cr_image_fields[${image_field}]} | ||
yq eval "${image_field} |= \"${cr_image_value}\"" $cr_yaml -i | ||
done | ||
} | ||
|
||
install_worker_prerequisites | ||
edit_cr_images | ||
cat $cr_yaml | grep repository: | ||
cat $cr_yaml | grep tag: | ||
kubectl apply -f $cr_yaml | ||
source build/ci/github_actions/deployment.sh | ||
wait_for_driver_deployment_to_start | ||
assert_driver_images_in_pods $expected_node_image $expected_controller_image | ||
wait_for_driver_deployment_to_finish |
28 changes: 28 additions & 0 deletions
28
build/ci/github_actions/driver/get_driver_images_tag_from_branch.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash -xe | ||
set +o pipefail | ||
|
||
driver_images_tag_from_branch=latest | ||
triggering_branch=$CI_ACTION_REF_NAME | ||
target_image_tags=$(build/ci/get_image_tags_from_branch.sh ${triggering_branch}) | ||
branch_image_tag=$(echo $branch_image_tag | awk '{print$2}') | ||
|
||
is_private_branch_component_image_exists(){ | ||
driver_component=$1 | ||
image_to_check=$csiblock_docker_registry_username/ibm-block-csi-$driver_component:$branch_image_tag | ||
is_image_tag_exists=false | ||
export driver_image_inspect=$(docker manifest inspect $image_to_check &> /dev/null; echo $?) | ||
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. where is |
||
if [ $driver_image_inspect == "0" ]; then | ||
echo true | ||
else | ||
echo false | ||
fi | ||
} | ||
|
||
is_controller_image_tag_exists=$(is_private_branch_component_image_exists controller) | ||
is_node_image_tag_exists=$(is_private_branch_component_image_exists node) | ||
|
||
if [ $is_controller_image_tag_exists == "true" ] && [ $is_node_image_tag_exists == "true " ]; then | ||
driver_images_tag_from_branch=$branch_image_tag | ||
fi | ||
|
||
echo "::set-output name=branch_image_tag::${driver_images_tag_from_branch}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid using the current registry/user name (csiblock) in our variables, since it can always change in the future