-
Notifications
You must be signed in to change notification settings - Fork 3
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
Draft PR for review comments of infraclouds contributions #2
base: infracloud/cassandra-5.0
Are you sure you want to change the base?
Changes from 250 commits
7d2b552
c337a82
96799ad
b90db0a
9e0848e
9d5c38e
6a1cdf6
66b153d
c0b12dc
9f86207
fae1c01
0a5f6af
be11cf6
f4b7897
f5e1ae1
82a1589
f61f449
e1f2333
bb28801
e2cbcbe
108d2b0
24fb78d
ecd22b2
3b5eb23
6ac257f
647c1c1
fcf2a7c
f60f1e8
9e0633f
1556417
7e0d4aa
7f0b241
10d6323
e5565f4
cb2a0b7
2e8d9e1
ae5c475
fdbf9cf
ac463d7
fa3f81a
d7b7e4d
446ca14
58c36f6
431385f
379d325
f1dbace
dcb8726
faac81a
99cc876
61bcad7
82224fe
3051892
499af2f
13ff92f
23bb558
d951683
68df97f
c3830b3
218e983
217c0c3
bbcb26d
08ee5d4
87fb545
1626567
9b10365
006c593
2bff62b
7c48fe3
d486827
245ed22
7b3b36a
2fb9d30
65a8835
bd837ed
886d7eb
c28eb0a
bcba87d
0111793
1e595bc
09283df
c341abc
ec091fe
3d6e2bd
078ca8e
395b9be
f2a2504
ed247ae
059b2c7
fbbbbe4
d6ec04d
0f3e13e
04dde10
62909cb
4ff1bce
0bc5d09
d603628
6e8efd9
c95bd00
5cf5a81
7bd388f
b73b5d0
1adb11c
63694b5
d5db683
e5c45fc
b978768
08189f1
5ca5833
7d35fb3
bafeb6c
b7405df
8e3ffd1
c6ede46
aef256f
3f37ec5
ffd55f6
7e68e82
7de2a55
17a797d
5c0ac21
1753aa3
4148183
ff86cf1
68dceab
7d900e8
291c042
729f8cd
b5adf2f
d822ffe
5cfd2a9
83ba764
1862029
a171ab4
c2d0643
8b2c14d
d08eded
6d9b24e
7cf493c
8b3eb0d
8165818
c2ef545
17e1e36
6e094ac
bc787be
5b0a0d9
0445a3e
9b51d62
77e3f44
420232f
e957b1a
579b71b
0ee7f7a
8801460
704b80f
0c3d81a
b380716
d34b6de
517f17b
9b2d1f1
9b4980c
546cf95
2109074
84e6595
2207f9f
fe31a27
18295df
b4cbd6a
ad4d06a
3f99f2f
d98613e
3d97537
98c3ede
c3a1a32
a59258b
8da7257
1942c8d
d87111d
9112b04
238b21d
46838ce
392c486
837df0b
6ac16ab
385eaec
b0f4083
baa58fd
668755b
dd547a6
dd34428
e8377c8
9549f12
3f33e1f
ebd05b3
159e867
ae5fb90
a2f5fe7
4a42255
b77830b
90937ff
ebb332f
37d4a19
b961834
3c5840e
38eadd2
68ededd
6ab307d
7dfb474
5a88e4f
7060a8d
fb4122b
d37ffb8
7773805
d5c0e25
015c9e5
c9328f9
20eb15a
b2e3ab0
c2974b6
b1faf35
d43af09
2a3d6c2
13b89a5
4f9f82d
45d8aa2
88ad70c
1862109
d6ee789
acaed3e
d84b73b
38c27a1
d714963
3e94a1c
93482ef
a3f7b1a
2bfe665
be5f02e
49c15df
742e923
b696aee
b8f9e3a
9d1765c
3490fdd
80a2e43
fa39706
653e3b1
6d47a1e
c0572a2
7613a52
2b89e51
3710ca5
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/bin/bash -x | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
|
@@ -28,9 +28,10 @@ | |
|
||
# variables, with defaults | ||
[ "x${cassandra_dir}" != "x" ] || cassandra_dir="$(readlink -f $(dirname "$0")/../..)" | ||
#[ "x${cassandra_dir}" != "x" ] || cassandra_dir="$(readlink -f $(dirname "$0"))" | ||
[ "x${build_dir}" != "x" ] || build_dir="${cassandra_dir}/build" | ||
[ -d "${build_dir}" ] || { mkdir -p "${build_dir}" ; } | ||
|
||
echo "$CASSANDRA_DIR from _docker_run" | ||
java_version_default=`grep 'property\s*name="java.default"' ${cassandra_dir}/build.xml |sed -ne 's/.*value="\([^"]*\)".*/\1/p'` | ||
java_version_supported=`grep 'property\s*name="java.supported"' ${cassandra_dir}/build.xml |sed -ne 's/.*value="\([^"]*\)".*/\1/p'` | ||
|
||
|
@@ -111,22 +112,34 @@ container_name="cassandra_${dockerfile/.docker/}_${un_script_name}_jdk${java_ver | |
# change ant's build directory to $DIST_DIR | ||
# set java to java_version | ||
# execute the run_script | ||
# docker_command="export ANT_OPTS=\"-Dbuild.dir=\${DIST_DIR} ${CASSANDRA_DOCKER_ANT_OPTS}\" ; \ | ||
# source \${CASSANDRA_DIR}/.build/docker/_set_java.sh ${java_version} ; \ | ||
# \${CASSANDRA_DIR}/.build/${run_script} ${@:4} ; exit \$? " | ||
|
||
docker_command="export ANT_OPTS=\"-Dbuild.dir=\${DIST_DIR} ${CASSANDRA_DOCKER_ANT_OPTS}\" ; \ | ||
source \${CASSANDRA_DIR}/.build/docker/_set_java.sh ${java_version} ; \ | ||
\${CASSANDRA_DIR}/.build/${run_script} ${@:4} ; exit \$? " | ||
source /home/build/cassandra/cassandra/.build/docker/_set_java.sh ${java_version} ; \ | ||
/home/build/cassandra/.build/${run_script} ${@:4} ; exit \$? " | ||
|
||
# run without the default seccomp profile | ||
# re-use the host's maven repository | ||
# container_id=$(docker run --name ${container_name} -d --security-opt seccomp=unconfined --rm \ | ||
# -v "${cassandra_dir}":/home/build/cassandra -v ~/.m2/repository/:/home/build/.m2/repository/ -v "${build_dir}":/dist \ | ||
# ${docker_volume_opt} \ | ||
# ${image_name} sleep 1h) | ||
container_id=$(docker run --name ${container_name} -d --security-opt seccomp=unconfined --rm \ | ||
-v "${cassandra_dir}":/home/build/cassandra -v ~/.m2/repository/:/home/build/.m2/repository/ -v "${build_dir}":/dist \ | ||
${docker_volume_opt} \ | ||
${image_name} sleep 1h) | ||
|
||
echo "Running container ${container_name} ${container_id}" | ||
|
||
docker exec --user root ${container_name} bash -c "\${CASSANDRA_DIR}/.build/docker/_create_user.sh build $(id -u) $(id -g)" | ||
echo "Running container ${container_name} ${container_id}" | ||
#sleep 3600 | ||
#docker exec --user root ${container_name} bash -c "\${CASSANDRA_DIR}/.build/docker/_create_user.sh build $(id -u) $(id -g)" | ||
docker exec --user root ${container_name} bash -c "/home/build/cassandra/.build/docker/_create_user.sh build $(id -u) $(id -g)" | ||
docker exec --user build ${container_name} bash -c "${docker_command}" | ||
RETURN=$? | ||
current_build_dir=$(basename "${build_dir}") | ||
docker cp ${container_name}:"/home/build/cassandra/build/${current_build_dir}" /home/jenkins/agent/workspace/k8s-e2e/build | ||
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. we can't be doing k8s/jenkins stuff in this script. 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. everything under ( Remember the newline character breaking the mount from working. Also, inside the docker container we need to make sure that both 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. as @Nbarola and @richamishra006 explained today, the problem so far here has been the files can be found in three places.
The jenkins script doesn't have access to the build_dir (only the k8s node and docker container has access). Nishant and Richa are working on how to provide/share/mount the cassandra_dir (which includes all build_dir) from k8s nodes to pods. |
||
|
||
docker stop ${container_name} >/dev/null | ||
popd >/dev/null | ||
|
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. should this file be under 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. Since it is a docker file, we placed it under the docker dir. If required we can move it under .jenkins 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Use Alpine Linux as the base image | ||
FROM jenkins/inbound-agent:3148.v532a_7e715ee3-4 | ||
|
||
USER root | ||
RUN apt-get update | ||
RUN apt-get install xz-utils -y | ||
RUN apt-get install bc -y | ||
RUN apt-get update | ||
RUN apt-get install coreutils -y | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y openjdk-11-jdk openjdk-17-jdk && \ | ||
update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/bin/java && \ | ||
update-alternatives --set javac /usr/lib/jvm/java-11-openjdk-amd64/bin/javac && \ | ||
update-alternatives --install /usr/local/bin/jdk_11 java /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1 && \ | ||
update-alternatives --install /usr/local/bin/jdk_17 java /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1 | ||
|
||
# Install Docker | ||
RUN apt-get install -y gnupg | ||
# Install Docker for Debian Bullseye | ||
RUN apt-get update && \ | ||
apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release && \ | ||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ | ||
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list && \ | ||
apt-get update && \ | ||
apt-get install -y docker-ce docker-ce-cli containerd.io | ||
|
||
#VOLUME /var/run/docker.sock | ||
RUN usermod -aG docker jenkins | ||
#RUN chown -R 1000:1000 /var/run/docker.sock | ||
|
||
USER jenkins | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/bin/bash +x | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
|
@@ -82,7 +82,6 @@ dockerfile="ubuntu2004_test.docker" | |
image_tag="$(md5sum docker/${dockerfile} | cut -d' ' -f1)" | ||
image_name="apache/cassandra-${dockerfile/.docker/}:${image_tag}" | ||
docker_mounts="-v ${cassandra_dir}:/home/cassandra/cassandra -v "${build_dir}":/home/cassandra/cassandra/build -v ${HOME}/.m2/repository:/home/cassandra/.m2/repository" | ||
|
||
# Look for existing docker image, otherwise build | ||
if ! ( [[ "$(docker images -q ${image_name} 2>/dev/null)" != "" ]] ) ; then | ||
# try docker login to increase dockerhub rate limits | ||
|
@@ -202,14 +201,18 @@ docker_command="source \${CASSANDRA_DIR}/.build/docker/_set_java.sh ${java_versi | |
docker_id=$(docker run --name ${container_name} ${docker_flags} ${docker_mounts} ${docker_volume_opt} ${image_name} sleep 4h) | ||
|
||
echo "Running container ${container_name} ${docker_id}" | ||
#sleep 600 | ||
|
||
docker exec --user root ${container_name} bash -c "\${CASSANDRA_DIR}/.build/docker/_create_user.sh cassandra $(id -u) $(id -g)" | tee -a ${logfile} | ||
docker exec --user root ${container_name} update-alternatives --set python /usr/bin/python${python_version} | tee -a ${logfile} | ||
|
||
docker cp /home/jenkins/agent/workspace/k8s-e2e/build ${container_name}:/home/cassandra/cassandra | ||
michaelsembwever marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# capture logs and pid for container | ||
docker exec --user cassandra ${container_name} bash -c "${docker_command}" | tee -a ${logfile} | ||
status=$? | ||
|
||
docker cp ${container_name}:/home/cassandra/cassandra/build/test/output /home/jenkins/agent/workspace/k8s-e2e/build/test | ||
docker exec --user cassandra ${container_name} bash -c "mkdir -p /home/cassandra/cassandra/result/1/${target} && cp -r /home/cassandra/cassandra/build/test/output /home/cassandra/cassandra/result/1/${target}" | ||
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. we can't be doing k8s/jenkins stuff in this script. 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. For tests, the and mounted here: https://github.com/thelastpickle/cassandra/blob/infracloud/cassandra-5.0/.build/docker/run-tests.sh#L84 |
||
if [ "$status" -ne 0 ] ; then | ||
echo "${docker_id} failed (${status}), debug…" | ||
docker inspect ${docker_id} | ||
|
@@ -223,7 +226,7 @@ if [ "$status" -ne 0 ] ; then | |
echo "Failure." | ||
fi | ||
# docker stop in background, ignore errors | ||
( nohup docker stop ${docker_id} >/dev/null 2>/dev/null & ) | ||
#( nohup docker stop ${docker_id} >/dev/null 2>/dev/null & ) | ||
|
||
xz -f ${logfile} 2>/dev/null | ||
|
||
|
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 file belongs under 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. As we have run-ci.sh script file under .build and this script file is using the jenkins-deployment.yaml file, so we placed it in the same dir. 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. please put under |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: jenkins-operator-user-configuration | ||
data: | ||
1-system-message.yaml: | | ||
tool: | ||
jdk: | ||
installations: | ||
- name: jdk_11_latest | ||
home: "/usr/bin/jdk_11/bin/java" | ||
- name: jdk_17_latest | ||
home: "/usr/bin/jdk_17/bin/java" | ||
--- | ||
apiVersion: jenkins.io/v1alpha2 | ||
kind: Jenkins | ||
metadata: | ||
name: example | ||
spec: | ||
configurationAsCode: | ||
configurations: | ||
- name: jenkins-operator-user-configuration | ||
secret: | ||
name: "" | ||
groovyScripts: | ||
configurations: [] | ||
secret: | ||
name: "" | ||
service: | ||
type: ClusterIP | ||
port: 8080 | ||
jenkinsAPISettings: | ||
authorizationStrategy: createUser | ||
master: | ||
plugins: | ||
- name: ws-cleanup | ||
version: "0.45" | ||
- name: javadoc | ||
version: "243.vb_b_503b_b_45537" | ||
- name: description-setter | ||
version: "1.10" | ||
- name: throttle-concurrents | ||
version: "2.14" | ||
- name: test-stability | ||
version: "2.3" | ||
- name: postbuildscript | ||
version: "3.2.0-550.v88192b_d3e922" | ||
- name: github | ||
version: "1.37.3" | ||
- name: timestamper | ||
version: "1.26" | ||
- name: openJDK-native-plugin | ||
version: "1.7" | ||
basePlugins: | ||
- name: kubernetes | ||
version: "4029.v5712230ccb_f8" | ||
- name: workflow-job | ||
version: "1342.v046651d5b_dfe" | ||
- name: workflow-aggregator | ||
version: "596.v8c21c963d92d" | ||
- name: git | ||
version: "5.2.0" | ||
- name: job-dsl | ||
version: "1.84" | ||
- name: configuration-as-code | ||
version: "1700.v6f448841296e" | ||
- name: kubernetes-credentials-provider | ||
version: "1.225.v14f9e6b_28f53" | ||
disableCSRFProtection: false | ||
containers: | ||
- name: jenkins-master | ||
image: jenkins/jenkins:2.414.1-lts-jdk11 | ||
# env: | ||
# - name: JAVA_OPTS | ||
# value: "-Dhudson.cli.CLI.HTTPS=true -Djenkins.websocket=false" | ||
imagePullPolicy: Always | ||
livenessProbe: | ||
failureThreshold: 12 | ||
httpGet: | ||
path: /login | ||
port: http | ||
scheme: HTTP | ||
initialDelaySeconds: 100 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 5 | ||
readinessProbe: | ||
failureThreshold: 10 | ||
httpGet: | ||
path: /login | ||
port: http | ||
scheme: HTTP | ||
initialDelaySeconds: 80 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
resources: | ||
limits: | ||
cpu: 1500m | ||
memory: 3Gi | ||
requests: | ||
cpu: 500m | ||
memory: 500Mi | ||
securityContext: | ||
fsGroup: 1000 | ||
runAsUser: 1000 | ||
seedJobs: | ||
- id: jenkins-operator | ||
targets: ".jenkins/job/DslJob.jenkins" #"cicd/jobs/k8s.jenkins" | ||
description: "Casandra Repo" | ||
repositoryBranch: infracloud/cassandra-5.0 #master #infracloud/cassandra-5.0 # | ||
repositoryUrl: https://github.com/infracloudio/cassandra.git | ||
michaelsembwever marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
# Parse command-line arguments | ||
while [[ $# -gt 0 ]]; do | ||
key="$1" | ||
case $key in | ||
-c|--kubeconfig) | ||
KUBECONFIG="$2" # This sets the KUBECONFIG variable to the next argument. | ||
shift # This shifts the arguments to the left, discarding the current argument and moving to the next one. | ||
shift # This is an additional shift to move to the argument after the option value. | ||
;; | ||
-ctx|--kubecontext) | ||
KUBECONTEXT="$2" # This sets the KUBECONTEXT variable to the next argument. | ||
shift # This shifts the arguments to the left, discarding the current argument and moving to the next one. | ||
shift # This is an additional shift to move to the argument after the option value. | ||
;; | ||
*) | ||
echo "Unknown option: $1" | ||
michaelsembwever marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [ -z "$KUBECONFIG" ] && [ -z "$KUBECONTEXT" ]; then | ||
echo "Please provide either the path to the kubeconfig using -c|--kubeconfig option or the kubecontext using -ctx|--kubecontext option." | ||
exit 1 | ||
fi | ||
|
||
# This sets the kubeconfig and kubecontext if provided | ||
if [ -n "$KUBECONFIG" ]; then | ||
export KUBECONFIG="$KUBECONFIG" | ||
fi | ||
|
||
if [ -n "$KUBECONTEXT" ]; then | ||
kubectl config use-context "$KUBECONTEXT" | ||
fi | ||
|
||
# Install Helm | ||
|
||
# Check if Helm is already installed | ||
if ! command -v helm &>/dev/null; then | ||
echo "Helm not found. Installing Helm..." | ||
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 # enhance without downloading the script | ||
chmod 700 get_helm.sh | ||
./get_helm.sh | ||
else | ||
echo "Helm is already installed." | ||
fi | ||
|
||
# Add Helm Jenkins Operator repository | ||
echo "Adding Helm repository for Jenkins Operator..." | ||
helm repo add jenkins https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/chart | ||
|
||
# Install Jenkins Operator using Helm | ||
echo "Installing Jenkins Operator..." | ||
helm upgrade --install jenkins-operator jenkins/jenkins-operator --set jenkins.enabled=false --set jenkins.backup.enabled=false --version 0.8.0-beta.2 | ||
|
||
echo "Jenkins Operator installed successfully!" # condition to check if above command was success | ||
|
||
# deploy jenkins Instance TODO jenkins file parameter | ||
kubectl apply -f jenkins-deployment.yaml | ||
|
||
# TODO wait for job pods | ||
#kubectl rollout wait pod/ [--for=<condition>] | ||
|
||
#sleep 120 | ||
|
||
# get job pod name - TODO parametrise the job name | ||
#jobPodName=$(kubectl get po | grep k8sagent-e2e | cut -d " " -f1) | ||
|
||
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. we're missing here the teardown of the jenkins stack. something along the lines of
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. you can leave this, i will tackle it. 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. Since for now, the jenkins deployment is working with default namespace only (the limitation we mentioned earlier), so there is no need to delete the default namespace, we can remove the delete command (for namespace) 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. We have added the teardown code, also parameterised it as well |
||
# get the file - TODO parameterize the path to fetch path | ||
#kubectl exec -n default $jobPodName -- tar cf - /home/jenkins/agent/workspace/k8s-e2e | tar xf - -C . |
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.
can be removed now?