Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 611b81f

Browse files
Don't Send Identity Headers If In DF (#67)
* Don't send identity for clusters in dogfood * Add location to model for identity * Add identity validation to testing
1 parent ec40c30 commit 611b81f

File tree

8 files changed

+32
-3
lines changed

8 files changed

+32
-3
lines changed

src/k8s-extension/HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Release History
44
===============
55

6+
0.6.1
7+
++++++++++++++++++
8+
* Remove sending identity for clusters in Dogfood
9+
* Provide fix for getting tested distros for microsoft.openservicemesh
10+
* Add location to model for identity
11+
612
0.6.0
713
++++++++++++++++++
814
* Update extension resource models to Track2

src/k8s-extension/azext_k8s_extension/consts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
EXTENSION_PACKAGE_NAME = "azext_k8s_extension"
99
PROVIDER_NAMESPACE = 'Microsoft.KubernetesConfiguration'
1010
REGISTERED = "Registered"
11+
DF_RM_ENDPOINT = 'https://api-dogfood.resources.windows-int.net/'

src/k8s-extension/azext_k8s_extension/custom.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ def create_k8s_extension(cmd, client, resource_group_name, cluster_name, name, c
138138
validate_cc_registration(cmd)
139139

140140
# Create identity, if required
141-
if create_identity:
141+
# We don't create the identity if we are in DF
142+
if create_identity and not __is_dogfood_cluster(cmd):
142143
extension_instance.identity, extension_instance.location = \
143144
__create_identity(cmd, resource_group_name, cluster_name, cluster_type, cluster_rp)
144145

@@ -292,3 +293,7 @@ def __get_config_settings_from_file(file_path):
292293
raise Exception("File {} is empty".format(file_path))
293294

294295
return settings
296+
297+
298+
def __is_dogfood_cluster(cmd):
299+
return cmd.cli_ctx.cloud.endpoints.resource_manager == consts.DF_RM_ENDPOINT

src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ class ExtensionInstance(ProxyResource):
279279
:param identity: The identity of the configuration.
280280
:type identity:
281281
~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ConfigurationIdentity
282+
:param location: Location of resource type
283+
:type location: str
282284
"""
283285

284286
_validation = {
@@ -311,6 +313,7 @@ class ExtensionInstance(ProxyResource):
311313
'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'},
312314
'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'},
313315
'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'},
316+
'location': {'key': 'location', 'type': 'str'},
314317
}
315318

316319
def __init__(
@@ -332,6 +335,7 @@ def __init__(
332335
self.last_status_time = None
333336
self.error_info = None
334337
self.identity = kwargs.get('identity', None)
338+
self.location = kwargs.get('location', None)
335339

336340

337341
class ExtensionInstancesList(msrest.serialization.Model):

src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ class ExtensionInstance(ProxyResource):
297297
:param identity: The identity of the configuration.
298298
:type identity:
299299
~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ConfigurationIdentity
300+
:param location: Location of resource type
301+
:type location: str
300302
"""
301303

302304
_validation = {
@@ -329,6 +331,7 @@ class ExtensionInstance(ProxyResource):
329331
'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'},
330332
'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'},
331333
'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'},
334+
'location': {'key': 'location', 'type': 'str'},
332335
}
333336

334337
def __init__(
@@ -344,6 +347,7 @@ def __init__(
344347
configuration_protected_settings: Optional[Dict[str, str]] = None,
345348
statuses: Optional[List["ExtensionStatus"]] = None,
346349
identity: Optional["ConfigurationIdentity"] = None,
350+
location: Optional[str] = None,
347351
**kwargs
348352
):
349353
super(ExtensionInstance, self).__init__(system_data=system_data, **kwargs)
@@ -361,6 +365,7 @@ def __init__(
361365
self.last_status_time = None
362366
self.error_info = None
363367
self.identity = identity
368+
self.location = location
364369

365370

366371
class ExtensionInstancesList(msrest.serialization.Model):

src/k8s-extension/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# TODO: Add any additional SDK dependencies here
3333
DEPENDENCIES = []
3434

35-
VERSION = "0.6.0"
35+
VERSION = "0.6.1"
3636

3737
with open('README.rst', 'r', encoding='utf-8') as f:
3838
README = f.read()

testing/test/extensions/public/AzureMonitor.Tests.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Describe 'Azure Monitor Testing' {
2424
do
2525
{
2626
if (Has-ExtensionData $extensionName) {
27-
break
27+
if (Has-Identity-Provisioned) {
28+
break
29+
}
2830
}
2931
Start-Sleep -Seconds 10
3032
$n += 1

testing/test/helper/Helper.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ function Has-ExtensionData {
1818
return $false
1919
}
2020

21+
22+
function Has-Identity-Provisioned {
23+
$output = kubectl get azureclusteridentityrequests -n azure-arc container-insights-clusteridentityrequest -o json | ConvertFrom-Json
24+
return ($null -ne $output.status.expirationTime) -and ($null -ne $output.status.tokenReference.dataName) -and ($null -ne $output.status.tokenReference.secretName)
25+
}
26+
2127
function Get-ExtensionStatus {
2228
param(
2329
[string]$extensionName

0 commit comments

Comments
 (0)