-
Notifications
You must be signed in to change notification settings - Fork 129
[v2.10] add prime mode logic to the provisioning-tests script #1841
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: dev-v2.10
Are you sure you want to change the base?
Changes from all commits
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,31 @@ | ||
| #!/usr/bin/awk -f | ||
| # Usage: channels-pick-minchan-for-version.awk <channels-file> <exact-version> | ||
| # Prints the minChannelServerVersion for that release (if present), returns 2 | ||
| # if receives insufficient arguments, else nothing. | ||
|
|
||
| function trim(s){ sub(/^[ \t\r\n]+/,"",s); sub(/[ \t\r\n]+$/,"",s); return s } | ||
|
|
||
| BEGIN { | ||
| if (ARGC < 3) exit 2 | ||
jferrazbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| target = ARGV[2] | ||
| ARGV[2] = "" # prevent awk from treating target as a file | ||
| inBlock = 0 | ||
| curVer = "" | ||
| } | ||
|
|
||
| # Start of a release block: "- version: <ver>" | ||
| /^[[:space:]]*-[[:space:]]*version:[[:space:]]*/ { | ||
| inBlock = 1 | ||
| line = $0 | ||
| sub(/^[[:space:]]*-[[:space:]]*version:[[:space:]]*/, "", line) | ||
| curVer = trim(line) | ||
| next | ||
| } | ||
|
|
||
| # Capture minChannelServerVersion only if we are in the target block | ||
| inBlock && curVer == target && /^[[:space:]]*minChannelServerVersion:[[:space:]]*/ { | ||
| line = $0 | ||
| sub(/^[[:space:]]*minChannelServerVersion:[[:space:]]*/, "", line) | ||
| print trim(line) | ||
| exit 0 | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,66 @@ | ||||||||||
| #!/usr/bin/env bash | ||||||||||
| # scripts/prime-route | ||||||||||
| # Sets PRIME_MODE, PRIME_REGISTRY_ENVIRONMENT, and (optionally) PRIME_REG_HOST/CATTLE_AGENT_IMAGE. | ||||||||||
| # Detection is independent of whether endpoints are available. | ||||||||||
| # Inputs: | ||||||||||
| # CHANNELS_FILE, SOME_K8S_VERSION, LAST_COMMUNITY_RANCHER | ||||||||||
| # REGISTRY_ENDPOINT, STAGE_REGISTRY_ENDPOINT | ||||||||||
| # PRIME_AGENT_IMAGE | ||||||||||
| set -e | ||||||||||
|
|
||||||||||
| # only set defaults if not provided by the workflow | ||||||||||
| if [ -z "${LAST_COMMUNITY_RANCHER:-}" ]; then | ||||||||||
| LAST_COMMUNITY_RANCHER="v2.10.0-alpha1" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| if [ -z "${PRIME_AGENT_IMAGE:-}" ]; then | ||||||||||
| PRIME_AGENT_IMAGE="rancher/rancher-agent:v2.10.10" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| # Compute minChannelServerVersion for the selected K8s version (may be empty) | ||||||||||
| MINCHAN="$(scripts/channels-pick-minchan-for-version.awk "${CHANNELS_FILE}" "${SOME_K8S_VERSION}" || true)" | ||||||||||
|
|
||||||||||
| # Defaults | ||||||||||
| PRIME_MODE=0 | ||||||||||
| unset PRIME_REGISTRY_ENVIRONMENT | ||||||||||
| unset PRIME_REG_HOST | ||||||||||
jferrazbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| # Decide Prime mode purely by version comparison: MINCHAN > LAST_COMMUNITY_RANCHER | ||||||||||
| if [[ -n "${MINCHAN}" ]] && scripts/semver_g.awk "${MINCHAN}" "${LAST_COMMUNITY_RANCHER}"; then | ||||||||||
| PRIME_MODE=1 | ||||||||||
|
|
||||||||||
| # --- BEGIN sensitive section (suppress xtrace to avoid printing hosts) --- | ||||||||||
| _TRACE_WAS_ON=0 | ||||||||||
| if [[ $- == *x* ]]; then | ||||||||||
| _TRACE_WAS_ON=1 | ||||||||||
| set +x | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| # Choose staging vs production by "-rc" in SOME_K8S_VERSION (prerelease => staging) | ||||||||||
| if [[ "${SOME_K8S_VERSION,,}" == *-rc* ]]; then | ||||||||||
| PRIME_REGISTRY_ENVIRONMENT="staging" | ||||||||||
| PRIME_REG_HOST="${STAGE_REGISTRY_ENDPOINT:-}" | ||||||||||
| else | ||||||||||
| PRIME_REGISTRY_ENVIRONMENT="production" | ||||||||||
| PRIME_REG_HOST="${REGISTRY_ENDPOINT:-}" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| # Only export PRIME_REG_HOST if it is set | ||||||||||
| if [[ -n "${PRIME_REG_HOST}" ]]; then | ||||||||||
| export PRIME_REG_HOST | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| # If Prime is on and PRIME_AGENT_IMAGE is set, override CATTLE_AGENT_IMAGE | ||||||||||
| if [[ -n "${PRIME_AGENT_IMAGE:-}" ]]; then | ||||||||||
|
Comment on lines
+53
to
+54
|
||||||||||
| # If Prime is on and PRIME_AGENT_IMAGE is set, override CATTLE_AGENT_IMAGE | |
| if [[ -n "${PRIME_AGENT_IMAGE:-}" ]]; then | |
| # If Prime is on and PRIME_AGENT_IMAGE is set, override CATTLE_AGENT_IMAGE only if not already set | |
| if [[ -n "${PRIME_AGENT_IMAGE:-}" && -z "${CATTLE_AGENT_IMAGE:-}" ]]; then |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/usr/bin/awk -f | ||
| # Exit codes: 0 if A>B by major.minor.patch (ignoring pre-release suffix), 1 if A<=B, 2 if insufficient arguments. | ||
| # Usage: scripts/semver_g.awk <A> <B> | ||
jferrazbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| function norm(s, n,i,arr) { | ||
| gsub(/^v/,"",s); sub(/-.*/,"",s) | ||
| n = split(s, arr, ".") | ||
| for (i=1; i<=3; i++) if (i>n) arr[i]=0 | ||
| return sprintf("%d.%d.%d", arr[1], arr[2], arr[3]) | ||
| } | ||
| BEGIN { | ||
| if (ARGC < 3) exit 2 | ||
jferrazbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| as = norm(ARGV[1]); bs = norm(ARGV[2]) | ||
| split(as,a,"."); split(bs,b,".") | ||
| if (a[1]>b[1] || (a[1]==b[1] && (a[2]>b[2] || (a[2]==b[2] && a[3]>b[3])))) exit 0 | ||
| exit 1 | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.