Skip to content

Commit 1d07b71

Browse files
committed
Merge remote-tracking branch 'origin/main' into vidai/release-2024-11-19
2 parents 58df09f + 460ff0e commit 1d07b71

File tree

281 files changed

+59979
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+59979
-131
lines changed

.azure-pipelines/code-gen.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ jobs:
2121
pool: pool-windows-2019
2222
steps:
2323
- checkout: self
24-
persistCredentials: true
25-
- template: util/get-github-token-steps.yml
24+
- template: util/get-github-pat-steps.yml
2625
- task: NodeTool@0
2726
displayName: Use Node 14.15.5
2827
inputs:

.azure-pipelines/util/get-github-token-steps.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

NuGet.Config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@
1515

1616

1717

18+
19+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Example Analysis
2+
3+
### What is the purpose of example analysis?
4+
As we know, our cmdlet help markdown is handwritten, which is an error-prone process. Example analysis is one of steps of static analysis, which checks the syntax correctness and completeness of cmdlet help markdown, especially for code blocks in example sections.
5+
6+
### What will be checked by example analyzer?
7+
Example analyzer will check
8+
- if there are any missing section heading, like '## EXAMPLES', '## PARAMETERS' and so on.
9+
- if code block type is defined clearly like ```powershell
10+
- if code block is separated into two parts: ```powershell and ```output
11+
- if customized rules are violated. Customized rules include
12+
- Invalid_Cmdlet
13+
- Is_Alias
14+
- Capitalization_Conventions_Violated
15+
- Unknown_Parameter_Set
16+
- Invalid_Parameter_Name
17+
- Duplicate_Parameter_Name
18+
- Unassigned_Parameter
19+
- Unassigned_Variable
20+
- Unbinded_Expression
21+
- Mismatched_Parameter_Value_Type
22+
23+
### What will be ignore by example analyzer?
24+
- If the example begins with `<!-- Aladdin Generated Example -->` or matches with regex `<!-- Skip.*-->`, its scan will be skipped.
25+
26+
### How to run example analyzer locally to debug issues reported in CIs
27+
Run following script in PowerShell console, which requires PSScriptAnalyzer installed on local
28+
```powershell
29+
tools/StaticAnalysis/ExampleAnalyzer/Measure-MarkdownOrScript.ps1 -MarkdownPaths {your-help-folder} -RulePaths tools/StaticAnalysis/ExampleAnalyzer/AnalyzeRules/*.psm1
30+
```
31+
32+
### TroubleShooting
33+
- If a cmdlet is recognized as Invalid_Cmdlet, most likely its module is not imported correctly. Check its import process and configuration. If it's correct, it may be caused by parallel importing all psd1 files. Currently, the workaround is suppressing false positive. Maybe only importing changed modules are one of potential solutions.
34+
35+
### Miscellaneous
36+
- Storage module has not been separated into ```powershell and ```output as their examples contain many outputs. They skips scan by regex `<!-- Skip.*-->` at the beginning of code block.

src/ConnectedKubernetes/ConnectedKubernetes.Autorest/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
[assembly: ComVisible(false)]
2525
[assembly: CLSCompliant(false)]
2626
[assembly: Guid("57c436a1-0e82-42cb-a1a6-f727667af406")]
27-
[assembly: AssemblyVersion("0.12.0")]
28-
[assembly: AssemblyFileVersion("0.12.0")]
27+
[assembly: AssemblyVersion("0.13.0")]
28+
[assembly: AssemblyFileVersion("0.13.0")]

src/ConnectedKubernetes/ConnectedKubernetes.Autorest/custom/New-AzConnectedKubernetes.ps1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ function New-AzConnectedKubernetes {
411411
catch {
412412
# This is attempting to delete Azure Arc resources that are orphaned.
413413
# We are catching and ignoring any messages here.
414-
$null = helm delete azure-arc --ignore-not-found --namespace $ReleaseNamespace --kubeconfig $KubeConfig --kube-context $KubeContext
414+
$null = helm delete azure-arc --ignore-not-found --namespace $ReleaseNamespace --kubeconfig $KubeConfig --kube-context $KubeContext | Out-Null
415415
}
416416
}
417417

@@ -622,11 +622,11 @@ function New-AzConnectedKubernetes {
622622

623623
$PSBoundParameters.Add('ArcAgentryConfiguration', $arcAgentryConfigs)
624624

625-
Write-Output "Creating 'Kubernetes - Azure Arc' object in Azure"
625+
Write-Verbose "Creating 'Kubernetes - Azure Arc' object in Azure"
626626
Write-Debug "PSBoundParameters: $PSBoundParameters"
627-
$Response = Az.ConnectedKubernetes.internal\New-AzConnectedKubernetes @PSBoundParameters
627+
$CCResponse = Az.ConnectedKubernetes.internal\New-AzConnectedKubernetes @PSBoundParameters
628628

629-
if ((-not $WhatIfPreference) -and (-not $Response)) {
629+
if ((-not $WhatIfPreference) -and (-not $CCResponse)) {
630630
Write-Error "Failed to create the 'Kubernetes - Azure Arc' resource."
631631
return
632632
}
@@ -639,8 +639,8 @@ function New-AzConnectedKubernetes {
639639
-Debug:($PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent -eq $true)
640640

641641
# Convert the $Response object into a nested hashtable.
642-
Write-Debug "PUT response: $Response"
643-
$Response = ConvertFrom-Json "$Response"
642+
Write-Debug "PUT response: $CCResponse"
643+
$Response = ConvertFrom-Json "$CCResponse"
644644
$Response = ConvertTo-Hashtable $Response
645645

646646
# What-If processing does not create a full response so we might have
@@ -716,7 +716,7 @@ function New-AzConnectedKubernetes {
716716
$options += " --debug"
717717
}
718718
if ($PSCmdlet.ShouldProcess($ClusterName, "Update Kubernetes cluster with Azure Arc")) {
719-
Write-Output "Executing helm upgrade command, this can take a few minutes...."
719+
Write-Verbose "Executing helm upgrade command, this can take a few minutes...."
720720
try {
721721
helm upgrade `
722722
--install azure-arc `
@@ -733,7 +733,7 @@ function New-AzConnectedKubernetes {
733733
--set global.azureEnvironment=AZUREPUBLICCLOUD `
734734
--set systemDefaultValues.clusterconnect-agent.enabled=true `
735735
--set global.kubernetesDistro=$Distribution `
736-
--set global.kubernetesInfra=$Infrastructure (-split $options)
736+
--set global.kubernetesInfra=$Infrastructure (-split $options) | Out-Null
737737
}
738738
catch {
739739
throw "Unable to install helm chart at $ChartPath"
@@ -744,7 +744,7 @@ function New-AzConnectedKubernetes {
744744
if ($PSBoundParameters.ContainsKey('OidcIssuerProfileEnabled') -or $PSBoundParameters.ContainsKey('WorkloadIdentityEnabled') ) {
745745
$ExistConnectedKubernetes = Get-AzConnectedKubernetes -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName @CommonPSBoundParameters
746746

747-
Write-Output "Cluster configuration is in progress..."
747+
Write-Verbose "Cluster configuration is in progress..."
748748
$timeout = [datetime]::Now.AddMinutes(60)
749749

750750
while (($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne "Succeeded") -and ($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne "Failed") -and ([datetime]::Now -lt $timeout)) {
@@ -753,7 +753,7 @@ function New-AzConnectedKubernetes {
753753
}
754754

755755
if ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq "Succeeded") {
756-
Write-Output "Cluster configuration succeeded."
756+
Write-Verbose "Cluster configuration succeeded."
757757
}
758758
elseif ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq "Failed") {
759759
Write-Error "Cluster configuration failed."
@@ -763,6 +763,6 @@ function New-AzConnectedKubernetes {
763763
}
764764
}
765765
}
766-
Return $Response
766+
Return $CCResponse
767767
}
768768
}

src/ConnectedKubernetes/ConnectedKubernetes.Autorest/custom/Set-AzConnectedKubernetes.ps1

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -675,12 +675,46 @@ function Set-AzConnectedKubernetes {
675675

676676
$PSBoundParameters.Add('ArcAgentryConfiguration', $arcAgentryConfigs)
677677

678-
Write-Output "Updating the connected cluster resource...."
679-
$Response = Az.ConnectedKubernetes.internal\Set-AzConnectedKubernetes @PSBoundParameters
680-
if ((-not $WhatIfPreference) -and (-not $Response)) {
678+
Write-Verbose "Updating the connected cluster resource...."
679+
$CCResponse = Az.ConnectedKubernetes.internal\Set-AzConnectedKubernetes @PSBoundParameters
680+
if ((-not $WhatIfPreference) -and (-not $CCResponse)) {
681681
Write-Error "Failed to update the 'Kubernetes - Azure Arc' resource"
682682
return
683683
}
684+
685+
# Wait for the agent state to settle before proceeding. If it doesn't,
686+
# we'll continue anyway - but remember and throw an error at the end.
687+
$agentsInTerminalState = $true
688+
if ($PSCmdlet.ShouldProcess($ClusterName, "Check agent state of the connected cluster")) {
689+
690+
$timeout = [datetime]::Now.AddMinutes(60)
691+
692+
for (;;) {
693+
$CCResponse = Get-AzConnectedKubernetes -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName @CommonPSBoundParameters
694+
695+
if ($null -eq $CCResponse.ArcAgentProfileAgentState) {
696+
Write-Verbose "No agent configuration in progress."
697+
break
698+
}
699+
if ($CCResponse.ArcAgentProfileAgentState -eq "Succeeded") {
700+
Write-Verbose "Cluster agent configuration succeeded."
701+
break
702+
}
703+
if ($CCResponse.ArcAgentProfileAgentState -eq "Failed") {
704+
Write-Error "Cluster agent configuration failed."
705+
break
706+
}
707+
if ([datetime]::Now -ge $timeout) {
708+
Write-Error "Cluster agent configuration timed out after 60 minutes."
709+
$agentsInTerminalState = $false
710+
break
711+
}
712+
713+
Write-Verbose "Cluster agent configuration is in progress..."
714+
Start-Sleep -Seconds 30
715+
}
716+
}
717+
684718
$arcAgentryConfigs = ConvertTo-ArcAgentryConfiguration `
685719
-ConfigurationSetting $ConfigurationSetting `
686720
-RedactedProtectedConfiguration $RedactedProtectedConfiguration `
@@ -690,8 +724,8 @@ function Set-AzConnectedKubernetes {
690724

691725

692726
# Convert the $Response object into a nested hashtable.
693-
Write-Debug "PUT response: $Response"
694-
$Response = ConvertFrom-Json "$Response"
727+
Write-Debug "PUT response: $CCResponse"
728+
$Response = ConvertFrom-Json "$CCResponse"
695729
$Response = ConvertTo-Hashtable $Response
696730

697731
# Whatif may return empty response
@@ -709,7 +743,7 @@ function Set-AzConnectedKubernetes {
709743
$ResponseStr = $Response | ConvertTo-Json -Depth 10
710744
Write-Debug "PUT response: $ResponseStr"
711745

712-
Write-Output "Preparing helm ...."
746+
Write-Verbose "Preparing helm ...."
713747

714748
if ($PSCmdlet.ShouldProcess('configDP', 'get helm values from config DP')) {
715749
$helmValuesDp = Get-HelmValuesFromConfigDP `
@@ -774,7 +808,7 @@ function Set-AzConnectedKubernetes {
774808
-Debug:($PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent -eq $true)
775809
}
776810

777-
Write-Output "Executing helm upgrade, this can take a few minutes ...."
811+
Write-Verbose "Executing helm upgrade, this can take a few minutes ...."
778812
Write-Debug $options -ErrorAction Continue
779813
if ($DebugPreference -eq "Continue") {
780814
$options += " --debug"
@@ -786,37 +820,18 @@ function Set-AzConnectedKubernetes {
786820
$ChartPath `
787821
--namespace $ReleaseInstallNamespace `
788822
-f $userValuesLocation `
789-
--wait (-split $options)
823+
--wait (-split $options) | Out-Null
790824
}
791825
catch {
792826
throw "Unable to install helm release"
793827
}
794-
Return $Response
795828
}
796829

797-
if ($PSCmdlet.ShouldProcess($ClusterName, "Check agent state of the connected cluster")) {
798-
if ($PSBoundParameters.ContainsKey('OidcIssuerProfileEnabled') -or $PSBoundParameters.ContainsKey('WorkloadIdentityEnabled') ) {
799-
$ExistConnectedKubernetes = Get-AzConnectedKubernetes -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName @CommonPSBoundParameters
800-
801-
Write-Output "Cluster configuration is in progress..."
802-
$timeout = [datetime]::Now.AddMinutes(60)
803-
804-
while (($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne "Succeeded") -and ($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne "Failed") -and ([datetime]::Now -lt $timeout)) {
805-
Start-Sleep -Seconds 30
806-
$ExistConnectedKubernetes = Get-AzConnectedKubernetes -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName @CommonPSBoundParameters
807-
}
808-
809-
if ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq "Succeeded") {
810-
Write-Output "Cluster configuration succeeded."
811-
}
812-
elseif ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq "Failed") {
813-
Write-Error "Cluster configuration failed."
814-
}
815-
else {
816-
Write-Error "Cluster configuration timed out after 60 minutes."
817-
}
818-
}
830+
# If there was a problem with agent state, throw the error now.
831+
if ($agentsInTerminalState -eq $false) {
832+
throw "Timed out waiting for Agent State to reach terminal state."
819833
}
834+
Return $CCResponse
820835
}
821836
}
822837

src/ConnectedKubernetes/ConnectedKubernetes.Autorest/generate-portal-ux.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,16 @@ function New-MetadataForParameterSet()
248248
$cmdletName = Get-MappedCmdletFromFunctionName $ParameterSetInfo.Name
249249
$description = (Get-CmdletAttribute -CmdletInfo $ParameterSetInfo -AttributeName "DescriptionAttribute").Description
250250
[object[]]$example = New-ExampleForParameterSet $ParameterSetInfo
251+
if ($Null -eq $example)
252+
{
253+
$example = @()
254+
}
255+
251256
[string[]]$signature = New-ParameterArrayInParameterSet $ParameterSetInfo
257+
if ($Null -eq $signature)
258+
{
259+
$signature = @()
260+
}
252261

253262
return @{
254263
Path = $httpPath

src/ConnectedKubernetes/ConnectedKubernetes/Az.ConnectedKubernetes.psd1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 11/8/2024
6+
# Generated on: 11/14/2024
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.12.0'
15+
ModuleVersion = '0.13.0'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core', 'Desktop'
@@ -112,8 +112,7 @@ PrivateData = @{
112112
# IconUri = ''
113113

114114
# ReleaseNotes of this module
115-
ReleaseNotes = '* Corrected function that only worked on Windows.
116-
* Prevented unexpected value changes where parameters that were never set are unchanged but replayed back as part of Set-AzConnectedKubernetes processing.'
115+
ReleaseNotes = '* Fixed output type of cmdlet'
117116

118117
# Prerelease string of this module
119118
# Prerelease = ''

src/ConnectedKubernetes/ConnectedKubernetes/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
-->
2020
## Upcoming Release
2121

22+
## Version 0.13.0
23+
* Fixed output type of cmdlet
24+
2225
## Version 0.12.0
2326
* Corrected function that only worked on Windows.
2427
* Prevented unexpected value changes where parameters that were never set are unchanged but replayed back as part of Set-AzConnectedKubernetes processing.

0 commit comments

Comments
 (0)