Merge pull request #37 from Heavybullets8/hot-patch2

Hot patch2
This commit is contained in:
Heavybullets8 2022-12-26 21:49:14 +00:00 committed by GitHub
commit 057b98f1d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 1 deletions

View File

@ -14,6 +14,7 @@ echo "5) Update HeavyScript"
echo "6) Update Applications" echo "6) Update Applications"
echo "7) Command to Container" echo "7) Command to Container"
echo "8) Patch 22.12.0" echo "8) Patch 22.12.0"
echo "9) Patch 22.12.0 (2)"
echo echo
echo "0) Exit" echo "0) Exit"
read -rt 120 -p "Please select an option by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } read -rt 120 -p "Please select an option by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; }
@ -83,6 +84,9 @@ case $selection in
8) 8)
patch_2212_backups patch_2212_backups
;; ;;
9)
patch_2212_backups2
;;
*) *)
echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu
;; ;;

View File

@ -173,3 +173,61 @@ do
done done
} }
patch_2212_backups2(){
clear -x
#Check TrueNAS version, skip if not 22.12.0
if ! [ "$(cli -m csv -c 'system version' | awk -F '-' '{print $3}')" == "22.12.0" ]; then
echo "This patch does not apply to your version of TrueNAS"
return
fi
#Description
echo "This patch will fix the issue certain applicattions breaking backups"
echo "You only need to run this patch once, it will not run again"
echo
# Apply patch
echo "Applying Backup Patch"
if patch -N --reject-file=/dev/null -s -p0 /usr/lib/python3/dist-packages/middlewared/plugins/kubernetes_linux/backup.py < patches/backups.patch &>/dev/null; then
echo "Backup Patch applied"
else
echo "Backup Patch already applied"
exit
fi
echo
#Restart middlewared
while true
do
echo "We need to restart middlewared to finish the patch"
echo "This will cause a short downtime for some minor services approximately 10-30 seconds"
echo "Applications should not be affected"
read -rt 120 -p "Would you like to proceed? (y/N): " yesno || { echo -e "\nFailed to make a selection in time" ; exit; }
case $yesno in
[Yy] | [Yy][Ee][Ss])
echo "Restarting middlewared"
service middlewared restart &
wait $!
echo "Restarted middlewared"
echo "You are set, there is no need to run this patch again"
break
;;
[Nn] | [Nn][Oo])
echo "Exiting"
echo "Please restart middlewared manually"
echo "You can do: service middlewared restart"
exit
;;
*)
echo "That was not an option, try again"
sleep 3
continue
;;
esac
done
}

11
patches/backups.patch Normal file
View File

@ -0,0 +1,11 @@
--- /usr/lib/python3/dist-packages/middlewared/plugins/kubernetes_linux/backup.py 2022-12-13 05:32:23.000000000 -0700
+++ backups.patch 2022-12-26 14:14:25.075037767 -0700
@@ -61,7 +61,8 @@
['metadata.namespace', '=', chart_release['namespace']]
]
)
- for secret in sorted(secrets, key=lambda d: d['metadata']['name']):
+ # We ignore this keeping in line with helm behaviour where the secret malformed is ignored by helm
+ for secret in sorted(filter(lambda d: d.get('data'), secrets), key=lambda d: d['metadata']['name']):
with open(os.path.join(secrets_dir, secret['metadata']['name']), 'w') as f:
f.write(self.middleware.call_sync('k8s.secret.export_to_yaml_internal', secret))