From c16f6b524c53216559733b79453085842e4706e3 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:43:34 +0300 Subject: [PATCH 1/4] update logging of K3s --- azure_jumpstart_arcbox/artifacts/installK3s.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/installK3s.sh b/azure_jumpstart_arcbox/artifacts/installK3s.sh index df38800f35..f3fa99b325 100644 --- a/azure_jumpstart_arcbox/artifacts/installK3s.sh +++ b/azure_jumpstart_arcbox/artifacts/installK3s.sh @@ -1,7 +1,4 @@ #!/bin/bash -exec >installK3s.log -exec 2>&1 - sudo apt-get update sudo sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/" /etc/ssh/sshd_config @@ -20,7 +17,6 @@ echo $templateBaseUrl:$7 | awk '{print substr($1,2); }' >> vars.sh echo $storageContainerName:$8 | awk '{print substr($1,2); }' >> vars.sh echo $k3sControlPlane:$9 | awk '{print substr($1,2); }' >> vars.sh - sed -i '2s/^/export adminUsername=/' vars.sh sed -i '3s/^/export subscriptionId=/' vars.sh sed -i '4s/^/export vmName=/' vars.sh @@ -31,6 +27,11 @@ sed -i '8s/^/export templateBaseUrl=/' vars.sh sed -i '9s/^/export storageContainerName=/' vars.sh sed -i '10s/^/export k3sControlPlane=/' vars.sh +export vmName=$3 + +exec >installK3s-${vmName}.log +exec 2>&1 + # Set k3 deployment variables export K3S_VERSION="1.29.6+k3s2" # Do not change! @@ -42,7 +43,7 @@ sudo curl -v -o /etc/profile.d/welcomeK3s.sh ${templateBaseUrl}artifacts/welcome # Syncing this script log to 'jumpstart_logs' directory for ease of troubleshooting sudo -u $adminUsername mkdir -p /home/${adminUsername}/jumpstart_logs -while sleep 1; do sudo -s rsync -a /var/lib/waagent/custom-script/download/0/installK3s.log /home/${adminUsername}/jumpstart_logs/installK3s.log; done & +while sleep 1; do sudo -s rsync -a /var/lib/waagent/custom-script/download/0/installK3s-$vmName.log /home/${adminUsername}/jumpstart_logs/installK3s-$vmName.log; done & # Downloading azcopy echo "" @@ -189,7 +190,7 @@ else echo "ERROR: Failed to add k3s worker nodes" exit 1 fi - + sudo service sshd restart fi @@ -197,7 +198,6 @@ fi echo "" echo "Uploading the script logs to staging storage" echo "" -# Authorize azcopy by using a system-wide managed identity -log="/home/$adminUsername/jumpstart_logs/installK3s.log" +log="/home/$adminUsername/jumpstart_logs/installK3s-$vmName.log" storageContainerNameLower=$(echo $storageContainerName | tr '[:upper:]' '[:lower:]') azcopy cp $log "https://$stagingStorageAccountName.blob.core.windows.net/$storageContainerNameLower/installK3s-$vmName.log" \ No newline at end of file From d47718adc13063a6d48b7ef92ef33ad6f88976da Mon Sep 17 00:00:00 2001 From: Zaid Mohammad Date: Tue, 6 Aug 2024 11:49:28 -0400 Subject: [PATCH 2/4] add error handling --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 87f1860e77..1ca3a7423e 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -378,8 +378,13 @@ $clusters | Foreach-Object -ThrottleLimit 5 -Parallel { Start-Sleep -Seconds 10 - az customlocation create --name $customLocation --resource-group $Env:resourceGroup --namespace arc --host-resource-id $connectedClusterId --cluster-extension-ids $extensionId --only-show-errors - + try { + az customlocation create --name $customLocation --resource-group $Env:resourceGroup --namespace arc --host-resource-id $connectedClusterId --cluster-extension-ids $extensionId + } catch { + Write-Host "Error creating custom location: $_" + Exit + } + Start-Sleep -Seconds 10 # Deploying the Azure Arc Data Controller From 6ec5c5ea9692b975973dbd7ebd5e9a060612c178 Mon Sep 17 00:00:00 2001 From: Zaid Mohammad Date: Tue, 6 Aug 2024 12:10:31 -0400 Subject: [PATCH 3/4] add error handling --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 1ca3a7423e..971e8bb346 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -379,7 +379,7 @@ $clusters | Foreach-Object -ThrottleLimit 5 -Parallel { Start-Sleep -Seconds 10 try { - az customlocation create --name $customLocation --resource-group $Env:resourceGroup --namespace arc --host-resource-id $connectedClusterId --cluster-extension-ids $extensionId + az customlocation create --name $customLocation --resource-group $Env:resourceGroup --namespace arc --host-resource-id $connectedClusterId --cluster-extension-ids $extensionId --only-show-errors } catch { Write-Host "Error creating custom location: $_" Exit From 4419874fac90af57f979dd407c13ee16e86fba0a Mon Sep 17 00:00:00 2001 From: Zaid Mohammad Date: Tue, 6 Aug 2024 13:19:55 -0400 Subject: [PATCH 4/4] update error handling --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 971e8bb346..cda7204a2b 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -381,8 +381,8 @@ $clusters | Foreach-Object -ThrottleLimit 5 -Parallel { try { az customlocation create --name $customLocation --resource-group $Env:resourceGroup --namespace arc --host-resource-id $connectedClusterId --cluster-extension-ids $extensionId --only-show-errors } catch { - Write-Host "Error creating custom location: $_" - Exit + Write-Host "Error creating custom location: $_" -ForegroundColor Red + Exit 1 } Start-Sleep -Seconds 10