Skip to content

Commit 66faee9

Browse files
Merge pull request #2474 from trozet/merge-2-27-25
OCPBUGS-48781: [DownstreamMerge] 2-27-25
2 parents 2e689e1 + ecf7e81 commit 66faee9

File tree

450 files changed

+14056
-8769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

450 files changed

+14056
-8769
lines changed

.github/actions/retest-action/entrypoint.sh

Lines changed: 76 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ set -ex
66
# Prerequisites check
77
##############################
88

9-
if ! jq -e '.issue.pull_request' ${GITHUB_EVENT_PATH}; then
9+
if ! jq -e '.issue.pull_request' "${GITHUB_EVENT_PATH}"; then
1010
echo "Not a PR... Exiting."
1111
exit 0
1212
fi
1313

14-
COMMENT_BODY=$(jq -r '.comment.body' ${GITHUB_EVENT_PATH})
14+
COMMENT_BODY=$(jq -r '.comment.body' "${GITHUB_EVENT_PATH}")
1515
if [ "${COMMENT_BODY}" != "/retest" ] &&
1616
[ "${COMMENT_BODY}" != "/retest-failed" ] &&
1717
[ "${COMMENT_BODY}" != "/cancel" ] &&
@@ -25,25 +25,27 @@ fi
2525
##############################
2626

2727
send_reaction() {
28-
local REACTION_SYMBOL="$1"
29-
local REACTION_URL="$(jq -r '.comment.url' ${GITHUB_EVENT_PATH})/reactions"
30-
curl --request POST \
31-
--url "${REACTION_URL}" \
32-
--header "authorization: Bearer ${GITHUB_TOKEN}" \
33-
--header "accept: application/vnd.github.squirrel-girl-preview+json" \
34-
--header "content-type: application/json" \
35-
--data '{ "content" : "'${REACTION_SYMBOL}'" }'
28+
REACTION_SYMBOL="$1"
29+
REACTION_URL="$(jq -r '.comment.url' "${GITHUB_EVENT_PATH}")/reactions"
30+
curl --silent \
31+
--request POST \
32+
--url "${REACTION_URL}" \
33+
--header "authorization: Bearer ${GITHUB_TOKEN}" \
34+
--header "accept: application/vnd.github.squirrel-girl-preview+json" \
35+
--header "content-type: application/json" \
36+
--data '{ "content" : "'"${REACTION_SYMBOL}"'" }'
3637
}
3738

3839
send_comment() {
39-
local COMMENT="$1"
40-
local COMMENTS_URL=$(jq -r '.issue.comments_url' ${GITHUB_EVENT_PATH})
41-
curl --request POST \
42-
--url "${COMMENTS_URL}" \
43-
--header "authorization: Bearer ${GITHUB_TOKEN}" \
44-
--header "accept: application/vnd.github.squirrel-girl-preview+json" \
45-
--header "content-type: application/json" \
46-
--data '{ "body" : "'"${COMMENT}"'" }'
40+
COMMENT="$1"
41+
COMMENTS_URL=$(jq -r '.issue.comments_url' "${GITHUB_EVENT_PATH}")
42+
curl --silent \
43+
--request POST \
44+
--url "${COMMENTS_URL}" \
45+
--header "authorization: Bearer ${GITHUB_TOKEN}" \
46+
--header "accept: application/vnd.github.squirrel-girl-preview+json" \
47+
--header "content-type: application/json" \
48+
--data '{ "body" : "'"${COMMENT}"'" }'
4749
}
4850

