Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add null check for empty kube-config in connectedk8s proxy scenario #24

Merged
merged 19 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
25b5b03
[Bugfix] Supporting resource Predictions types in mdp commands (#8282)
ajaykn Nov 18, 2024
ac9a484
[Release] Update index.json for extension [ mdp ]
azclibot Nov 18, 2024
4ba987c
Set SA token default TTL to 1 day (#8290)
ABZhang0 Nov 18, 2024
71f420f
[Release] Update index.json for extension [ amg ]
azclibot Nov 18, 2024
b8fdf43
[connectedmachine] release preview version 2024-07-31 (#8214)
yaotongms Nov 18, 2024
47cc219
[Release] Update index.json for extension [ connectedmachine ]
azclibot Nov 18, 2024
c39b92b
Updating healthcareapis information to Health Data Services. (#8256)
msjasteppe Nov 19, 2024
4dacc7a
[connectedk8s] Update extension CLI to v1.10.3 (#8292)
bavneetsingh16 Nov 19, 2024
bcf51dc
[Release] Update index.json for extension [ connectedk8s ]
azclibot Nov 19, 2024
eb8290c
[Firewall] `az network firewall create`: add support public-ip for vh…
Pan-Qi Nov 19, 2024
b09ccf5
[Release] Update index.json for extension [ azure-firewall ]
azclibot Nov 19, 2024
da7e2d4
{CI} Sync resourceManagement.yml according To ADO Wiki Page - Service…
azclibot Nov 20, 2024
b3165cc
networkcloud 20240701preview version updated (#8291)
priyamshet Nov 20, 2024
207cad1
[Release] Update index.json for extension [ networkcloud ]
azclibot Nov 20, 2024
183ea32
add null check for empty kube-config in connectedk8s proxy scenario
Nov 21, 2024
d9ff42e
update the release notes
Nov 21, 2024
e2389f2
fix test for connectks proxy
Nov 21, 2024
ad1127f
fix connectedk8s proxy test
Nov 22, 2024
5d5a5af
merge upstream changes
Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/connectedk8s/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.10.4
++++++
* Fixed the issue where the 'connectedk8s proxy' command would fail if the kubeconfig file was empty.

1.10.3
++++++
* Fixed linting and styling issues, and added type annotations.
Expand Down
13 changes: 8 additions & 5 deletions src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3372,11 +3372,14 @@ def merge_kubernetes_configurations(
break
except (KeyError, TypeError):
continue

handle_merge(existing, addition, "clusters", replace)
handle_merge(existing, addition, "users", replace)
handle_merge(existing, addition, "contexts", replace)
existing["current-context"] = addition["current-context"]

if existing is None:
existing = addition
else:
handle_merge(existing, addition, "clusters", replace)
handle_merge(existing, addition, "users", replace)
handle_merge(existing, addition, "contexts", replace)
existing["current-context"] = addition["current-context"]

# check that ~/.kube/config is only read- and writable by its owner
if platform.system() != "Windows":
Expand Down
2 changes: 1 addition & 1 deletion src/connectedk8s/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.

VERSION = "1.10.3"
VERSION = "1.10.4"

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
4 changes: 4 additions & 0 deletions testing/pipeline/k8s-custom-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ stages:
parameters:
jobName: TroubleshootTest
path: ./test/configurations/Troubleshoot.Tests.ps1
- template: ./templates/run-test.yml
parameters:
jobName: Connectedk8sProxyTest
path: ./test/configurations/ConnectProxy.Tests.ps1
- job: BuildPublishExtension
pool:
vmImage: 'ubuntu-20.04'
Expand Down
62 changes: 62 additions & 0 deletions testing/test/configurations/ConnectProxy.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Describe 'Connectedk8s Proxy Scenario' {
BeforeAll {
. $PSScriptRoot/../helper/Constants.ps1
}

It 'Check if basic onboarding works correctly' {
az connectedk8s connect -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup -l $ARC_LOCATION --no-wait
$? | Should -BeTrue
Start-Sleep -Seconds 10

# Loop and retry until the configuration installs
$n = 0
do
{
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
$provisioningState = ($output | ConvertFrom-Json).provisioningState
Write-Host "Provisioning State: $provisioningState"
if ($provisioningState -eq $SUCCEEDED) {
break
}
Start-Sleep -Seconds 10
$n += 1
} while ($n -le $MAX_RETRY_ATTEMPTS)
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS
}

It 'Connectedk8s proxy test with non-empty kubeconfig' {
# Start the proxy command as a background job
$proxyJob = Start-Job -ScriptBlock {
param($ClusterName, $ResourceGroup)

# Capture output and errors
try {
$output = az connectedk8s proxy -n $ClusterName -g $ResourceGroup 2>&1
return @{ Success = $LASTEXITCODE -eq 0; Output = $output }
} catch {
return @{ Success = $false; Output = $_.Exception.Message }
}
} -ArgumentList $ENVCONFIG.arcClusterName, $ENVCONFIG.resourceGroup

# Wait for a certain amount of time (e.g., 30 seconds)
Start-Sleep -Seconds 30

# Display the output
Write-Host "Proxy Job State: $($proxyJob.State)"

# Check if the job ran successfully
$proxyJob.State | Should -Be 'Running'

Stop-Job -Job $proxyJob
Remove-Job -Job $proxyJob
}

It "Delete the connected instance" {
az connectedk8s delete -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --force -y
$? | Should -BeTrue

# Configuration should be removed from the resource model
az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
$? | Should -BeFalse
}
}
Loading