Skip to content

Commit c7ed7dd

Browse files
authored
go 1.17 upgrade for prow images (#170)
Description of changes: * include updating go module version inside `go.mod` file alongwith updating ACK runtime version * perform `go mod download` and `go mod tidy` before executing `make build-controller` command * update `go` version to `1.17.5` in all prow images * use github utility functions for opening PR and issues inside `auto-generate-controllers.sh` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 90c1279 commit c7ed7dd

File tree

9 files changed

+118
-121
lines changed

9 files changed

+118
-121
lines changed

cd/auto-generate/auto-generate-controllers.sh

Lines changed: 57 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ GITHUB_ORG=${GITHUB_ORG:-$DEFAULT_GITHUB_ISSUE_ORG}
4646
DEFAULT_GITHUB_ISSUE_REPO="community"
4747
GITHUB_ISSUE_REPO=${GITHUB_ISSUE_REPO:-$DEFAULT_GITHUB_ISSUE_REPO}
4848

49+
GITHUB_ISSUE_ORG_REPO="$GITHUB_ORG/$GITHUB_ISSUE_REPO"
50+
4951
DEFAULT_GITHUB_LABEL="ack-bot-autogen"
5052
GITHUB_LABEL=${GITHUB_LABEL:-$DEFAULT_GITHUB_LABEL}
5153

@@ -57,6 +59,7 @@ MISSING_GIT_TAG="missing-git-tag"
5759

5860
# Check all the dependencies are present in container.
5961
source "$TEST_INFRA_DIR"/scripts/lib/common.sh
62+
source "$TEST_INFRA_DIR"/scripts/lib/gh.sh
6063
check_is_installed git
6164
check_is_installed gh
6265

@@ -79,6 +82,14 @@ else
7982
echo "auto-generate-controllers.sh][INFO] ACK runtime version for new controllers will be $ACK_RUNTIME_VERSION"
8083
fi
8184

85+
GO_VERSION_IN_GO_MOD=$(grep -E "^go [0-9]+\.[0-9]+$" go.mod | cut -d " " -f2)
86+
if [[ -z $GO_VERSION_IN_GO_MOD ]]; then
87+
echo "auto-generate-controllers.sh][ERROR] Unable to determine go version from code-generator/go.mod file. Exiting"
88+
exit 1
89+
else
90+
echo "auto-generate-controllers.sh][INFO] go version in code-generator/go.mod file is $GO_VERSION_IN_GO_MOD"
91+
fi
92+
8293
DEFAULT_PR_SOURCE_BRANCH="ack-bot/runtime-$ACK_RUNTIME_VERSION"
8394
PR_SOURCE_BRANCH=${PR_SOURCE_BRANCH:-$DEFAULT_PR_SOURCE_BRANCH}
8495

@@ -103,20 +114,51 @@ for CONTROLLER_NAME in $CONTROLLER_NAMES; do
103114
# Find the ACK runtime version in service controller 'go.mod' file
104115
pushd "$CONTROLLER_DIR" >/dev/null
105116
SERVICE_RUNTIME_VERSION=$(go list -m -f '{{ .Version }}' github.com/aws-controllers-k8s/runtime 2>/dev/null || echo "$RUNTIME_MISSING_VERSION")
106-
popd >/dev/null
107117

108-
if [[ $SERVICE_RUNTIME_VERSION == $RUNTIME_MISSING_VERSION ]]; then
109-
echo "auto-generate-controllers.sh][ERROR] Unable to determine ACK runtime version from $CONTROLLER_NAME/go.mod file. Skipping $CONTROLLER_NAME"
110-
continue
111-
fi
118+
if [[ $SERVICE_RUNTIME_VERSION == $RUNTIME_MISSING_VERSION ]]; then
119+
echo "auto-generate-controllers.sh][ERROR] Unable to determine ACK runtime version from $CONTROLLER_NAME/go.mod file. Skipping $CONTROLLER_NAME"
120+
continue
121+
fi
112122

113-
# If the current version is same as latest ACK runtime version, skip this controller.
114-
if [[ $SERVICE_RUNTIME_VERSION == $ACK_RUNTIME_VERSION ]]; then
115-
echo "auto-generate-controllers.sh][INFO] $CONTROLLER_NAME already has the latest ACK runtime version $ACK_RUNTIME_VERSION. Skipping $CONTROLLER_NAME"
116-
continue
117-
fi
123+
# If the current version is same as latest ACK runtime version, skip this controller.
124+
if [[ $SERVICE_RUNTIME_VERSION == $ACK_RUNTIME_VERSION ]]; then
125+
echo "auto-generate-controllers.sh][INFO] $CONTROLLER_NAME already has the latest ACK runtime version $ACK_RUNTIME_VERSION. Skipping $CONTROLLER_NAME"
126+
continue
127+
else
128+
echo "auto-generate-controllers.sh][INFO] ACK runtime version for new controller will be $ACK_RUNTIME_VERSION. Current version is $SERVICE_RUNTIME_VERSION"
129+
echo -n "auto-generate-controllers.sh][INFO] Updating 'go.mod' file for $CONTROLLER_NAME with ACK runtime $ACK_RUNTIME_VERSION ... "
130+
if ! go get -u github.com/aws-controllers-k8s/runtime@"$ACK_RUNTIME_VERSION" >/dev/null; then
131+
echo ""
132+
echo "auto-generate-controllers.sh][ERROR] Unable to update go.mod file with ACK runtime version $ACK_RUNTIME_VERSION"
133+
continue
134+
fi
118135

119-
echo "auto-generate-controllers.sh][INFO] ACK runtime version for new controller will be $ACK_RUNTIME_VERSION. Current version is $SERVICE_RUNTIME_VERSION"
136+
echo -n "auto-generate-controllers.sh][INFO] Updating 'go.mod' file for $CONTROLLER_NAME with go version $GO_VERSION_IN_GO_MOD ... "
137+
if ! go mod edit -go="$GO_VERSION_IN_GO_MOD" >/dev/null; then
138+
echo ""
139+
echo "auto-generate-controllers.sh][ERROR] Unable to update go.mod file with go version $GO_VERSION_IN_GO_MOD"
140+
continue
141+
fi
142+
echo "ok"
143+
144+
# go dependencies need to be updated otherwise 'make build-controller' command will fail
145+
echo -n "auto-generate-controllers.sh][INFO] Executing 'go mod download' for $CONTROLLER_NAME after 'go.mod' updates ... "
146+
if ! go mod download >/dev/null; then
147+
echo ""
148+
echo "auto-generate-controllers.sh][ERROR] Unable to perform 'go mod download' for $CONTROLLER_NAME"
149+
continue
150+
fi
151+
echo "ok"
152+
153+
echo -n "auto-generate-controllers.sh][INFO] Executing 'go mod tidy' for $CONTROLLER_NAME after 'go.mod' updates ... "
154+
if ! go mod tidy >/dev/null; then
155+
echo ""
156+
echo "auto-generate-controllers.sh][ERROR] Unable to perform 'go mod tidy' for $CONTROLLER_NAME"
157+
continue
158+
fi
159+
echo "ok"
160+
fi
161+
popd >/dev/null
120162

121163
echo -n "auto-generate-controllers.sh][INFO] Ensuring that GitHub label $GITHUB_LABEL exists for $GITHUB_ORG/$CONTROLLER_NAME ... "
122164
if ! gh api repos/"$GITHUB_ORG"/"$CONTROLLER_NAME"/labels/"$GITHUB_LABEL" --silent >/dev/null; then
@@ -157,15 +199,6 @@ for CONTROLLER_NAME in $CONTROLLER_NAMES; do
157199
echo "auto-generate-controllers.sh][ERROR] Failure while executing 'make build-controller' command. Creating/Updating GitHub issue"
158200
ISSUE_TITLE="Errors while generating \`$CONTROLLER_NAME\` for ACK runtime \`$ACK_RUNTIME_VERSION\`"
159201

160-
echo -n "auto-generate-controllers.sh][INFO] Querying already open GitHub issue ... "
161-
ISSUE_NUMBER=$(gh issue list -R "$GITHUB_ORG/$GITHUB_ISSUE_REPO" -L 1 -s open --json number -S "$ISSUE_TITLE" --jq '.[0].number' -A @me -l "$GITHUB_LABEL")
162-
if [[ $? -ne 0 ]]; then
163-
echo ""
164-
echo "auto-generate-controllers.sh][ERROR] Unable to query open github issue. Skipping $CONTROLLER_NAME"
165-
continue
166-
fi
167-
echo "ok"
168-
169202
# Capture 'make build-controller' command output & error, then persist
170203
# in '$GITHUB_ISSUE_BODY_FILE'
171204
MAKE_BUILD_OUTPUT=$(cat "$MAKE_BUILD_OUTPUT_FILE")
@@ -174,53 +207,15 @@ for CONTROLLER_NAME in $CONTROLLER_NAMES; do
174207
GITHUB_ISSUE_BODY_FILE=/tmp/"SERVICE_NAME"_gh_issue_body
175208
eval "echo \"$(cat "$GITHUB_ISSUE_BODY_TEMPLATE_FILE")\"" > $GITHUB_ISSUE_BODY_FILE
176209

177-
# If there is an already existing issue with same title as '$ISSUE_TITLE',
178-
# update the body of existing issue with latest command output.
179-
# In case no such issue exist, create a new GitHub issue.
180-
# Skip PR generation in both cases and continue to next service controller.
181-
if [[ -z $ISSUE_NUMBER ]]; then
182-
echo -n "auto-generate-controllers.sh][INFO] No open issues exist. Creating a new GitHub issue inside $GITHUB_ORG/$GITHUB_ISSUE_REPO ... "
183-
if ! gh issue create -R "$GITHUB_ORG/$GITHUB_ISSUE_REPO" -t "$ISSUE_TITLE" -F "$GITHUB_ISSUE_BODY_FILE" -l "$GITHUB_LABEL" >/dev/null ; then
184-
echo ""
185-
echo "auto-generate-controllers.sh][ERROR] Unable to create GitHub issue for reporting failure. Skipping $CONTROLLER_NAME"
186-
continue
187-
fi
188-
echo "ok"
189-
continue
190-
else
191-
echo -n "auto-generate-controllers.sh][INFO] Updating error output in the body of existing issue#$ISSUE_NUMBER inside $GITHUB_ORG/$GITHUB_ISSUE_REPO ... "
192-
if ! gh issue edit "$ISSUE_NUMBER" -R "$GITHUB_ORG/$GITHUB_ISSUE_REPO" -F "$GITHUB_ISSUE_BODY_FILE" >/dev/null; then
193-
echo ""
194-
echo "auto-generate-controllers.sh][ERROR] Unable to edit GitHub issue$ISSUE_NUMBER with latest 'make build-controller' error. Skipping $CONTROLLER_NAME"
195-
continue
196-
fi
197-
echo "ok"
198-
continue
199-
fi
210+
open_gh_issue "$GITHUB_ISSUE_ORG_REPO" "$ISSUE_TITLE" "$GITHUB_ISSUE_BODY_FILE"
200211
# Skip creating PR for this service controller after updating GitHub issue.
201212
continue
202213
fi
203214

204215
# Since there are no failures, print make build output in prowjob logs
205216
cat "$MAKE_BUILD_OUTPUT_FILE"
206217
pushd "$CONTROLLER_DIR" >/dev/null
207-
# After successful 'make build-controller', update go.mod file
208-
echo -n "auto-generate-controllers.sh][INFO] Updating 'go.mod' file in $CONTROLLER_NAME ... "
209-
if ! sed -i "s|aws-controllers-k8s/runtime $SERVICE_RUNTIME_VERSION|aws-controllers-k8s/runtime $ACK_RUNTIME_VERSION|" go.mod >/dev/null; then
210-
echo ""
211-
echo "auto-generate-controllers.sh][ERROR] Unable to update go.mod file with latest runtime version. Skipping $CONTROLLER_NAME"
212-
continue
213-
fi
214-
echo "ok"
215-
216-
# perform 'go mod tidy' to remove old ACK runtime dependency
217-
echo -n "auto-generate-controllers.sh][INFO] Executing 'go mod tidy' to cleanup redundant dependencies for $CONTROLLER_NAME ... "
218-
if ! go mod tidy >/dev/null; then
219-
echo ""
220-
echo "auto-generate-controllers.sh][ERROR] Unable to execute 'go mod tidy'. Skipping $CONTROLLER_NAME"
221-
continue
222-
fi
223-
echo "ok"
218+
GITHUB_CONTROLLER_ORG_REPO="$GITHUB_ORG/$CONTROLLER_NAME"
224219

225220
# add git remote
226221
echo -n "auto-generate-controllers.sh][INFO] Adding git remote ... "
@@ -251,44 +246,15 @@ for CONTROLLER_NAME in $CONTROLLER_NAMES; do
251246
fi
252247
echo "ok"
253248

254-
# If a PR exists from '$PR_SOURCE_BRANCH' to '$PR_TARGET_BRANCH' then
255-
# update the PR body with latest successful command output.
256-
# In case no such PR exists, create a new PR.
257-
echo -n "auto-generate-controllers.sh][INFO] Finding existing open pull requests ... "
258-
PR_NUMBER=$(gh pr list -R "$GITHUB_ORG/$CONTROLLER_NAME" -A @me -L 1 -s open --json number -S "$COMMIT_MSG" --jq '.[0].number' -l "$GITHUB_LABEL")
259-
if [[ $? -ne 0 ]]; then
260-
echo ""
261-
echo "auto-generate-controllers.sh][ERROR] Failed to query for an existing pull request for $GITHUB_ORG/$CONTROLLER_NAME , from $PR_SOURCE_BRANCH -> $PR_TARGET_BRANCH branch"
262-
else
263-
echo "ok"
264-
fi
265-
266249
# Capture 'make build-controller' command output, then persist
267250
# in '$GITHUB_PR_BODY_FILE'
268251
MAKE_BUILD_OUTPUT=$(cat "$MAKE_BUILD_OUTPUT_FILE")
269252
PR_BODY_TEMPLATE_FILE_NAME=$([[ -z "$RELEASE_VERSION" ]] && echo "gh_pr_body_template.txt" || echo "gh_pr_body_new_release_template.txt")
270253
GITHUB_PR_BODY_TEMPLATE_FILE="$THIS_DIR/$PR_BODY_TEMPLATE_FILE_NAME"
271-
GITHUB_PR_BODY_FILE=/tmp/"SERVICE_NAME"_gh_pr_body
254+
GITHUB_PR_BODY_FILE=/tmp/"$SERVICE_NAME"_gh_pr_body
272255
eval "echo \"$(cat "$GITHUB_PR_BODY_TEMPLATE_FILE")\"" > $GITHUB_PR_BODY_FILE
273256

274-
if [[ -z $PR_NUMBER ]]; then
275-
echo -n "auto-generate-controllers.sh][INFO] No Existing PRs found. Creating a new pull request for $GITHUB_ORG/$CONTROLLER_NAME , from $PR_SOURCE_BRANCH -> $PR_TARGET_BRANCH branch ... "
276-
if ! gh pr create -R "$GITHUB_ORG/$CONTROLLER_NAME" -t "$COMMIT_MSG" -F "$GITHUB_PR_BODY_FILE" -H "$PR_SOURCE_BRANCH" -B "$PR_TARGET_BRANCH" -l "$GITHUB_LABEL" >/dev/null ; then
277-
echo ""
278-
echo "auto-generate-controllers.sh][ERROR] Failed to create pull request. Skipping $CONTROLLER_NAME"
279-
continue
280-
fi
281-
echo "ok"
282-
else
283-
echo "auto-generate-controllers.sh][INFO] PR#$PR_NUMBER already exists for $GITHUB_ORG/$CONTROLLER_NAME , from $PR_SOURCE_BRANCH -> $PR_TARGET_BRANCH branch"
284-
echo -n "auto-generate-controllers.sh][INFO] Updating PR body with latest 'make build-controller' output..."
285-
if ! gh pr edit "$PR_NUMBER" -R "$GITHUB_ORG/$CONTROLLER_NAME" -F "$GITHUB_PR_BODY_FILE" >/dev/null ; then
286-
echo ""
287-
echo "auto-generate-controllers.sh][ERROR] Failed to update pull request"
288-
continue
289-
fi
290-
echo "ok"
291-
fi
257+
open_pull_request "$GITHUB_CONTROLLER_ORG_REPO" "$COMMIT_MSG" "$GITHUB_PR_BODY_FILE"
292258
echo "auto-generate-controllers.sh][INFO] Done :) "
293259
# PRs created from this script trigger the presubmit prowjobs.
294260
# To control the number of presubmit prowjobs that will run in parallel,

cd/core-validator/generate-test-controller.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ pushd "$CODEGEN_DIR" >/dev/null
3333
else
3434
echo "generate-test-controller.sh][INFO] ACK runtime version in code-generator/go.mod file is $ACK_RUNTIME_VERSION"
3535
fi
36+
37+
GO_VERSION_IN_GO_MOD=$(grep -E "^go [0-9]+\.[0-9]+$" go.mod | cut -d " " -f2)
38+
if [[ -z $GO_VERSION_IN_GO_MOD ]]; then
39+
echo "generate-test-controller.sh][ERROR] Unable to determine go version from code-generator/go.mod file. Exiting"
40+
exit 1
41+
else
42+
echo "generate-test-controller.sh][INFO] go version in code-generator/go.mod file is $GO_VERSION_IN_GO_MOD"
43+
fi
3644
popd >/dev/null
3745

3846
# Update go.mod file
@@ -48,6 +56,29 @@ pushd "$CONTROLLER_DIR" >/dev/null
4856
echo "generate-test-controller.sh][ERROR] Unable to update go.mod file with ACK runtime version $ACK_RUNTIME_VERSION"
4957
exit 1
5058
fi
59+
60+
echo -n "generate-test-controller.sh][INFO] Updating 'go.mod' file for $CONTROLLER_NAME with go version $GO_VERSION_IN_GO_MOD ... "
61+
if ! go mod edit -go="$GO_VERSION_IN_GO_MOD" >/dev/null; then
62+
echo ""
63+
echo "generate-test-controller.sh][ERROR] Unable to update go.mod file with go version $GO_VERSION_IN_GO_MOD"
64+
exit 1
65+
fi
66+
echo "ok"
67+
68+
echo -n "generate-test-controller.sh][INFO] Executing 'go mod download' for $CONTROLLER_NAME after 'go.mod' updates ... "
69+
if ! go mod download >/dev/null; then
70+
echo ""
71+
echo "generate-test-controller.sh][ERROR] Unable to perform 'go mod download' for $CONTROLLER_NAME"
72+
exit 1
73+
fi
74+
echo "ok"
75+
76+
echo -n "generate-test-controller.sh][INFO] Executing 'go mod tidy' for $CONTROLLER_NAME after 'go.mod' updates ... "
77+
if ! go mod tidy >/dev/null; then
78+
echo ""
79+
echo "generate-test-controller.sh][ERROR] Unable to perform 'go mod tidy' for $CONTROLLER_NAME"
80+
exit 1
81+
fi
5182
echo "ok"
5283
popd >/dev/null
5384

prow/jobs/images/Dockerfile.auto-generate-controllers

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM debian:buster-slim AS base
33
ARG GOPROXY=https://proxy.golang.org|direct
44
ENV GOPROXY=${GOPROXY}
55

6-
ARG GO_VERSION=1.15
6+
ARG GO_VERSION=1.17.5
77
ENV GO_VERSION=${GO_VERSION}
88

99
ENV GOPATH=/home/prow/go \

prow/jobs/images/Dockerfile.olm-bundle-pr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM debian:buster-slim AS base
33
ARG GOPROXY=https://proxy.golang.org|direct
44
ENV GOPROXY=${GOPROXY}
55

6-
ARG GO_VERSION=1.15
6+
ARG GO_VERSION=1.17.5
77
ENV GO_VERSION=${GO_VERSION}
88

99
ENV GOPATH=/home/prow/go \

prow/jobs/images/Dockerfile.olm-test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM debian:buster-slim AS base
33
ARG GOPROXY=https://proxy.golang.org|direct
44
ENV GOPROXY=${GOPROXY}
55

6-
ARG GO_VERSION=1.15
6+
ARG GO_VERSION=1.17.5
77
ENV GO_VERSION=${GO_VERSION}
88

99
ENV GOPATH=/home/prow/go \

prow/jobs/jinja/postsubmits/codegen_release.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
spec:
2020
serviceAccountName: post-submit-service-account
2121
containers:
22-
- image: public.ecr.aws/m5q3e4b2/prow:prow-auto-generate-controllers-0.0.5
22+
- image: public.ecr.aws/m5q3e4b2/prow:prow-auto-generate-controllers-0.0.6
2323
env:
2424
- name: GITHUB_TOKEN
2525
valueFrom:

prow/jobs/jinja/postsubmits/controller_release.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
spec:
115115
serviceAccountName: post-submit-service-account
116116
containers:
117-
- image: public.ecr.aws/m5q3e4b2/prow:prow-olm-bundle-pr-0.0.1
117+
- image: public.ecr.aws/m5q3e4b2/prow:prow-olm-bundle-pr-0.0.2
118118
env:
119119
- name: GITHUB_TOKEN
120120
valueFrom:

prow/jobs/jinja/presubmits/code_generator_tests.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
spec:
3333
serviceAccountName: pre-submit-service-account
3434
containers:
35-
- image: public.ecr.aws/m5q3e4b2/prow:prow-olm-test-0.0.1
35+
- image: public.ecr.aws/m5q3e4b2/prow:prow-olm-test-0.0.2
3636
env:
3737
- name: SERVICE
3838
value: "s3"

0 commit comments

Comments
 (0)