diff --git a/build/windows/Makefile.ps1 b/build/windows/Makefile.ps1 index 9f3c438b0..52abbb071 100644 --- a/build/windows/Makefile.ps1 +++ b/build/windows/Makefile.ps1 @@ -13,21 +13,21 @@ Write-Host("current script dir : " + $currentdir + " ") if ($false -eq (Test-Path -Path $currentdir)) { Write-Host("Invalid current dir : " + $currentdir + " ") -ForegroundColor Red - exit + exit 1 } $builddir = Split-Path -Path $currentdir Write-Host("builddir dir : " + $builddir + " ") if ($false -eq (Test-Path -Path $builddir)) { Write-Host("Invalid build dir : " + $builddir + " ") -ForegroundColor Red - exit + exit 1 } $versionFilePath = Join-Path -Path $builddir -child "version" Write-Host("versionFilePath : " + $versionFilePath + " ") if ($false -eq (Test-Path -Path $versionFilePath)) { Write-Host("Version file path incorrect or doesnt exist : " + $versionFilePath + " ") -ForegroundColor Red - exit + exit 1 } # read the version info @@ -36,7 +36,7 @@ foreach($line in Get-Content -Path $versionFilePath) { $parts = $line.split("=") if ($parts.length -lt 2 ) { Write-Host("Invalid content in version file : " + $versionFilePath + " ") -ForegroundColor Red - exit + exit 1 } switch ($parts[0]) { "CONTAINER_BUILDVERSION_MAJOR" { $BuildVersionMajor = $parts[1] } @@ -57,7 +57,7 @@ if ([string]::IsNullOrEmpty($BuildVersionMajor) -or [string]::IsNullOrEmpty($BuildVersionDate) -or [string]::IsNullOrEmpty($BuildVersionStatus)) { Write-Host("Expected version info doesnt exist in this version file : " + $versionFilePath + " ") -ForegroundColor Red - exit + exit 1 } # build version format will be [major].[minior].[patch]-[revision] $buildVersionString = $BuildVersionMajor + "." + $BuildVersionMinor + "." + $BuildVersionPatch + "-" + $BuildVersionBuildNR @@ -68,7 +68,7 @@ $certsrcdir = Join-Path -Path $builddir -ChildPath "windows\installer\certificat Write-Host("certsrc dir : " + $certsrcdir + " ") if ($false -eq (Test-Path -Path $certsrcdir)) { Write-Host("Invalid certificate generator source dir : " + $certsrcdir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host("set the cerificate generator source code directory : " + $certsrcdir + " ...") Set-Location -Path $certsrcdir @@ -100,13 +100,13 @@ Write-Host("Successfully published certificate generator code binaries") -Foregr $certreleasebinpath = Join-Path -PATH $certsrcdir -ChildPath "bin\Release\$dotnetcoreframework\win10-x64\publish\*.*" if ($false -eq (Test-Path -Path $certreleasebinpath)) { Write-Host("certificate release bin path doesnt exist : " + $certreleasebinpath + " ") -ForegroundColor Red - exit + exit 1 } $rootdir = Split-Path -Path $builddir if ($false -eq (Test-Path -Path $rootdir)) { Write-Host("Invalid docker provider root source dir : " + $rootdir + " ") -ForegroundColor Red - exit + exit 1 } $publishdir = Join-Path -Path $rootdir -ChildPath "kubernetes\windows\omsagentwindows" @@ -128,7 +128,7 @@ $outomsgoplugindir = Join-Path -Path $rootdir -ChildPath "source\plugins\go\src" Write-Host("Building Out_OMS go plugin code...") if ($false -eq (Test-Path -Path $outomsgoplugindir)) { Write-Host("Invalid Out oms go plugin code dir : " + $outomsgoplugindir + " ") -ForegroundColor Red - exit + exit 1 } Set-Location -Path $outomsgoplugindir @@ -178,7 +178,7 @@ if (Test-Path -Path $livenessprobeexepath){ Write-Host("livenessprobe.exe exists which indicates cpp build step succeeded") -ForegroundColor Green } else { Write-Host("livenessprobe.exe doesnt exist which indicates cpp build step failed") -ForegroundColor Red - exit + exit 1 } $installerdir = Join-Path -Path $builddir -ChildPath "common\installer" diff --git a/kubernetes/windows/dockerbuild/build-and-publish-dev-docker-image.ps1 b/kubernetes/windows/dockerbuild/build-and-publish-dev-docker-image.ps1 index 0fde7f379..b87132218 100644 --- a/kubernetes/windows/dockerbuild/build-and-publish-dev-docker-image.ps1 +++ b/kubernetes/windows/dockerbuild/build-and-publish-dev-docker-image.ps1 @@ -15,18 +15,18 @@ Write-Host("current script dir : " + $currentdir + " ") if ($false -eq (Test-Path -Path $currentdir)) { Write-Host("Invalid current dir : " + $currentdir + " ") -ForegroundColor Red - exit + exit 1 } if ([string]::IsNullOrEmpty($image)) { Write-Host "Image parameter shouldnt be null or empty" -ForegroundColor Red - exit + exit 1 } $imageparts = $image.split(":") if (($imageparts.Length -ne 2)){ Write-Host "Image not in valid format. Expected format should be /:" -ForegroundColor Red - exit + exit 1 } $imagetag = $imageparts[1].ToLower() @@ -48,7 +48,7 @@ $dockerFileDir = Split-Path -Path $currentdir Write-Host("builddir dir : " + $dockerFileDir + " ") if ($false -eq (Test-Path -Path $dockerFileDir)) { Write-Host("Invalid dockerFile Dir : " + $dockerFileDir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host "changing directory to DockerFile dir: $dockerFileDir" diff --git a/kubernetes/windows/dockerbuild/build-and-publish-docker-image.ps1 b/kubernetes/windows/dockerbuild/build-and-publish-docker-image.ps1 index dbcfa6097..c1f655882 100644 --- a/kubernetes/windows/dockerbuild/build-and-publish-docker-image.ps1 +++ b/kubernetes/windows/dockerbuild/build-and-publish-docker-image.ps1 @@ -15,18 +15,18 @@ Write-Host("current script dir : " + $currentdir + " ") if ($false -eq (Test-Path -Path $currentdir)) { Write-Host("Invalid current dir : " + $currentdir + " ") -ForegroundColor Red - exit + exit 1 } if ([string]::IsNullOrEmpty($image)) { Write-Host "Image parameter shouldnt be null or empty" -ForegroundColor Red - exit + exit 1 } $imageparts = $image.split(":") if (($imageparts.Length -ne 2)){ Write-Host "Image not in valid format. Expected format should be /:" -ForegroundColor Red - exit + exit 1 } $imagetag = $imageparts[1].ToLower() @@ -48,7 +48,7 @@ $dockerFileDir = Split-Path -Path $currentdir Write-Host("builddir dir : " + $dockerFileDir + " ") if ($false -eq (Test-Path -Path $dockerFileDir)) { Write-Host("Invalid dockerFile Dir : " + $dockerFileDir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host "changing directory to DockerFile dir: $dockerFileDir" diff --git a/kubernetes/windows/dockerbuild/build-dev-base-image.ps1 b/kubernetes/windows/dockerbuild/build-dev-base-image.ps1 index 142e20c3f..4b17239d2 100644 --- a/kubernetes/windows/dockerbuild/build-dev-base-image.ps1 +++ b/kubernetes/windows/dockerbuild/build-dev-base-image.ps1 @@ -1,6 +1,6 @@ <# .DESCRIPTION - Builds the Docker Image locally for the server core ltsc base and installs dependencies + Builds the Docker Image locally for the server core ltsc base and installs dependencies #> @@ -9,7 +9,7 @@ Write-Host("current script dir : " + $currentdir + " ") if ($false -eq (Test-Path -Path $currentdir)) { Write-Host("Invalid current dir : " + $currentdir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host "start:Building the cert generator and out oms code via Makefile.ps1" @@ -20,7 +20,7 @@ $dockerFileDir = Split-Path -Path $currentdir Write-Host("builddir dir : " + $dockerFileDir + " ") if ($false -eq (Test-Path -Path $dockerFileDir)) { Write-Host("Invalid dockerFile Dir : " + $dockerFileDir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host "changing directory to DockerFile dir: $dockerFileDir" diff --git a/scripts/build/windows/install-build-pre-requisites.ps1 b/scripts/build/windows/install-build-pre-requisites.ps1 index 7f1c9b54f..1ea316798 100755 --- a/scripts/build/windows/install-build-pre-requisites.ps1 +++ b/scripts/build/windows/install-build-pre-requisites.ps1 @@ -2,7 +2,7 @@ function Install-Go { $tempDir = $env:TEMP if ($false -eq (Test-Path -Path $tempDir)) { Write-Host("Invalid TEMP dir PATH : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $tempGo = Join-Path -Path $tempDir -ChildPath "gotemp" @@ -10,7 +10,7 @@ function Install-Go { New-Item -Path $tempGo -ItemType "directory" -Force -ErrorAction Stop if ($false -eq (Test-Path -Path $tempGo)) { Write-Host("Invalid tempGo : " + $tempGo + " ") -ForegroundColor Red - exit + exit 1 } $url = "https://dl.google.com/go/go1.15.14.windows-amd64.msi" @@ -35,7 +35,7 @@ function Build-Dependencies { $tempDir = $env:TEMP if ($false -eq (Test-Path -Path $tempDir)) { Write-Host("Invalid TEMP dir PATH : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $tempDependencies = Join-Path -Path $tempDir -ChildPath "gcctemp" @@ -43,7 +43,7 @@ function Build-Dependencies { New-Item -Path $tempDependencies -ItemType "directory" -Force -ErrorAction Stop if ($false -eq (Test-Path -Path $tempDependencies)) { Write-Host("Invalid temp Dir : " + $tempDependencies + " ") -ForegroundColor Red - exit + exit 1 } @@ -82,7 +82,7 @@ function Install-DotNetCoreSDK() { $tempDir = $env:TEMP if ($false -eq (Test-Path -Path $tempDir)) { Write-Host("Invalid TEMP dir : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $dotNetSdkTemp = Join-Path -Path $tempDir -ChildPath "dotNetSdk" @@ -90,7 +90,7 @@ function Install-DotNetCoreSDK() { New-Item -Path $dotNetSdkTemp -ItemType "directory" -Force -ErrorAction Stop if ($false -eq (Test-Path -Path $dotNetSdkTemp)) { Write-Host("Invalid dotNetSdkTemp : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $url = "https://download.visualstudio.microsoft.com/download/pr/4e88f517-196e-4b17-a40c-2692c689661d/eed3f5fca28262f764d8b650585a7278/dotnet-sdk-3.1.301-win-x64.exe" @@ -110,7 +110,7 @@ function Install-Docker() { $tempDir = $env:TEMP if ($false -eq (Test-Path -Path $tempDir)) { Write-Host("Invalid TEMP dir PATH : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $dockerTemp = Join-Path -Path $tempDir -ChildPath "docker" @@ -118,7 +118,7 @@ function Install-Docker() { New-Item -Path $dockerTemp -ItemType "directory" -Force -ErrorAction Stop if ($false -eq (Test-Path -Path $dockerTemp)) { Write-Host("Invalid dockerTemp : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $url = "https://download.docker.com/win/stable/Docker%20Desktop%20Installer.exe" diff --git a/scripts/onboarding/aks/mdmonboarding/mdm_onboarding.ps1 b/scripts/onboarding/aks/mdmonboarding/mdm_onboarding.ps1 index dcf73f098..a5d95c31e 100644 --- a/scripts/onboarding/aks/mdmonboarding/mdm_onboarding.ps1 +++ b/scripts/onboarding/aks/mdmonboarding/mdm_onboarding.ps1 @@ -39,7 +39,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az else { Write-Host("Please run the script as an administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } @@ -66,7 +66,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -77,7 +77,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -88,7 +88,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Aks in a new powershell window: eg. 'Install-Module Az.Aks -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -103,7 +103,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -114,7 +114,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAksModule) { @@ -124,7 +124,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az catch { Write-Host("Could not import Az.Aks... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -132,7 +132,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -161,7 +161,7 @@ if ($account.Account -eq $null) { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -181,7 +181,7 @@ else { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -196,7 +196,7 @@ if ($notPresent) { Write-Host("Could not find Aks cluster. Please make sure that specified cluster exists: '" + $clusterName + "'is correct and you have access to the cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully checked specified cluster exists details...") -ForegroundColor Green diff --git a/scripts/onboarding/aks/mdmonboarding/mdm_onboarding_atscale.ps1 b/scripts/onboarding/aks/mdmonboarding/mdm_onboarding_atscale.ps1 index a791bb18e..32311ca61 100644 --- a/scripts/onboarding/aks/mdmonboarding/mdm_onboarding_atscale.ps1 +++ b/scripts/onboarding/aks/mdmonboarding/mdm_onboarding_atscale.ps1 @@ -30,7 +30,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ else { Write-Host("Please run the script as an administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } @@ -57,7 +57,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -68,7 +68,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -79,7 +79,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Aks in a new powershell window: eg. 'Install-Module Az.Aks -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -94,7 +94,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -105,7 +105,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAksModule) { @@ -115,7 +115,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ catch { Write-Host("Could not import Az.Aks... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -123,7 +123,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -152,7 +152,7 @@ if ($account.Account -eq $null) { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -172,7 +172,7 @@ else { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -187,7 +187,7 @@ if ($notPresent) { Write-Host("Failed to get Aks clusters in specified subscription. Please make sure that you have access to the existing clusters") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully got all aks clusters ...") -ForegroundColor Green diff --git a/scripts/onboarding/aksengine/kubernetes/AddMonitoringWorkspaceTags.ps1 b/scripts/onboarding/aksengine/kubernetes/AddMonitoringWorkspaceTags.ps1 index 29f629878..a0965f960 100644 --- a/scripts/onboarding/aksengine/kubernetes/AddMonitoringWorkspaceTags.ps1 +++ b/scripts/onboarding/aksengine/kubernetes/AddMonitoringWorkspaceTags.ps1 @@ -64,7 +64,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { else { Write-Host("Please run the script as an administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -89,7 +89,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } try { Write-Host("Installing Az.Accounts...") @@ -97,7 +97,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -109,7 +109,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { Write-Host("Could not import Az.Resources ...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } try { Import-Module Az.Accounts @@ -117,14 +117,14 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { catch { Write-Host("Could not import Az.Accounts... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -138,7 +138,7 @@ if ($NameoftheCloud -like "AzureCloud" -or } else { Write-Host("Error: Monitoring not supported in this cloud: $NameoftheCloud") -ForegroundColor Red - exit + exit 1 } # @@ -151,7 +151,7 @@ if ($notPresent) { Write-Host("Could not find RG. Please make sure that the resource group name: '" + $ResourceGroupName + "'is correct and you have access to the aks-engine cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully checked resource groups details...") -ForegroundColor Green @@ -179,20 +179,20 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { } else { Write-Host("Resource group name: '" + $ResourceGroupName + "'is doesnt have the aks-engine resources") -ForegroundColor Red - exit + exit 1 } } if ($isKubernetesCluster -eq $false) { Write-Host("Resource group name: '" + $ResourceGroupName + "' doesnt have the aks-engine or acs-engine resources") -ForegroundColor Red - exit + exit 1 } # validate specified logAnalytics workspace exists or not $workspaceResource = Get-AzResource -ResourceId $LogAnalyticsWorkspaceResourceId if ($null -eq $workspaceResource) { Write-Host("Specified Log Analytics workspace ResourceId: '" + $LogAnalyticsWorkspaceResourceId + "' doesnt exist or don't have access to it") -ForegroundColor Red - exit + exit 1 } # @@ -202,11 +202,11 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { $r = Get-AzResource -ResourceGroupName $ResourceGroupName -ResourceName $k8MasterVM.Name if ($null -eq $r) { Write-Host("Get-AzResource for Resource Group: " + $ResourceGroupName + "Resource Name :" + $k8MasterVM.Name + " failed" ) -ForegroundColor Red - exit + exit 1 } if ($null -eq $r.Tags) { Write-Host("K8s master VM should have the tags" ) -ForegroundColor Red - exit + exit 1 } if ($r.Tags.ContainsKey("logAnalyticsWorkspaceResourceId")) { $existingLogAnalyticsWorkspaceResourceId = $r.Tags["logAnalyticsWorkspaceResourceId"] @@ -225,7 +225,7 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { $existingclusterName = $r.Tags["clusterName"] if ($existingclusterName -eq $ClusterName) { Write-Host("Ignoring attaching clusterName tag to K8s master VM :" + $k8MasterVM.Name + " since it has already with same tag value" ) -ForegroundColor Yellow - exit + exit 1 } Write-Host("K8s master VM :" + $k8MasterVM.Name + " has the existing tag for clusterName with different from specified one" ) -ForegroundColor Green $r.Tags.Remove("clusterName") diff --git a/scripts/onboarding/managed/disable-monitoring.ps1 b/scripts/onboarding/managed/disable-monitoring.ps1 index bcd135dba..8be60c50d 100644 --- a/scripts/onboarding/managed/disable-monitoring.ps1 +++ b/scripts/onboarding/managed/disable-monitoring.ps1 @@ -61,7 +61,7 @@ if ([string]::IsNullOrEmpty($azureCloudName) -eq $true) { } else { Write-Host("Specified Azure Cloud name is : $azureCloudName") Write-Host("Only supported Azure clouds are : AzureCloud and AzureUSGovernment") - exit + exit 1 } } @@ -89,7 +89,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - else { Write-Host("Please re-launch the script with elevated administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -116,7 +116,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -127,7 +127,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -139,7 +139,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.OperationalInsights in a new powershell window: eg. 'Install-Module Az.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -154,7 +154,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -165,7 +165,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -176,7 +176,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Could not import Az.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -184,14 +184,14 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } if ([string]::IsNullOrEmpty($clusterResourceId)) { Write-Host("Specified Azure ClusterResourceId should not be NULL or empty") -ForegroundColor Red - exit + exit 1 } if ([string]::IsNullOrEmpty($kubeContext)) { @@ -211,7 +211,7 @@ if ($clusterResourceId.StartsWith("/") -eq $false) { if ($clusterResourceId.Split("/").Length -ne 9){ Write-Host("Provided Cluster Resource Id is not in expected format") -ForegroundColor Red - exit + exit 1 } if (($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedclusters") -ne $true) -and @@ -219,7 +219,7 @@ if (($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedcluste ($clusterResourceId.ToLower().Contains("microsoft.containerservice/managedclusters") -ne $true) ) { Write-Host("Provided cluster ResourceId is not supported cluster type: $clusterResourceId") -ForegroundColor Red - exit + exit 1 } if ($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedclusters") -eq $true) { @@ -284,7 +284,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $clusterSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -304,7 +304,7 @@ else { Write-Host("Could not select subscription with ID : " + $clusterSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -314,7 +314,7 @@ Write-Host("Checking specified Azure Managed cluster resource exists and got acc $clusterResource = Get-AzResource -ResourceId $clusterResourceId if ($null -eq $clusterResource) { Write-Host("specified Azure Managed cluster resource id either you dont have access or doesnt exist") -ForegroundColor Red - exit + exit 1 } $clusterRegion = $clusterResource.Location.ToLower() @@ -323,7 +323,7 @@ if ($isArcK8sCluster -eq $true) { $clusterIdentity = $clusterResource.identity.type.ToString().ToLower() if ($clusterIdentity.Contains("systemassigned") -eq $false) { Write-Host("Identity of Azure Arc enabled Kubernetes cluster should be systemassigned but it has identity: $clusterIdentity") -ForegroundColor Red - exit + exit 1 } } @@ -345,7 +345,7 @@ try { $releases = helm list --filter $helmChartReleaseName if ($releases.Count -lt 2) { Write-Host("There is no existing release with name : $helmChartReleaseName") -ForegroundColor Yellow - exit + exit 1 } for($index =0 ; $index -lt $releases.Count ; $index ++ ) { @@ -360,7 +360,7 @@ try { $releases = helm list --filter $helmChartReleaseName --kube-context $kubeContext if ($releases.Count -lt 2) { Write-Host("There is no existing release with name : $helmChartReleaseName") -ForegroundColor Yellow - exit + exit 1 } for($index =0 ; $index -lt $releases.Count ; $index ++ ) { @@ -374,7 +374,7 @@ try { } catch { Write-Host ("Failed to delete Azure Monitor for containers HELM chart : '" + $Error[0] + "' ") -ForegroundColor Red - exit + exit 1 } Write-Host("Successfully disabled Azure Monitor for containers for cluster: $clusteResourceId") -ForegroundColor Green diff --git a/scripts/onboarding/managed/enable-monitoring.ps1 b/scripts/onboarding/managed/enable-monitoring.ps1 index e79ef2138..27bc2fd62 100644 --- a/scripts/onboarding/managed/enable-monitoring.ps1 +++ b/scripts/onboarding/managed/enable-monitoring.ps1 @@ -81,7 +81,7 @@ if ([string]::IsNullOrEmpty($azureCloudName) -eq $true) { } else { Write-Host("Specified Azure Cloud name is : $azureCloudName") Write-Host("Only supported azure clouds are : AzureCloud and AzureUSGovernment") - exit + exit 1 } } @@ -109,7 +109,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - else { Write-Host("Please re-launch the script with elevated administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -136,7 +136,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -147,7 +147,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -159,7 +159,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.OperationalInsights in a new powershell window: eg. 'Install-Module Az.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -174,7 +174,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -185,7 +185,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -196,7 +196,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Could not import Az.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -204,14 +204,14 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } if ([string]::IsNullOrEmpty($clusterResourceId)) { Write-Host("Specified Azure Arc enabled Kubernetes ClusterResourceId should not be NULL or empty") -ForegroundColor Red - exit + exit 1 } if ([string]::IsNullOrEmpty($kubeContext)) { @@ -232,7 +232,7 @@ if ($clusterResourceId.StartsWith("/") -eq $false) { if ($clusterResourceId.Split("/").Length -ne 9) { Write-Host("Provided Cluster Resource Id is not in expected format") -ForegroundColor Red - exit + exit 1 } if (($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedclusters") -ne $true) -and @@ -240,7 +240,7 @@ if (($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedcluste ($clusterResourceId.ToLower().Contains("microsoft.containerservice/managedclusters") -ne $true) ) { Write-Host("Provided cluster ResourceId is not supported cluster type: $clusterResourceId") -ForegroundColor Red - exit + exit 1 } if (([string]::IsNullOrEmpty($servicePrincipalClientId) -eq $false) -and @@ -305,7 +305,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $clusterSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -325,7 +325,7 @@ else { Write-Host("Could not select subscription with ID : " + $clusterSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -335,7 +335,7 @@ Write-Host("Checking specified Azure Managed cluster resource exists and got acc $clusterResource = Get-AzResource -ResourceId $clusterResourceId if ($null -eq $clusterResource) { Write-Host("specified Azure Managed cluster resource id either you dont have access or doesnt exist") -ForegroundColor Red - exit + exit 1 } $clusterRegion = $clusterResource.Location.ToLower() @@ -344,7 +344,7 @@ if ($isArcK8sCluster -eq $true) { $clusterIdentity = $clusterResource.identity.type.ToString().ToLower() if ($clusterIdentity.contains("systemassigned") -eq $false) { Write-Host("Identity of Azure Arc enabled Kubernetes cluster should be systemassigned but it has identity: $clusterIdentity") -ForegroundColor Red - exit + exit 1 } } @@ -450,7 +450,7 @@ else { Write-Host("using specified Log Analytics Workspace ResourceId: '" + $workspaceResourceId + "' ") if ([string]::IsNullOrEmpty($workspaceResourceId)) { Write-Host("Specified workspaceResourceId should not be NULL or empty") -ForegroundColor Red - exit + exit 1 } $workspaceResourceId = $workspaceResourceId.Trim() if ($workspaceResourceId.EndsWith("/")) { @@ -465,7 +465,7 @@ else { if (($workspaceResourceId.ToLower().Contains("microsoft.operationalinsights/workspaces") -ne $true) -or ($workspaceResourceId.Split("/").Length -ne 9)) { Write-Host("Provided workspace resource id should be in this format /subscriptions//resourceGroups//providers/Microsoft.OperationalInsights/workspaces/") -ForegroundColor Red - exit + exit 1 } $workspaceResourceParts = $workspaceResourceId.Split("/") @@ -482,7 +482,7 @@ else { $WorkspaceInformation = Get-AzOperationalInsightsWorkspace -ResourceGroupName $workspaceResourceGroup -Name $workspaceName -ErrorAction SilentlyContinue if ($null -eq $WorkspaceInformation) { Write-Host("Specified Log Analytics Workspace: '" + $workspaceName + "' in Resource Group: '" + $workspaceResourceGroup + "' in Subscription: '" + $workspaceSubscriptionId + "' does not exist") -ForegroundColor Red - exit + exit 1 } } @@ -520,7 +520,7 @@ try { } catch { Write-Host ("Failed to workspace details. Please validate whether you have Log Analytics Contributor role on the workspace error: '" + $Error[0] + "' ") -ForegroundColor Red - exit + exit 1 } diff --git a/scripts/troubleshoot/TroubleshootError.ps1 b/scripts/troubleshoot/TroubleshootError.ps1 index 4c2d95ac6..6d97c53d5 100644 --- a/scripts/troubleshoot/TroubleshootError.ps1 +++ b/scripts/troubleshoot/TroubleshootError.ps1 @@ -35,7 +35,7 @@ if (($null -eq $ClusterResourceId) -or ($ClusterResourceId.Split("/").Length -ne Write-Host("Resource Id Format for AKS cluster is : /subscriptions//resourceGroups//providers/Microsoft.ContainerService/managedClusters/") -ForegroundColor Red Write-Host("Resource Id Format for ARO cluster is : /subscriptions//resourceGroups//providers/Microsoft.ContainerService/openShiftManagedClusters/") -ForegroundColor Red Stop-Transcript - exit + exit 1 } $isClusterAndWorkspaceInDifferentSubs = $false @@ -70,7 +70,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco else { Write-Host("Please re-launch the script with elevated administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -97,7 +97,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.ResourceGraph in a new powershell window: eg. 'Install-Module Az.ResourceGraph -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAksModule) { @@ -108,7 +108,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Aks in a new powershell window: eg. 'Install-Module Az.Aks -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -120,7 +120,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -132,7 +132,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -145,7 +145,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.OperationalInsights in a new powershell window: eg. 'Install-Module Az.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -159,7 +159,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco Write-Host("Could not Import Az.ResourceGraph...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.ResourceGraph in a new powershell window: eg. 'Install-Module Az.ResourceGraph -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -171,7 +171,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco Write-Host("Could not Import Az.Aks...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Aks in a new powershell window: eg. 'Install-Module Az.Aks -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -183,7 +183,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -194,7 +194,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -205,7 +205,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Could not import Az.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -213,7 +213,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -277,7 +277,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $ClusterSubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the Subscription" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -297,7 +297,7 @@ else { Write-Host("Could not select subscription with ID : " + $ClusterSubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the Subscription" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -313,7 +313,7 @@ if ($notPresent) { Write-Host("Could not find RG. Please make sure that the resource group name: '" + $ResourceGroupName + "'is correct and you have access to the Resource Group") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully checked resource groups details...") -ForegroundColor Green @@ -327,7 +327,7 @@ try { Write-Host("Could not fetch cluster details: Please make sure that the '" + $ClusterType + "' Cluster name: '" + $ClusterName + "' is correct and you have access to the cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } else { Write-Host("Successfully checked '" + $ClusterType + "' Cluster details...") -ForegroundColor Green @@ -342,7 +342,7 @@ try { Write-Host($AksOptInLink) -ForegroundColor Red; Write-Host(""); Stop-Transcript - exit + exit 1 } $omsagentconfig = $props.addonprofiles.omsagent.config; @@ -364,7 +364,7 @@ try { Write-Host("Could not fetch cluster details: Please make sure that the '" + $ClusterType + "' Cluster name: '" + $ClusterName + "' is correct and you have access to the cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $monitorProfile = $ResourceDetail.aroproperties.monitorprofile @@ -373,7 +373,7 @@ try { Write-Host($AksOptInLink) -ForegroundColor Red; Write-Host(""); Stop-Transcript - exit + exit 1 } $LogAnalyticsWorkspaceResourceID = $monitorProfile.workspaceresourceid @@ -385,7 +385,7 @@ catch { Write-Host("Could not fetch cluster details: Please make sure that the '" + $ClusterType + "' Cluster name: '" + $ClusterName + "' is correct and you have access to the cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } @@ -511,7 +511,7 @@ if ($null -eq $LogAnalyticsWorkspaceResourceID) { } Write-Host("") Stop-Transcript - exit + exit 1 } else { @@ -532,7 +532,7 @@ else { Write-Host("Could not change to Workspace subscriptionId : '" + $workspaceSubscriptionId + "'." ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } @@ -557,7 +557,7 @@ else { } Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully fetched workspace subcription details...") -ForegroundColor Green Write-Host("") @@ -581,7 +581,7 @@ else { Write-Host("Opt-in - " + $AksOptInLink) -ForegroundColor Red } Stop-Transcript - exit + exit 1 } Write-Host("Successfully fetched workspace resource group...") -ForegroundColor Green Write-Host("") @@ -610,7 +610,7 @@ else { } Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspaceLocation = $WorkspaceInformation.Location @@ -619,7 +619,7 @@ else { Write-Host("Cannot fetch workspace location. Please try again...") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspacePricingTier = $WorkspaceInformation.sku @@ -635,7 +635,7 @@ else { Write-Host("Failed to get the list of solutions onboarded to the workspace. Please make sure that it hasn't been deleted and you have access to it.") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } try { @@ -647,7 +647,7 @@ else { Write-Host("Failed to get ContainerInsights solution details from the workspace") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $isSolutionOnboarded = $WorkspaceIPDetails.Enabled[$ContainerInsightsIndex] @@ -711,7 +711,7 @@ try { if ($WorkspaceUsage.CurrentValue -ge $WorkspaceUsage.Limit) { Write-Host("Workspace usage has reached or over the configured daily cap. Please increase the daily cap limits or wait for next reset interval") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } Write-Host("Workspace doesnt have daily cap configured") -ForegroundColor Green @@ -720,7 +720,7 @@ catch { Write-Host("Failed to get usage details of the workspace") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } @@ -757,7 +757,7 @@ if ("AKS" -eq $ClusterType ) { Write-Host($AksOptInLink) -ForegroundColor Red Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } $rsPodStatus = $rsPod.status @@ -778,7 +778,7 @@ if ("AKS" -eq $ClusterType ) { Write-Host($AksOptInLink) -ForegroundColor Red Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent replicaset pod running OK.") -ForegroundColor Green @@ -786,7 +786,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to get omsagent replicatset pod info using kubectl get rs : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the omsagent daemonset pod running correctly ...") @@ -795,7 +795,7 @@ if ("AKS" -eq $ClusterType ) { if (($null -eq $ds) -or ($null -eq $ds.Items) -or ($ds.Items.Length -ne 1)) { Write-Host( "omsagent replicaset pod not scheduled or failed to schedule." + $contactUSMessage) Stop-Transcript - exit + exit 1 } $dsStatus = $ds.Items[0].status @@ -809,7 +809,7 @@ if ("AKS" -eq $ClusterType ) { Write-Host($dsStatus) Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent daemonset pod running OK.") -ForegroundColor Green @@ -817,7 +817,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the omsagent heatlhservice running correctly ...") @@ -826,7 +826,7 @@ if ("AKS" -eq $ClusterType ) { if ($healthservice.Items.Length -ne 1) { Write-Host( "omsagent healthservice not scheduled or failed to schedule." + $contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent healthservice running OK.") -ForegroundColor Green @@ -834,7 +834,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to execute kubectl get services command : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ($isClusterAndWorkspaceInDifferentSubs) { @@ -851,7 +851,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to get workspace details. Please validate whether you have Log Analytics Contributor role on the workspace error: '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the WorkspaceGuid and key matching with configured log analytics workspace ...") @@ -862,7 +862,7 @@ if ("AKS" -eq $ClusterType ) { if ((($workspaceGuidConfiguredOnAgent -eq $workspaceGUID) -and ($workspaceKeyConfiguredOnAgent -eq $workspacePrimarySharedKey)) -eq $false) { Write-Host ("Error - Log Analytics Workspace Guid and key configured on the agent not matching with details of the Workspace. Please verify and fix with the correct workspace Guid and Key") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Workspace Guid and Key on the agent matching with the Workspace") -ForegroundColor Green @@ -870,7 +870,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking agent version...") @@ -885,7 +885,7 @@ if ("AKS" -eq $ClusterType ) { } catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } diff --git a/scripts/troubleshoot/TroubleshootError_AcsEngine.ps1 b/scripts/troubleshoot/TroubleshootError_AcsEngine.ps1 index 1f1e1ba5d..5662d3f79 100644 --- a/scripts/troubleshoot/TroubleshootError_AcsEngine.ps1 +++ b/scripts/troubleshoot/TroubleshootError_AcsEngine.ps1 @@ -45,7 +45,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o else { Write-Host("Please run the script as an administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } $message = "This script will try to install the latest versions of the following Modules : ` @@ -69,7 +69,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o } catch { Write-Host("Close other powershell logins and try installing the latest modules for AzureRM.profile in a new powershell window: eg. 'Install-Module AzureRM.profile -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } try { Write-Host("Installing AzureRM.Resources...") @@ -77,7 +77,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o } catch { Write-Host("Close other powershell logins and try installing the latest modules for AzureRM.Resoureces in a new powershell window: eg. 'Install-Module AzureRM.Resoureces -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } try { @@ -86,7 +86,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o } catch { Write-Host("Close other powershell logins and try installing the latest modules for AzureRM.OperationalInsights in a new powershell window: eg. 'Install-Module AzureRM.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } 1 { @@ -97,7 +97,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o Write-Host("Could not import AzureRM.profile...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for AzureRM.profile in a new powershell window: eg. 'Install-Module AzureRM.profile -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } try { Import-Module AzureRM.Resources @@ -105,7 +105,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o catch { Write-Host("Could not import AzureRM.Resources... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } try { Import-Module AzureRM.OperationalInsights @@ -113,7 +113,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o catch { Write-Host("Could not import AzureRM.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Running troubleshooting script... Please reinstall this Module") Write-Host("") @@ -121,7 +121,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -151,7 +151,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the Subscription" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -171,7 +171,7 @@ else { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the Subscription" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -187,7 +187,7 @@ if ($notPresent) { Write-Host("Could not find RG. Please make sure that the resource group name: '" + $ResourceGroupName + "'is correct and you have access to the Resource Group") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully checked resource groups details...") -ForegroundColor Green @@ -197,13 +197,13 @@ Write-Host("Successfully checked resource groups details...") -ForegroundColor G if ([string]::IsNullOrEmpty($KubeConfig)) { Write-Host("KubeConfig should not be NULL or empty") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ((Test-Path $KubeConfig -PathType Leaf) -ne $true) { Write-Host("provided KubeConfig path : '" + $KubeConfig + "' doesnt exist or you dont have read access") -ForegroundColor Red Stop-Transcript - exit + exit 1 } # @@ -249,13 +249,13 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { } else { Write-Host("This Resource group : '" + $ResourceGroupName + "'does not have the AKS-engine or ACS-Engine Kubernetes resources") -ForegroundColor Red - exit + exit 1 } } if ($isKubernetesCluster -eq $false) { Write-Host("Monitoring only supported for AKS-Engine or ACS-Engine with Kubernetes") -ForegroundColor Red - exit + exit 1 } Write-Host("Successfully checked the AKS-Engine or ACS-Engine Kuberentes cluster resources in specified resource group") -ForegroundColor Green @@ -270,7 +270,7 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { if ($null -eq $r) { Write-Host("Get-AzureRmResource for Resource Group: " + $ResourceGroupName + "Resource Name :" + $k8MasterVM.Name + " failed" ) -ForegroundColor Red - exit + exit 1 } if ($null -eq $r.Tags) { @@ -279,7 +279,7 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { Write-Host("Please try to opt out of monitoring and opt-in using the following links:") -ForegroundColor Red Write-Host("Opt-out - " + $OptOutLink) -ForegroundColor Red Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red - exit + exit 1 } if ($r.Tags.ContainsKey("logAnalyticsWorkspaceResourceId")) { @@ -300,7 +300,7 @@ if ($null -eq $LogAnalyticsWorkspaceResourceID) { Write-Host("There is no existing logAnalyticsWorkspaceResourceId tag on AKS-Engine k8 master nodes or VMSSes so this indicates this cluster not enabled monitoring or tags have been removed" ) -ForegroundColor Red Write-Host("Please try to opt-in for monitoring using the following links:") -ForegroundColor Red Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red - exit + exit 1 } else { @@ -309,7 +309,7 @@ else { Write-Host("Please add the clusterName tag with the value of clusterName used during the omsagent agent onboarding. Refer below link for details:") -ForegroundColor Red Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red - exit + exit 1 } Write-Host("Configured LogAnalyticsWorkspaceResourceId: : '" + $LogAnalyticsWorkspaceResourceID + "' ") @@ -328,7 +328,7 @@ else { Write-Host("Could not change to Workspace subscriptionId : '" + $workspaceSubscriptionId + "'." ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } @@ -347,7 +347,7 @@ else { Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully fetched workspace subcription details...") -ForegroundColor Green Write-Host("") @@ -364,7 +364,7 @@ else { Write-Host("Opt-out - " + $OptOutLink) -ForegroundColor Red Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Successfully fetched workspace resource group...") -ForegroundColor Green Write-Host("") @@ -386,7 +386,7 @@ else { Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspaceLocation = $WorkspaceInformation.Location @@ -396,7 +396,7 @@ else { Write-Host("Cannot fetch workspace location. Please try again...") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspacePricingTier = $WorkspaceInformation.sku @@ -413,7 +413,7 @@ else { Write-Host("Failed to get the list of solutions onboarded to the workspace. Please make sure that it hasn't been deleted and you have access to it.") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } try { @@ -425,7 +425,7 @@ else { Write-Host("Failed to get ContainerInsights solution details from the workspace") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $isSolutionOnboarded = $WorkspaceIPDetails.Enabled[$ContainerInsightsIndex] @@ -498,7 +498,7 @@ try { } catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("") diff --git a/scripts/troubleshoot/TroubleshootError_nonAzureK8s.ps1 b/scripts/troubleshoot/TroubleshootError_nonAzureK8s.ps1 index 14b080b23..76bbad16c 100644 --- a/scripts/troubleshoot/TroubleshootError_nonAzureK8s.ps1 +++ b/scripts/troubleshoot/TroubleshootError_nonAzureK8s.ps1 @@ -47,25 +47,25 @@ Write-Host("LogAnalyticsWorkspaceResourceId: : '" + $azureLogAnalyticsWorkspaceR if (($azureLogAnalyticsWorkspaceResourceId.ToLower().Contains("microsoft.operationalinsights/workspaces") -ne $true) -or ($azureLogAnalyticsWorkspaceResourceId.Split("/").Length -ne 9)) { Write-Host("Provided Azure Log Analytics resource id should be in this format /subscriptions//resourceGroups//providers/Microsoft.OperationalInsights/workspaces/") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ([string]::IsNullOrEmpty($kubeConfig)) { Write-Host("kubeConfig should not be NULL or empty") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ((Test-Path $kubeConfig -PathType Leaf) -ne $true) { Write-Host("provided kubeConfig path : '" + $kubeConfig + "' doesnt exist or you dont have read access") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ([string]::IsNullOrEmpty($clusterContextInKubeconfig)) { Write-Host("provide clusterContext should be valid context in the provided kubeconfig") -ForegroundColor Red Stop-Transcript - exit + exit 1 } # checks the all required Powershell modules exist and if not exists, request the user permission to install @@ -92,7 +92,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - else { Write-Host("Please re-launch the script with elevated administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -120,7 +120,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -132,7 +132,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -145,7 +145,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.OperationalInsights in a new powershell window: eg. 'Install-Module Az.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -160,7 +160,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -171,7 +171,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -182,7 +182,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Could not import Az.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -190,7 +190,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -222,7 +222,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $workspaceSubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -242,7 +242,7 @@ else { Write-Host("Could not select subscription with ID : " + $workspaceSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -253,7 +253,7 @@ $workspaceResource = Get-AzResource -ResourceId $azureLogAnalyticsWorkspaceResou if ($null -eq $workspaceResource) { Write-Host("specified Azure Log Analytics resource id: " + $azureLogAnalyticsWorkspaceResourceId + ". either you dont have access or doesnt exist") -ForegroundColor Red Stop-Transcript - exit + exit 1 } # @@ -272,7 +272,7 @@ catch { Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspaceLocation = $WorkspaceInformation.Location @@ -281,7 +281,7 @@ if ($null -eq $WorkspaceLocation) { Write-Host("Cannot fetch workspace location. Please try again...") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspacePricingTier = $WorkspaceInformation.sku @@ -297,7 +297,7 @@ catch { Write-Host("Failed to get the list of solutions onboarded to the workspace. Please make sure that it hasn't been deleted and you have access to it.") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } try { @@ -309,7 +309,7 @@ catch { Write-Host("Failed to get ContainerInsights solution details from the workspace") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $isSolutionOnboarded = $WorkspaceIPDetails.Enabled[$ContainerInsightsIndex] @@ -317,7 +317,7 @@ if ($isSolutionOnboarded) { if ($WorkspacePricingTier -eq "Free") { Write-Host("Pricing tier of the configured LogAnalytics workspace is Free so you may need to upgrade to pricing tier to non-Free") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } else { @@ -356,13 +356,13 @@ else { Write-Host ("Template deployment failed with an error: '" + $Error[0] + "' ") -ForegroundColor Red Write-Host($contactUSMessage) -ForegroundColor Red Stop-Transcript - exit + exit 1 } } else { Write-Host("The container health solution isn't onboarded to your cluster. This required for the monitoring to work.") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -382,7 +382,7 @@ try { if ($null -eq $rsPod) { Write-Host( "omsagent replicaset pod not scheduled or failed to scheduled." + $contactUSMessage) -ForegroundColor Red Stop-Transcript - exit + exit 1 } $rsPodStatus = $rsPod.status if ((($rsPodStatus.availableReplicas -eq 1) -and @@ -393,7 +393,7 @@ try { Write-Host($rsPodStatus) Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent replicaset pod running OK.") -ForegroundColor Green @@ -401,7 +401,7 @@ try { catch { Write-Host ("Failed to get omsagent replicatset pod info using kubectl get rs : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the omsagent daemonset pod running correctly ...") @@ -410,7 +410,7 @@ try { if ($ds.Items.Length -ne 1) { Write-Host( "omsagent replicaset pod not scheduled or failed to schedule." + $contactUSMessage) -ForegroundColor Red Stop-Transcript - exit + exit 1 } $dsStatus = $ds.Items[0].status @@ -424,7 +424,7 @@ try { Write-Host($rsPodStatus) Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent daemonset pod running OK.") -ForegroundColor Green @@ -432,7 +432,7 @@ try { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the omsagent heatlhservice running correctly ...") @@ -441,7 +441,7 @@ try { if ($healthservice.Items.Length -ne 1) { Write-Host( "omsagent healthservice not scheduled or failed to schedule." + $contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent healthservice pod running OK.") -ForegroundColor Green @@ -449,7 +449,7 @@ try { catch { Write-Host ("Failed to execute kubectl get services command : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Retrieving WorkspaceGUID and WorkspacePrimaryKey of the workspace : " + $WorkspaceInformation.Name) @@ -462,7 +462,7 @@ try { catch { Write-Host ("Failed to workspace details. Please validate whether you have Log Analytics Contributor role on the workspace error: '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the WorkspaceGuid and key matching with configured log analytics workspace ...") @@ -473,7 +473,7 @@ try { if ((($workspaceGuidConfiguredOnAgent -eq $workspaceGUID) -and ($workspaceKeyConfiguredOnAgent -eq $workspacePrimarySharedKey)) -eq $false) { Write-Host ("Error - Log Analytics Workspace Guid and key configured on the agent not matching with details of the Workspace. Please verify and fix with the correct workspace Guid and Key") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Workspace Guid and Key on the agent matching with the Workspace") -ForegroundColor Green @@ -481,7 +481,7 @@ try { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking agent version...") @@ -497,7 +497,7 @@ try { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("resetting cluster context back, what it was before") diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index fbee1dd75..407ab3611 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -964,7 +964,7 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int if er != nil { Log("Error::mdsd::Failed to write to mdsd %d records after %s. Will retry ... error : %s", len(msgPackEntries), elapsed, er.Error()) - UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0) + UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0, 0) if MdsdInsightsMetricsMsgpUnixSocketClient != nil { MdsdInsightsMetricsMsgpUnixSocketClient.Close() MdsdInsightsMetricsMsgpUnixSocketClient = nil @@ -976,7 +976,7 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int return output.FLB_RETRY } else { numTelegrafMetricsRecords := len(msgPackEntries) - UpdateNumTelegrafMetricsSentTelemetry(numTelegrafMetricsRecords, 0, 0) + UpdateNumTelegrafMetricsSentTelemetry(numTelegrafMetricsRecords, 0, 0, 0) Log("Success::mdsd::Successfully flushed %d telegraf metrics records that was %d bytes to mdsd in %s ", numTelegrafMetricsRecords, bts, elapsed) } } @@ -985,9 +985,13 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int var metrics []laTelegrafMetric var i int + numWinMetricsWithTagsSize64KBorMore := 0 for i = 0; i < len(laMetrics); i++ { metrics = append(metrics, *laMetrics[i]) + if len(*&laMetrics[i].Tags) >= (64 * 1024) { + numWinMetricsWithTagsSize64KBorMore += 1 + } } laTelegrafMetrics := InsightsMetricsBlob{ @@ -1039,7 +1043,7 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int if err != nil { message := fmt.Sprintf("PostTelegrafMetricsToLA::Error:(retriable) when sending %v metrics. duration:%v err:%q \n", len(laMetrics), elapsed, err.Error()) Log(message) - UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0) + UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0, 0) return output.FLB_RETRY } @@ -1048,7 +1052,7 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int Log("PostTelegrafMetricsToLA::Error:(retriable) RequestID %s Response Status %v Status Code %v", reqID, resp.Status, resp.StatusCode) } if resp != nil && resp.StatusCode == 429 { - UpdateNumTelegrafMetricsSentTelemetry(0, 1, 1) + UpdateNumTelegrafMetricsSentTelemetry(0, 1, 1, 0) } return output.FLB_RETRY } @@ -1056,18 +1060,19 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int defer resp.Body.Close() numMetrics := len(laMetrics) - UpdateNumTelegrafMetricsSentTelemetry(numMetrics, 0, 0) + UpdateNumTelegrafMetricsSentTelemetry(numMetrics, 0, 0, numWinMetricsWithTagsSize64KBorMore) Log("PostTelegrafMetricsToLA::Info:Successfully flushed %v records in %v", numMetrics, elapsed) } return output.FLB_OK } -func UpdateNumTelegrafMetricsSentTelemetry(numMetricsSent int, numSendErrors int, numSend429Errors int) { +func UpdateNumTelegrafMetricsSentTelemetry(numMetricsSent int, numSendErrors int, numSend429Errors int, numWinMetricswith64KBorMoreSize int) { ContainerLogTelemetryMutex.Lock() TelegrafMetricsSentCount += float64(numMetricsSent) TelegrafMetricsSendErrorCount += float64(numSendErrors) TelegrafMetricsSend429ErrorCount += float64(numSend429Errors) + WinTelegrafMetricsCountWithTagsSize64KBorMore += float64(numWinMetricswith64KBorMoreSize) ContainerLogTelemetryMutex.Unlock() } diff --git a/source/plugins/go/src/telemetry.go b/source/plugins/go/src/telemetry.go index b344f4ac8..b4f8ab89d 100644 --- a/source/plugins/go/src/telemetry.go +++ b/source/plugins/go/src/telemetry.go @@ -32,6 +32,8 @@ var ( TelemetryClient appinsights.TelemetryClient // ContainerLogTelemetryTicker sends telemetry periodically ContainerLogTelemetryTicker *time.Ticker + //Tracks the number of windows telegraf metrics count with Tags size 64KB or more between telemetry ticker periods (uses ContainerLogTelemetryTicker) + WinTelegrafMetricsCountWithTagsSize64KBorMore float64 //Tracks the number of telegraf metrics sent successfully between telemetry ticker periods (uses ContainerLogTelemetryTicker) TelegrafMetricsSentCount float64 //Tracks the number of send errors between telemetry ticker periods (uses ContainerLogTelemetryTicker) @@ -78,6 +80,7 @@ const ( metricNameNumberofTelegrafMetricsSentSuccessfully = "TelegrafMetricsSentCount" metricNameNumberofSendErrorsTelegrafMetrics = "TelegrafMetricsSendErrorCount" metricNameNumberofSend429ErrorsTelegrafMetrics = "TelegrafMetricsSend429ErrorCount" + metricNameNumberofWinTelegrafMetricsWithTagsSize64KBorMore = "WinTelegrafMetricsCountWithTagsSize64KBorMore" metricNameErrorCountContainerLogsSendErrorsToMDSDFromFluent = "ContainerLogs2MdsdSendErrorCount" metricNameErrorCountContainerLogsMDSDClientCreateError = "ContainerLogsMdsdClientCreateErrorCount" metricNameErrorCountInsightsMetricsMDSDClientCreateError = "InsightsMetricsMDSDClientCreateErrorsCount" @@ -117,6 +120,7 @@ func SendContainerLogPluginMetrics(telemetryPushIntervalProperty string) { telegrafMetricsSentCount := TelegrafMetricsSentCount telegrafMetricsSendErrorCount := TelegrafMetricsSendErrorCount telegrafMetricsSend429ErrorCount := TelegrafMetricsSend429ErrorCount + winTelegrafMetricsCountWithTagsSize64KBorMore := WinTelegrafMetricsCountWithTagsSize64KBorMore containerLogsSendErrorsToMDSDFromFluent := ContainerLogsSendErrorsToMDSDFromFluent containerLogsMDSDClientCreateErrors := ContainerLogsMDSDClientCreateErrors containerLogsSendErrorsToADXFromFluent := ContainerLogsSendErrorsToADXFromFluent @@ -133,6 +137,7 @@ func SendContainerLogPluginMetrics(telemetryPushIntervalProperty string) { TelegrafMetricsSentCount = 0.0 TelegrafMetricsSendErrorCount = 0.0 TelegrafMetricsSend429ErrorCount = 0.0 + WinTelegrafMetricsCountWithTagsSize64KBorMore = 0.0 FlushedRecordsCount = 0.0 FlushedRecordsSize = 0.0 FlushedRecordsTimeTaken = 0.0 @@ -227,6 +232,9 @@ func SendContainerLogPluginMetrics(telemetryPushIntervalProperty string) { if kubeMonEventsMDSDClientCreateErrors > 0.0 { TelemetryClient.Track(appinsights.NewMetricTelemetry(metricNameErrorCountKubeMonEventsMDSDClientCreateError, kubeMonEventsMDSDClientCreateErrors)) } + if winTelegrafMetricsCountWithTagsSize64KBorMore > 0.0 { + TelemetryClient.Track(appinsights.NewMetricTelemetry(metricNameNumberofWinTelegrafMetricsWithTagsSize64KBorMore, winTelegrafMetricsCountWithTagsSize64KBorMore)) + } if ContainerLogRecordCountWithEmptyTimeStamp > 0.0 { TelemetryClient.Track(appinsights.NewMetricTelemetry(metricNameContainerLogRecordCountWithEmptyTimeStamp, containerLogRecordCountWithEmptyTimeStamp)) } diff --git a/source/plugins/ruby/constants.rb b/source/plugins/ruby/constants.rb index 69da56488..b9516c2ce 100644 --- a/source/plugins/ruby/constants.rb +++ b/source/plugins/ruby/constants.rb @@ -110,7 +110,7 @@ class Constants CONTAINER_INVENTORY_DATA_TYPE = "CONTAINER_INVENTORY_BLOB" CONTAINER_NODE_INVENTORY_DATA_TYPE = "CONTAINER_NODE_INVENTORY_BLOB" PERF_DATA_TYPE = "LINUX_PERF_BLOB" - INSIGHTS_METRICS_DATA_TYPE = "INSIGHTS_METRICS_BLOB" + INSIGHTS_METRICS_DATA_TYPE = "INSIGHTS_METRICS_BLOB" KUBE_SERVICES_DATA_TYPE = "KUBE_SERVICES_BLOB" KUBE_POD_INVENTORY_DATA_TYPE = "KUBE_POD_INVENTORY_BLOB" KUBE_NODE_INVENTORY_DATA_TYPE = "KUBE_NODE_INVENTORY_BLOB" @@ -119,17 +119,21 @@ class Constants KUBE_MON_AGENT_EVENTS_DATA_TYPE = "KUBE_MON_AGENT_EVENTS_BLOB" KUBE_HEALTH_DATA_TYPE = "KUBE_HEALTH_BLOB" CONTAINERLOGV2_DATA_TYPE = "CONTAINERINSIGHTS_CONTAINERLOGV2" - CONTAINERLOG_DATA_TYPE = "CONTAINER_LOG_BLOB" + CONTAINERLOG_DATA_TYPE = "CONTAINER_LOG_BLOB" #ContainerInsights Extension (AMCS) CI_EXTENSION_NAME = "ContainerInsights" - CI_EXTENSION_VERSION = "1" + CI_EXTENSION_VERSION = "1" #Current CI extension config size is ~5KB and going with 20KB to handle any future scenarios CI_EXTENSION_CONFIG_MAX_BYTES = 20480 - ONEAGENT_FLUENT_SOCKET_NAME = "/var/run/mdsd/default_fluent.socket" + ONEAGENT_FLUENT_SOCKET_NAME = "/var/run/mdsd/default_fluent.socket" #Tag prefix for output stream EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX = "dcr-" LINUX_LOG_PATH = $in_unit_test.nil? ? "/var/opt/microsoft/docker-cimprov/log/" : "./" WINDOWS_LOG_PATH = $in_unit_test.nil? ? "/etc/omsagentwindows/" : "./" + + #This is for telemetry to track if any of the windows customer has any of the field size >= 64KB + #To evaluate switching to Windows AMA 64KB impacts any existing customers + MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY = 65536 end diff --git a/source/plugins/ruby/in_cadvisor_perf.rb b/source/plugins/ruby/in_cadvisor_perf.rb index 862e88e44..aba24ecc2 100644 --- a/source/plugins/ruby/in_cadvisor_perf.rb +++ b/source/plugins/ruby/in_cadvisor_perf.rb @@ -64,12 +64,12 @@ def enumerate() begin eventStream = Fluent::MultiEventStream.new insightsMetricsEventStream = Fluent::MultiEventStream.new - metricData = CAdvisorMetricsAPIClient.getMetrics(winNode: nil, metricTime: batchTime ) + metricData = CAdvisorMetricsAPIClient.getMetrics(winNode: nil, metricTime: batchTime) metricData.each do |record| eventStream.add(time, record) if record end - if ExtensionUtils.isAADMSIAuthMode() + if ExtensionUtils.isAADMSIAuthMode() && !@@isWindows.nil? && @@isWindows == false $log.info("in_cadvisor_perf::enumerate: AAD AUTH MSI MODE") if @tag.nil? || !@tag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) @tag = ExtensionUtils.getOutputStreamId(Constants::PERF_DATA_TYPE) @@ -77,7 +77,7 @@ def enumerate() if @insightsmetricstag.nil? || !@insightsmetricstag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) @insightsmetricstag = ExtensionUtils.getOutputStreamId(Constants::INSIGHTS_METRICS_DATA_TYPE) end - $log.info("in_cadvisor_perf::enumerate: using perf tag -#{@tag} @ #{Time.now.utc.iso8601}") + $log.info("in_cadvisor_perf::enumerate: using perf tag -#{@tag} @ #{Time.now.utc.iso8601}") $log.info("in_cadvisor_perf::enumerate: using insightsmetrics tag -#{@insightsmetricstag} @ #{Time.now.utc.iso8601}") end router.emit_stream(@tag, eventStream) if eventStream @@ -95,9 +95,9 @@ def enumerate() containerGPUusageInsightsMetricsDataItems = [] containerGPUusageInsightsMetricsDataItems.concat(CAdvisorMetricsAPIClient.getInsightsMetrics(winNode: nil, metricTime: batchTime)) - containerGPUusageInsightsMetricsDataItems.each do |insightsMetricsRecord| - insightsMetricsEventStream.add(time, insightsMetricsRecord) if insightsMetricsRecord - end + containerGPUusageInsightsMetricsDataItems.each do |insightsMetricsRecord| + insightsMetricsEventStream.add(time, insightsMetricsRecord) if insightsMetricsRecord + end router.emit_stream(@insightsmetricstag, insightsMetricsEventStream) if insightsMetricsEventStream router.emit_stream(@mdmtag, insightsMetricsEventStream) if insightsMetricsEventStream diff --git a/source/plugins/ruby/in_kube_nodes.rb b/source/plugins/ruby/in_kube_nodes.rb index a32a32769..abbfe94a1 100644 --- a/source/plugins/ruby/in_kube_nodes.rb +++ b/source/plugins/ruby/in_kube_nodes.rb @@ -1,17 +1,17 @@ #!/usr/local/bin/ruby # frozen_string_literal: true -require 'fluent/plugin/input' +require "fluent/plugin/input" module Fluent::Plugin class Kube_nodeInventory_Input < Input Fluent::Plugin.register_input("kube_nodes", self) - def initialize (kubernetesApiClient=nil, - applicationInsightsUtility=nil, - extensionUtils=nil, - env=nil, - telemetry_flush_interval=nil) + def initialize(kubernetesApiClient = nil, + applicationInsightsUtility = nil, + extensionUtils = nil, + env = nil, + telemetry_flush_interval = nil) super() require "yaml" @@ -36,8 +36,7 @@ def initialize (kubernetesApiClient=nil, @@promConfigMountPath = "/etc/config/settings/prometheus-data-collection-settings" @@osmConfigMountPath = "/etc/config/osm-settings/osm-metric-collection-configuration" @@AzStackCloudFileName = "/etc/kubernetes/host/azurestackcloud.json" - - + @@rsPromInterval = @env["TELEMETRY_RS_PROM_INTERVAL"] @@rsPromFieldPassCount = @env["TELEMETRY_RS_PROM_FIELDPASS_LENGTH"] @@rsPromFieldDropCount = @env["TELEMETRY_RS_PROM_FIELDDROP_LENGTH"] @@ -119,6 +118,7 @@ def enumerate nodeInventory = nil currentTime = Time.now batchTime = currentTime.utc.iso8601 + nodeCount = 0 @nodesAPIE2ELatencyMs = 0 @nodeInventoryE2EProcessingLatencyMs = 0 @@ -138,7 +138,7 @@ def enumerate if @tag.nil? || !@tag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) @tag = @extensionUtils.getOutputStreamId(Constants::KUBE_NODE_INVENTORY_DATA_TYPE) end - $log.info("in_kube_nodes::enumerate: using perf tag -#{@kubeperfTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_nodes::enumerate: using perf tag -#{@kubeperfTag} @ #{Time.now.utc.iso8601}") $log.info("in_kube_nodes::enumerate: using insightsmetrics tag -#{@insightsMetricsTag} @ #{Time.now.utc.iso8601}") $log.info("in_kube_nodes::enumerate: using containernodeinventory tag -#{@ContainerNodeInventoryTag} @ #{Time.now.utc.iso8601}") $log.info("in_kube_nodes::enumerate: using kubenodeinventory tag -#{@tag} @ #{Time.now.utc.iso8601}") @@ -155,6 +155,7 @@ def enumerate nodesAPIChunkEndTime = (Time.now.to_f * 1000).to_i @nodesAPIE2ELatencyMs = (nodesAPIChunkEndTime - nodesAPIChunkStartTime) if (!nodeInventory.nil? && !nodeInventory.empty? && nodeInventory.key?("items") && !nodeInventory["items"].nil? && !nodeInventory["items"].empty?) + nodeCount += nodeInventory["items"].length $log.info("in_kube_nodes::enumerate : number of node items :#{nodeInventory["items"].length} from Kube API @ #{Time.now.utc.iso8601}") parse_and_emit_records(nodeInventory, batchTime) else @@ -168,6 +169,7 @@ def enumerate nodesAPIChunkEndTime = (Time.now.to_f * 1000).to_i @nodesAPIE2ELatencyMs = @nodesAPIE2ELatencyMs + (nodesAPIChunkEndTime - nodesAPIChunkStartTime) if (!nodeInventory.nil? && !nodeInventory.empty? && nodeInventory.key?("items") && !nodeInventory["items"].nil? && !nodeInventory["items"].empty?) + nodeCount += nodeInventory["items"].length $log.info("in_kube_nodes::enumerate : number of node items :#{nodeInventory["items"].length} from Kube API @ #{Time.now.utc.iso8601}") parse_and_emit_records(nodeInventory, batchTime) else @@ -181,6 +183,7 @@ def enumerate if (timeDifferenceInMinutes >= @TELEMETRY_FLUSH_INTERVAL_IN_MINUTES) @applicationInsightsUtility.sendMetricTelemetry("NodeInventoryE2EProcessingLatencyMs", @nodeInventoryE2EProcessingLatencyMs, {}) @applicationInsightsUtility.sendMetricTelemetry("NodesAPIE2ELatencyMs", @nodesAPIE2ELatencyMs, {}) + @applicationInsightsUtility.sendMetricTelemetry("NodeCount", nodeCount, {}) @@nodeInventoryLatencyTelemetryTimeTracker = DateTime.now.to_time.to_i end # Setting this to nil so that we dont hold memory until GC kicks in @@ -208,9 +211,9 @@ def parse_and_emit_records(nodeInventory, batchTime = Time.utc.iso8601) nodeInventoryRecord = getNodeInventoryRecord(item, batchTime) eventStream.add(emitTime, nodeInventoryRecord) if nodeInventoryRecord if @NODES_EMIT_STREAM_BATCH_SIZE > 0 && eventStream.count >= @NODES_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_node::parse_and_emit_records: number of node inventory records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_node::parse_and_emit_records: number of node inventory records emitted #{eventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@tag, eventStream) if eventStream - $log.info("in_kube_node::parse_and_emit_records: number of mdm node inventory records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_node::parse_and_emit_records: number of mdm node inventory records emitted #{eventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@MDMKubeNodeInventoryTag, eventStream) if eventStream if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) $log.info("kubeNodeInventoryEmitStreamSuccess @ #{Time.now.utc.iso8601}") @@ -223,7 +226,7 @@ def parse_and_emit_records(nodeInventory, batchTime = Time.utc.iso8601) containerNodeInventoryEventStream.add(emitTime, containerNodeInventoryRecord) if containerNodeInventoryRecord if @NODES_EMIT_STREAM_BATCH_SIZE > 0 && containerNodeInventoryEventStream.count >= @NODES_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_node::parse_and_emit_records: number of container node inventory records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_node::parse_and_emit_records: number of container node inventory records emitted #{containerNodeInventoryEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@ContainerNodeInventoryTag, containerNodeInventoryEventStream) if containerNodeInventoryEventStream containerNodeInventoryEventStream = Fluent::MultiEventStream.new if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) @@ -272,7 +275,7 @@ def parse_and_emit_records(nodeInventory, batchTime = Time.utc.iso8601) kubePerfEventStream.add(emitTime, metricRecord) if metricRecord end if @NODES_EMIT_STREAM_BATCH_SIZE > 0 && kubePerfEventStream.count >= @NODES_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_nodes::parse_and_emit_records: number of node perf metric records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_nodes::parse_and_emit_records: number of node perf metric records emitted #{kubePerfEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@kubeperfTag, kubePerfEventStream) if kubePerfEventStream kubePerfEventStream = Fluent::MultiEventStream.new if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) @@ -302,7 +305,7 @@ def parse_and_emit_records(nodeInventory, batchTime = Time.utc.iso8601) insightsMetricsEventStream.add(emitTime, insightsMetricsRecord) if insightsMetricsRecord end if @NODES_EMIT_STREAM_BATCH_SIZE > 0 && insightsMetricsEventStream.count >= @NODES_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_nodes::parse_and_emit_records: number of GPU node perf metric records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_nodes::parse_and_emit_records: number of GPU node perf metric records emitted #{insightsMetricsEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@insightsMetricsTag, insightsMetricsEventStream) if insightsMetricsEventStream insightsMetricsEventStream = Fluent::MultiEventStream.new if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) @@ -572,12 +575,12 @@ def getNodeTelemetryProps(item) return properties end end # Kube_Node_Input + class NodeStatsCache # inner class for caching implementation (CPU and memory caching is handled the exact same way, so logic to do so is moved to a private inner class) # (to reduce code duplication) class NodeCache - - @@RECORD_TIME_TO_LIVE = 60*20 # units are seconds, so clear the cache every 20 minutes. + @@RECORD_TIME_TO_LIVE = 60 * 20 # units are seconds, so clear the cache every 20 minutes. def initialize @cacheHash = {} @@ -622,7 +625,7 @@ def clean_cache() end end - nodes_to_remove.each {|node_name| + nodes_to_remove.each { |node_name| @cacheHash.delete(node_name) @timeAdded.delete(node_name) } @@ -630,7 +633,6 @@ def clean_cache() end end # NodeCache - @@cpuCache = NodeCache.new @@memCache = NodeCache.new diff --git a/source/plugins/ruby/in_kube_podinventory.rb b/source/plugins/ruby/in_kube_podinventory.rb index 3f5f4f1cc..f979ef7c5 100644 --- a/source/plugins/ruby/in_kube_podinventory.rb +++ b/source/plugins/ruby/in_kube_podinventory.rb @@ -1,7 +1,7 @@ #!/usr/local/bin/ruby # frozen_string_literal: true -require 'fluent/plugin/input' +require "fluent/plugin/input" module Fluent::Plugin require_relative "podinventory_to_mdm" @@ -12,7 +12,6 @@ class Kube_PodInventory_Input < Input @@MDMKubePodInventoryTag = "mdm.kubepodinventory" @@hostName = (OMS::Common.get_hostname) - def initialize super require "yaml" @@ -35,9 +34,16 @@ def initialize @PODS_EMIT_STREAM_BATCH_SIZE = 0 @podCount = 0 + @containerCount = 0 @serviceCount = 0 @controllerSet = Set.new [] @winContainerCount = 0 + @windowsNodeCount = 0 + @winContainerInventoryTotalSizeBytes = 0 + @winContainerCountWithInventoryRecordSize64KBOrMore = 0 + @winContainerCountWithEnvVarSize64KBOrMore = 0 + @winContainerCountWithPortsSize64KBOrMore = 0 + @winContainerCountWithCommandSize64KBOrMore = 0 @controllerData = {} @podInventoryE2EProcessingLatencyMs = 0 @podsAPIE2ELatencyMs = 0 @@ -100,9 +106,16 @@ def enumerate(podList = nil) podInventory = podList telemetryFlush = false @podCount = 0 + @containerCount = 0 @serviceCount = 0 @controllerSet = Set.new [] @winContainerCount = 0 + @winContainerInventoryTotalSizeBytes = 0 + @winContainerCountWithInventoryRecordSize64KBOrMore = 0 + @winContainerCountWithEnvVarSize64KBOrMore = 0 + @winContainerCountWithPortsSize64KBOrMore = 0 + @winContainerCountWithCommandSize64KBOrMore = 0 + @windowsNodeCount = 0 @controllerData = {} currentTime = Time.now batchTime = currentTime.utc.iso8601 @@ -110,27 +123,27 @@ def enumerate(podList = nil) @podInventoryE2EProcessingLatencyMs = 0 podInventoryStartTime = (Time.now.to_f * 1000).to_i if ExtensionUtils.isAADMSIAuthMode() - $log.info("in_kube_podinventory::enumerate: AAD AUTH MSI MODE") - if @kubeperfTag.nil? || !@kubeperfTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @kubeperfTag = ExtensionUtils.getOutputStreamId(Constants::PERF_DATA_TYPE) - end - if @kubeservicesTag.nil? || !@kubeservicesTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @kubeservicesTag = ExtensionUtils.getOutputStreamId(Constants::KUBE_SERVICES_DATA_TYPE) - end - if @containerInventoryTag.nil? || !@containerInventoryTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @containerInventoryTag = ExtensionUtils.getOutputStreamId(Constants::CONTAINER_INVENTORY_DATA_TYPE) - end - if @insightsMetricsTag.nil? || !@insightsMetricsTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @insightsMetricsTag = ExtensionUtils.getOutputStreamId(Constants::INSIGHTS_METRICS_DATA_TYPE) - end - if @tag.nil? || !@tag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @tag = ExtensionUtils.getOutputStreamId(Constants::KUBE_POD_INVENTORY_DATA_TYPE) - end - $log.info("in_kube_podinventory::enumerate: using perf tag -#{@kubeperfTag} @ #{Time.now.utc.iso8601}") - $log.info("in_kube_podinventory::enumerate: using kubeservices tag -#{@kubeservicesTag} @ #{Time.now.utc.iso8601}") - $log.info("in_kube_podinventory::enumerate: using containerinventory tag -#{@containerInventoryTag} @ #{Time.now.utc.iso8601}") - $log.info("in_kube_podinventory::enumerate: using insightsmetrics tag -#{@insightsMetricsTag} @ #{Time.now.utc.iso8601}") - $log.info("in_kube_podinventory::enumerate: using kubepodinventory tag -#{@tag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: AAD AUTH MSI MODE") + if @kubeperfTag.nil? || !@kubeperfTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @kubeperfTag = ExtensionUtils.getOutputStreamId(Constants::PERF_DATA_TYPE) + end + if @kubeservicesTag.nil? || !@kubeservicesTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @kubeservicesTag = ExtensionUtils.getOutputStreamId(Constants::KUBE_SERVICES_DATA_TYPE) + end + if @containerInventoryTag.nil? || !@containerInventoryTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @containerInventoryTag = ExtensionUtils.getOutputStreamId(Constants::CONTAINER_INVENTORY_DATA_TYPE) + end + if @insightsMetricsTag.nil? || !@insightsMetricsTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @insightsMetricsTag = ExtensionUtils.getOutputStreamId(Constants::INSIGHTS_METRICS_DATA_TYPE) + end + if @tag.nil? || !@tag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @tag = ExtensionUtils.getOutputStreamId(Constants::KUBE_POD_INVENTORY_DATA_TYPE) + end + $log.info("in_kube_podinventory::enumerate: using perf tag -#{@kubeperfTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: using kubeservices tag -#{@kubeservicesTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: using containerinventory tag -#{@containerInventoryTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: using insightsmetrics tag -#{@insightsMetricsTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: using kubepodinventory tag -#{@tag} @ #{Time.now.utc.iso8601}") end # Get services first so that we dont need to make a call for very chunk @@ -202,11 +215,24 @@ def enumerate(podList = nil) telemetryProperties["PODS_EMIT_STREAM_BATCH_SIZE"] = @PODS_EMIT_STREAM_BATCH_SIZE ApplicationInsightsUtility.sendCustomEvent("KubePodInventoryHeartBeatEvent", telemetryProperties) ApplicationInsightsUtility.sendMetricTelemetry("PodCount", @podCount, {}) + ApplicationInsightsUtility.sendMetricTelemetry("ContainerCount", @containerCount, {}) ApplicationInsightsUtility.sendMetricTelemetry("ServiceCount", @serviceCount, {}) telemetryProperties["ControllerData"] = @controllerData.to_json ApplicationInsightsUtility.sendMetricTelemetry("ControllerCount", @controllerSet.length, telemetryProperties) if @winContainerCount > 0 telemetryProperties["ClusterWideWindowsContainersCount"] = @winContainerCount + telemetryProperties["WindowsNodeCount"] = @windowsNodeCount + telemetryProperties["ClusterWideWindowsContainerInventoryTotalSizeKB"] = @winContainerInventoryTotalSizeBytes / 1024 + telemetryProperties["WindowsContainerCountWithInventoryRecordSize64KBorMore"] = @winContainerCountWithInventoryRecordSize64KBOrMore + if @winContainerCountWithEnvVarSize64KBOrMore > 0 + telemetryProperties["WinContainerCountWithEnvVarSize64KBOrMore"] = @winContainerCountWithEnvVarSize64KBOrMore + end + if @winContainerCountWithPortsSize64KBOrMore > 0 + telemetryProperties["WinContainerCountWithPortsSize64KBOrMore"] = @winContainerCountWithPortsSize64KBOrMore + end + if @winContainerCountWithCommandSize64KBOrMore > 0 + telemetryProperties["WinContainerCountWithCommandSize64KBOrMore"] = @winContainerCountWithCommandSize64KBOrMore + end ApplicationInsightsUtility.sendCustomEvent("WindowsContainerInventoryEvent", telemetryProperties) end ApplicationInsightsUtility.sendMetricTelemetry("PodInventoryE2EProcessingLatencyMs", @podInventoryE2EProcessingLatencyMs, telemetryProperties) @@ -236,6 +262,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc podInventory["items"].each do |item| #podInventory block start # pod inventory records podInventoryRecords = getPodInventoryRecords(item, serviceRecords, batchTime) + @containerCount += podInventoryRecords.length podInventoryRecords.each do |record| if !record.nil? eventStream.add(emitTime, record) if record @@ -249,6 +276,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc if !item["spec"]["nodeName"].nil? nodeName = item["spec"]["nodeName"] end + @windowsNodeCount = winNodes.length if (!nodeName.empty? && (winNodes.include? nodeName)) clusterCollectEnvironmentVar = ENV["AZMON_CLUSTER_COLLECT_ENV_VAR"] #Generate ContainerInventory records for windows nodes so that we can get image and image tag in property panel @@ -258,13 +286,27 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc containerInventoryRecords.each do |cirecord| if !cirecord.nil? containerInventoryStream.add(emitTime, cirecord) if cirecord + ciRecordSize = cirecord.to_s.length + @winContainerInventoryTotalSizeBytes += ciRecordSize + if ciRecordSize >= Constants::MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY + @winContainerCountWithInventoryRecordSize64KBOrMore += 1 + end + if !cirecord["EnvironmentVar"].nil? && !cirecord["EnvironmentVar"].empty? && cirecord["EnvironmentVar"].length >= Constants::MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY + @winContainerCountWithEnvVarSize64KBOrMore += 1 + end + if !cirecord["Ports"].nil? && !cirecord["Ports"].empty? && cirecord["Ports"].length >= Constants::MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY + @winContainerCountWithPortsSize64KBOrMore += 1 + end + if !cirecord["Command"].nil? && !cirecord["Command"].empty? && cirecord["Command"].length >= Constants::MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY + @winContainerCountWithCommandSize64KBOrMore += 1 + end end end end end if @PODS_EMIT_STREAM_BATCH_SIZE > 0 && eventStream.count >= @PODS_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_podinventory::parse_and_emit_records: number of pod inventory records emitted #{@PODS_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::parse_and_emit_records: number of pod inventory records emitted #{eventStream.count} @ #{Time.now.utc.iso8601}") if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) $log.info("kubePodInventoryEmitStreamSuccess @ #{Time.now.utc.iso8601}") end @@ -284,7 +326,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc end if @PODS_EMIT_STREAM_BATCH_SIZE > 0 && kubePerfEventStream.count >= @PODS_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_podinventory::parse_and_emit_records: number of container perf records emitted #{@PODS_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::parse_and_emit_records: number of container perf records emitted #{kubePerfEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@kubeperfTag, kubePerfEventStream) if kubePerfEventStream if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) $log.info("kubeContainerPerfEventEmitStreamSuccess @ #{Time.now.utc.iso8601}") @@ -303,7 +345,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc end if @PODS_EMIT_STREAM_BATCH_SIZE > 0 && insightsMetricsEventStream.count >= @PODS_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_podinventory::parse_and_emit_records: number of GPU insights metrics records emitted #{@PODS_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::parse_and_emit_records: number of GPU insights metrics records emitted #{insightsMetricsEventStream.count} @ #{Time.now.utc.iso8601}") if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) $log.info("kubePodInsightsMetricsEmitStreamSuccess @ #{Time.now.utc.iso8601}") end @@ -368,7 +410,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc kubeServiceRecord["ClusterName"] = KubernetesApiClient.getClusterName kubeServicesEventStream.add(emitTime, kubeServiceRecord) if kubeServiceRecord if @PODS_EMIT_STREAM_BATCH_SIZE > 0 && kubeServicesEventStream.count >= @PODS_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_podinventory::parse_and_emit_records: number of service records emitted #{@PODS_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::parse_and_emit_records: number of service records emitted #{kubeServicesEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@kubeservicesTag, kubeServicesEventStream) if kubeServicesEventStream kubeServicesEventStream = Fluent::MultiEventStream.new if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0)