-
Notifications
You must be signed in to change notification settings - Fork 75
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
[v1.3] Add addon version check with the repo #754
base: v1.3
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 |
---|---|---|
|
@@ -135,6 +135,82 @@ tar zxvf ${CHARTS_DIR}/nvidia-driver-runtime-${NVIDIA_DRIVER_RUNTIME_CHART_VERSI | |
# Create Helm repo index after charts are ready | ||
helm repo index ${CHARTS_DIR} | ||
|
||
# Check the matching of addon chart version and repo chart version | ||
check_addon_chart_version_matching() { | ||
echo "charts packed in Harvester repo" | ||
ls -alht ${CHARTS_DIR} | ||
|
||
echo "addon template files" | ||
ls -alht ${TOP_DIR}/pkg/config/templates/rancherd-22-addons.yaml | ||
|
||
for filename in ${TOP_DIR}/pkg/config/templates/rancherd-22-addons.yaml; do | ||
local tmpfile=/tmp/$(basename ${filename}) | ||
grep -v "{{" ${filename} > ${tmpfile} | ||
local cnt=$(yq '.resources | length' ${tmpfile}) | ||
|
||
local i=0 | ||
while [[ $i -lt $cnt ]] ; do | ||
local chart=$(idx=$i yq '.resources[env(idx)].spec.chart' ${tmpfile}) | ||
local version=$(idx=$i yq '.resources[env(idx)].spec.version' ${tmpfile}) | ||
echo addon: "$chart" version: $version | ||
|
||
local EXIT_CODE=0 | ||
local repover=$(chart=$chart yq '.entries[strenv(chart)][0].version' < ${CHARTS_DIR}/index.yaml) || EXIT_CODE=$? | ||
if [ $EXIT_CODE != 0 ]; then | ||
echo WARNING: addon $chart is defined, but the chart is not packed into repo / repo struct is changed | ||
continue | ||
fi | ||
|
||
# some charts are not packed into arm64 ISO, the above yq will return `null` | ||
if [[ $repover == "null" ]] && [[ ${ARCH} == "arm64" ]]; then | ||
echo WARNING: addon "$chart" is defined with version "$version" but the chart is not packed into repo in ${ARCH} | ||
elif [[ $repover != $version ]]; then | ||
echo addon "$chart" has version mis-matching: in repo is "$repover" but in addon is "$version" | ||
Comment on lines
+166
to
+168
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. same here |
||
return 1 | ||
fi | ||
(( i += 1 )) | ||
done | ||
done | ||
echo "all addons have matched version with the repo" | ||
} | ||
|
||
check_addon_chart_version_matching | ||
|
||
check_upgrade_addon_chart_version_matching() { | ||
echo "upgrade addon files" | ||
ls -alht ${harvester_path}/package/upgrade/addons | ||
|
||
for filename in ${harvester_path}/package/upgrade/addons/*.yaml; do | ||
local tmpfile=/tmp/$(basename ${filename}) | ||
grep -v "{{" ${filename} > ${tmpfile} | ||
|
||
local chart=$(yq '.spec.chart' ${tmpfile}) | ||
local version=$(yq '.spec.version' ${tmpfile}) | ||
echo upgrade addon: "$chart" version: $version | ||
|
||
local EXIT_CODE=0 | ||
local repover=$(chart=$chart yq '.entries[strenv(chart)][0].version' < ${CHARTS_DIR}/index.yaml) || EXIT_CODE=$? | ||
if [ $EXIT_CODE != 0 ]; then | ||
echo WARNING: upgrade addon $chart is defined, but the chart is not packed into repo / repo struct is changed | ||
continue | ||
Comment on lines
+194
to
+195
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. same here |
||
fi | ||
|
||
# some charts are not packed into arm64 ISO, the above yq will return `null` | ||
if [[ $repover == "null" ]] && [[ ${ARCH} == "arm64" ]]; then | ||
echo WARNING: upgrade addon "$chart" is defined with version "$version" but the chart is not packed into repo in ${ARCH} | ||
elif [[ $repover != $version ]]; then | ||
# the upgrade addon is stored in GH harvester; but the chart repo is stored in GH harvester-installer | ||
# a new version bumping generally means two PRs | ||
# directly return 1 will cause failure in build | ||
echo WARNING upgrade addon "$chart" has version mis-matching: in repo is "$repover" but in addon is "$version" | ||
Comment on lines
+200
to
+205
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. same here |
||
fi | ||
done | ||
|
||
echo "all upgrade addons have matched version with the repo" | ||
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're not failing the build on mismatches per #750 (comment), this line will always be printed. Better to either print a count of mismatches, or maybe just not print this line at all, e.g.: @@ -180,6 +180,7 @@ check_upgrade_addon_chart_version_matching() {
echo "upgrade addon files"
ls -alht ${harvester_path}/package/upgrade/addons
+ local mismatches=0
for filename in ${harvester_path}/package/upgrade/addons/*.yaml; do
local tmpfile=/tmp/$(basename ${filename})
grep -v "{{" ${filename} > ${tmpfile}
@@ -203,10 +204,13 @@ check_upgrade_addon_chart_version_matching() {
# a new version bumping generally means two PRs
# directly return 1 will cause failure in build
echo WARNING upgrade addon "$chart" has version mis-matching: in repo is "$repover" but in addon is "$version"
+ (( mismatches +=1 ))
fi
done
- echo "all upgrade addons have matched version with the repo"
+ if [[ $mismatches -eq 0 ]]; then
+ echo "all upgrade addons have matched version with the repo"
+ fi
}
check_upgrade_addon_chart_version_matching |
||
} | ||
|
||
check_upgrade_addon_chart_version_matching | ||
|
||
# Use offline bundle cache | ||
if [ -n "$HARVESTER_INSTALLER_OFFLINE_BUILD" -a -e /bundle ]; then | ||
cp -rf /bundle/* ${BUNDLE_DIR}/ | ||
|
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.
nit: the indention is 1 space instead of 2spaces.