4951
##############################
@@ -52,58 +54,80 @@ send_comment() {
5254

5355
ACTION="${COMMENT_BODY}"
5456

55-
if [ "$ACTION" == "/help" ]; then
57+
if [ "$ACTION" = "/help" ]; then
5658
send_comment "Supported operations are /retest, /retest-failed, /cancel"
5759
exit 0
5860
fi
5961

60-
PR_URL=$(jq -r '.issue.pull_request.url' ${GITHUB_EVENT_PATH})
62+
PR_URL=$(jq -r '.issue.pull_request.url' "${GITHUB_EVENT_PATH}")
6163

62-
curl --request GET \
63-
--url "${PR_URL}" \
64-
--header "authorization: Bearer ${GITHUB_TOKEN}" \
65-
--header "content-type: application/json" > pr.json
64+
curl --silent \
65+
--request GET \
66+
--url "${PR_URL}" \
67+
--header "authorization: Bearer ${GITHUB_TOKEN}" \
68+
--header "content-type: application/json" \
69+
> pr.json
6670

6771
ACTOR=$(jq -r '.user.login' pr.json)
6872
BRANCH=$(jq -r '.head.ref' pr.json)
6973

70-
curl --request GET \
71-
--url "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs?event=pull_request&actor=${ACTOR}&branch=${BRANCH}" \
72-
--header "authorization: Bearer ${GITHUB_TOKEN}" \
73-
--header "content-type: application/json" | jq '.workflow_runs | max_by(.run_number)' > run.json
74+
curl --silent \
75+
--request GET \
76+
--url "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs?event=pull_request&actor=${ACTOR}&branch=${BRANCH}" \
77+
--header "authorization: Bearer ${GITHUB_TOKEN}" \
78+
--header "content-type: application/json" |\
79+
jq '.workflow_runs | group_by(.name) | map(max_by(.run_number))' \
80+
> workflow_runs.json
81+
82+
[ -f "workflow_runs.json" ] && cat workflow_runs.json
7483

75-
ACTION_URL=""
76-
if [ "$ACTION" == "/retest" ]; then
77-
ACTION_URL=$(jq -r '.rerun_url' run.json)
78-
elif [ "$ACTION" == "/retest-failed" ]; then
84+
if [ "$ACTION" = "/retest" ]; then
85+
jq -r 'map(select(.status|contains("completed"))) | .[] | .rerun_url' workflow_runs.json \
86+
> url.data
87+
elif [ "$ACTION" = "/retest-failed" ]; then
7988
# New feature, rerun failed jobs:
8089
# https://docs.github.com/en/rest/reference/actions#re-run-failed-jobs-from-a-workflow-run
81-
RERUN_URL=$(jq -r '.rerun_url' run.json)
82-
ACTION_URL=${RERUN_URL}-failed-jobs
83-
elif [ "$ACTION" == "/cancel" ]; then
84-
ACTION_URL=$(jq -r '.cancel_url' run.json)
90+
jq -r 'map(select(.status|contains("completed"))) | map(select(.conclusion|contains("failure"))) | .[] | .rerun_url + "-failed-jobs"' workflow_runs.json \
91+
> url.data
92+
elif [ "$ACTION" = "/cancel" ]; then
93+
jq -r 'map(select(.status | test ("queued|in_progress|pending" )) | .[] | .cancel_url' workflow_runs.json \
94+
> url.data
8595
else
8696
echo "Something went wrong, unsupported action"
8797
exit 0
8898
fi
8999

90-
# Execute the action.
91-
# Store the response code in a variable.
92-
# Store the answer in file .action-response.json.
93-
RESPONSE_CODE=$(curl --write-out '%{http_code}' --silent --output .action-response.json --request POST \
94-
--url "${ACTION_URL}" \
95-
--header "authorization: Bearer ${GITHUB_TOKEN}" \
96-
--header "content-type: application/json")
97-
98-
99100
REACTION_SYMBOL="rocket"
100-
if ! echo ${RESPONSE_CODE} | egrep -q '^2'; then
101+
for url in $(cat url.data); do
102+
# Execute the action.
103+
# Store the response code in a variable.
104+
# Store the answer in file .action-response.json.
105+
RESPONSE_CODE=$(curl --silent \
106+
--write-out '%{http_code}' \
107+
--output .action-response.json \
108+
--request POST \
109+
--url "${url}" \
110+
--header "authorization: Bearer ${GITHUB_TOKEN}" \
111+
--header "content-type: application/json")
112+
113+
if ! echo "${RESPONSE_CODE}" | grep -E -q '^2'; then
114+
REACTION_SYMBOL="confused"
115+
RESPONSE_MESSAGE=$(jq -r '.message' .action-response.json)
116+
send_comment "Oops, something went wrong when triggering workflow run\n${url}\n~~~\n${RESPONSE_MESSAGE}\n~~~\n"
117+
break
118+
fi
119+
touch triggered.data
120+
echo "$url" | sed -e 's|/api.github.com/repos/|/github.com/|' -e 's|/[^/]*$||' >> triggered.data
121+
rm .action-response.json
122+
done
123+
124+
if [ -f "triggered.data" ]; then
125+
RESPONSE_MESSAGE="The following workflows runs were succesfully triggered:\n$(cat triggered.data)"
126+
send_comment "${RESPONSE_MESSAGE}"
127+
else
101128
REACTION_SYMBOL="confused"
129+
RESPONSE_MESSAGE="There was an error or no workflows were found in an appropriate state to be triggered"
130+
send_comment "${RESPONSE_MESSAGE}"
102131
fi
103-
send_reaction "${REACTION_SYMBOL}"
104132

105-
# In case we received a non 2xx response code, relay the error message as a comment.
106-
if ! echo ${RESPONSE_CODE} | egrep -q '^2'; then
107-
RESPONSE_MESSAGE=$(jq -r '.message' .action-response.json)
108-
send_comment "Oops, something went wrong:\n~~~\n${RESPONSE_MESSAGE}\n~~~\n"
109-
fi
133+
send_reaction "${REACTION_SYMBOL}"

.github/workflows/commands.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
- name: Re-Test Action
2424
uses: ./.github/actions/retest-action
2525
with:
26-
token: ${{ secrets.REPO_ACCESS_TOKEN }}
26+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ env:
3131
CI_IMAGE_PR_TAR: image-pr.tar
3232
CI_DIST_IMAGES_OUTPUT: dist/images/_output/
3333

34+
# To run CI over custom OVN
35+
# OVN_REPO: https://github.com/ovn-org/ovn
36+
# OVN_GITREF: main
3437

3538
jobs:
3639
# separate job for parallelism
@@ -49,9 +52,9 @@ jobs:
4952
id: go
5053

5154
- name: Verify
52-
uses: golangci/golangci-lint-action@v4
55+
uses: golangci/golangci-lint-action@v6
5356
with:
54-
version: v1.56.1
57+
version: v1.59.1
5558
working-directory: go-controller
5659
args: --modules-download-mode=vendor --timeout=15m0s --verbose
5760

@@ -116,12 +119,11 @@ jobs:
116119
- name: Build docker image - from master branch
117120
if: steps.is_master_image_build_needed.outputs.MASTER_IMAGE_RESTORED != 'true' && success()
118121
run: |
119-
pushd dist/images
120-
sudo cp -f ../../go-controller/_output/go/bin/ovn* .
121-
sudo cp -f ../../go-controller/_output/go/bin/hybrid-overlay-node .
122-
echo "ref: $(git rev-parse --symbolic-full-name HEAD) commit: $(git rev-parse HEAD)" > git_info
123-
docker build -t ovn-daemonset-fedora:dev -f Dockerfile.fedora .
124-
popd
122+
make -C dist/images \
123+
IMAGE=ovn-daemonset-fedora:dev \
124+
OVN_REPO=${{ env.OVN_REPO }} \
125+
OVN_GITREF=${{ env.OVN_GITREF }} \
126+
fedora-image
125127
126128
- name: Cache master image
127129
if: steps.is_master_image_build_needed.outputs.MASTER_IMAGE_RESTORED_FROM_CACHE != 'true' && success()
@@ -207,12 +209,13 @@ jobs:
207209
if: steps.is_pr_image_build_needed.outputs.PR_IMAGE_RESTORED != 'true' && success()
208210
run: |
209211
pushd dist/images
210-
sudo cp -f ../../go-controller/_output/go/bin/ovn* .
211-
sudo cp -f ../../go-controller/_output/go/bin/hybrid-overlay-node .
212-
echo "ref: $(git rev-parse --symbolic-full-name HEAD) commit: $(git rev-parse HEAD)" > git_info
213-
docker build -t ovn-daemonset-fedora:pr -f Dockerfile.fedora .
212+
IMAGE=ovn-daemonset-fedora:pr
213+
make IMAGE=${IMAGE} \
214+
OVN_REPO=${{ env.OVN_REPO }} \
215+
OVN_GITREF=${{ env.OVN_GITREF }} \
216+
fedora-image
214217
mkdir _output
215-
docker save ovn-daemonset-fedora:pr > _output/${CI_IMAGE_PR_TAR}
218+
docker save ${IMAGE} > _output/${CI_IMAGE_PR_TAR}
216219
popd
217220
218221
- name: Submit code coverage to Coveralls

contrib/kind.sh

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ usage() {
116116
echo "-gm | --gateway-mode Enable 'shared' or 'local' gateway mode."
117117
echo " DEFAULT: shared."
118118
echo "-ov | --ovn-image Use the specified docker image instead of building locally. DEFAULT: local build."
119+
echo "-ovr | --ovn-repo Specify the repository to build OVN from"
120+
echo "-ovg | --ovn-gitref Specify the branch, tag or commit id to build OVN from, it can be a pattern like 'branch-*' it will order results and use the first one"
119121
echo "-ml | --master-loglevel Log level for ovnkube (master), DEFAULT: 5."
120122
echo "-nl | --node-loglevel Log level for ovnkube (node), DEFAULT: 5"
121123
echo "-dbl | --dbchecker-loglevel Log level for ovn-dbchecker (ovnkube-db), DEFAULT: 5."
@@ -248,6 +250,12 @@ parse_args() {
248250
-ov | --ovn-image ) shift
249251
OVN_IMAGE=$1
250252
;;
253+
-ovr | --ovn-repo ) shift
254+
OVN_REPO=$1
255+
;;
256+
-ovg | --ovn-gitref) shift
257+
OVN_GITREF=$1
258+
;;
251259
-ml | --master-loglevel ) shift
252260
if ! [[ "$1" =~ ^[0-9]$ ]]; then
253261
echo "Invalid master-loglevel: $1"
@@ -393,6 +401,8 @@ print_params() {
393401
echo "OVN_EMPTY_LB_EVENTS = $OVN_EMPTY_LB_EVENTS"
394402
echo "OVN_MULTICAST_ENABLE = $OVN_MULTICAST_ENABLE"
395403
echo "OVN_IMAGE = $OVN_IMAGE"
404+
echo "OVN_REPO = $OVN_REPO"
405+
echo "OVN_GITREF = $OVN_GITREF"
396406
echo "MASTER_LOG_LEVEL = $MASTER_LOG_LEVEL"
397407
echo "NODE_LOG_LEVEL = $NODE_LOG_LEVEL"
398408
echo "DBCHECKER_LOG_LEVEL = $DBCHECKER_LOG_LEVEL"
@@ -537,6 +547,8 @@ set_default_params() {
537547
OVN_MULTICAST_ENABLE=${OVN_MULTICAST_ENABLE:-false}
538548
KIND_ALLOW_SYSTEM_WRITES=${KIND_ALLOW_SYSTEM_WRITES:-false}
539549
OVN_IMAGE=${OVN_IMAGE:-local}
550+
OVN_REPO=${OVN_REPO:-""}
551+
OVN_GITREF=${OVN_GITREF:-""}
540552
MASTER_LOG_LEVEL=${MASTER_LOG_LEVEL:-5}
541553
NODE_LOG_LEVEL=${NODE_LOG_LEVEL:-5}
542554
DBCHECKER_LOG_LEVEL=${DBCHECKER_LOG_LEVEL:-5}
@@ -788,26 +800,19 @@ build_ovn_image() {
788800
if [ "$OVN_IMAGE" == local ]; then
789801
set_ovn_image
790802

791-
# Build ovn image
792-
pushd ${DIR}/../go-controller
793-
make
794-
popd
803+
# Build binaries
804+
make -C ${DIR}/../go-controller
795805

796-
# Build ovn kube image
797-
pushd ${DIR}/../dist/images
798-
# Find all built executables, but ignore the 'windows' directory if it exists
799-
find ../../go-controller/_output/go/bin/ -maxdepth 1 -type f -exec cp -f {} . \;
800-
echo "ref: $(git rev-parse --symbolic-full-name HEAD) commit: $(git rev-parse HEAD)" > git_info
801-
$OCI_BIN build -t "${OVN_IMAGE}" -f Dockerfile.fedora .
806+
# Build image
807+
make -C ${DIR}/../dist/images IMAGE="${OVN_IMAGE}" OVN_REPO="${OVN_REPO}" OVN_GITREF="${OVN_GITREF}" OCI_BIN="${OCI_BIN}" fedora-image
802808

803809
# store in local registry
804810
if [ "$KIND_LOCAL_REGISTRY" == true ];then
805811
echo "Pushing built image to local $OCI_BIN registry"
806812
$OCI_BIN push "${OVN_IMAGE}"
807813
fi
808-
popd
809814
# We should push to local registry if image is not remote
810-
elif [ "${OVN_IMAGE}" != "" -a "${KIND_LOCAL_REGISTRY}" == true ] && (echo "$OVN_IMAGE" | grep / -vq); then
815+
elif [ "${OVN_IMAGE}" != "" -a "${KIND_LOCAL_REGISTRY}" == true ] && (echo "$OVN_IMAGE" | grep / -vq); then
811816
local local_registry_ovn_image="localhost:5000/${OVN_IMAGE}"
812817
$OCI_BIN tag "$OVN_IMAGE" $local_registry_ovn_image
813818
OVN_IMAGE=$local_registry_ovn_image

0 commit comments

Comments
 (0)