Skip to content

Commit

Permalink
fix: update windows MCS endpoints for MA to work in euap and other cl…
Browse files Browse the repository at this point in the history
…ouds (#870)

[comment]: # (Note that your PR title should follow the conventional
commit format: https://conventionalcommits.org/en/v1.0.0/#summary)
# PR Description

[comment]: # (The below checklist is for PRs adding new features. If a
box is not checked, add a reason why it's not needed.)
# New Feature Checklist

- [ ] List telemetry added about the feature.
- [ ] Link to the one-pager about the feature.
- [ ] List any tasks necessary for release (3P docs, AKS RP chart
changes, etc.) after merging the PR.
- [ ] Attach results of scale and perf testing.

[comment]: # (The below checklist is for code changes. Not all boxes
necessarily need to be checked. Build, doc, and template changes do not
need to fill out the checklist.)
# Tests Checklist

- [ ] Have end-to-end Ginkgo tests been run on your cluster and passed?
To bootstrap your cluster to run the tests, follow [these
instructions](/otelcollector/test/README.md#bootstrap-a-dev-cluster-to-run-ginkgo-tests).
  - Labels used when running the tests on your cluster:
    - [ ] `operator`
    - [ ] `windows`
    - [ ] `arm64`
    - [ ] `arc-extension`
- [ ] Have new tests been added? For features, have tests been added for
this feature? For fixes, is there a test that could have caught this
issue and could validate that the fix works?
  - [ ] Is a new scrape job needed?
- [ ] The scrape job was added to the folder
[test-cluster-yamls](/otelcollector/test/test-cluster-yamls/) in the
correct configmap or as a CR.
  - [ ] Was a new test label added?
- [ ] A string constant for the label was added to
[constants.go](/otelcollector/test/utils/constants.go).
- [ ] The label and description was added to the [test
README](/otelcollector/test/README.md).
- [ ] The label was added to this [PR
checklist](/.github/pull_request_template).
- [ ] The label was added as needed to
[testkube-test-crs.yaml](/otelcollector/test/testkube/testkube-test-crs.yaml).
  - [ ] Are additional API server permissions needed for the new tests?
- [ ] These permissions have been added to
[api-server-permissions.yaml](/otelcollector/test/testkube/api-server-permissions.yaml).
  - [ ] Was a new test suite (a new folder under `/tests`) added?
- [ ] The new test suite is included in
[testkube-test-crs.yaml](/otelcollector/test/testkube/testkube-test-crs.yaml).
  • Loading branch information
bragi92 authored May 1, 2024
1 parent 939e7a9 commit 2f82170
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions otelcollector/build/windows/scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ function Set-EnvironmentVariablesAndConfigParser {

############### Environment variables for MA {Start} ###############
[System.Environment]::SetEnvironmentVariable("MONITORING_ROLE_INSTANCE", "cloudAgentRoleInstanceIdentity", "Process")
[System.Environment]::SetEnvironmentVariable("MCS_AZURE_RESOURCE_ENDPOINT", "https://monitor.azure.com/", "Process")
[System.Environment]::SetEnvironmentVariable("MA_RoleEnvironment_OsType", "Windows", "Process")
[System.Environment]::SetEnvironmentVariable("MONITORING_VERSION", "2.0", "Process")
[System.Environment]::SetEnvironmentVariable("MONITORING_ROLE", "cloudAgentRoleIdentity", "Process")
[System.Environment]::SetEnvironmentVariable("MONITORING_IDENTITY", "use_ip_address", "Process")
[System.Environment]::SetEnvironmentVariable("MONITORING_ROLE_INSTANCE", "cloudAgentRoleInstanceIdentity", "Machine")
[System.Environment]::SetEnvironmentVariable("MCS_AZURE_RESOURCE_ENDPOINT", "https://monitor.azure.com/", "Machine")
[System.Environment]::SetEnvironmentVariable("MA_RoleEnvironment_OsType", "Windows", "Machine")
[System.Environment]::SetEnvironmentVariable("MONITORING_VERSION", "2.0", "Machine")
[System.Environment]::SetEnvironmentVariable("MONITORING_ROLE", "cloudAgentRoleIdentity", "Machine")
Expand All @@ -61,16 +59,59 @@ function Set-EnvironmentVariablesAndConfigParser {
[System.Environment]::SetEnvironmentVariable("ENABLE_MCS", "true", "Machine")
[System.Environment]::SetEnvironmentVariable("MDSD_USE_LOCAL_PERSISTENCY", "false", "Process")
[System.Environment]::SetEnvironmentVariable("MDSD_USE_LOCAL_PERSISTENCY", "false", "Machine")
[System.Environment]::SetEnvironmentVariable("MCS_GLOBAL_ENDPOINT", "https://global.handler.control.monitor.azure.com", "Process")
[System.Environment]::SetEnvironmentVariable("MA_RoleEnvironment_Location", $env:AKSREGION, "Process")
[System.Environment]::SetEnvironmentVariable("MA_RoleEnvironment_ResourceId", $env:CLUSTER, "Process")
[System.Environment]::SetEnvironmentVariable("MCS_CUSTOM_RESOURCE_ID", $env:CLUSTER, "Process")
[System.Environment]::SetEnvironmentVariable("customRegion", $env:AKSREGION, "Process")
[System.Environment]::SetEnvironmentVariable("MCS_GLOBAL_ENDPOINT", "https://global.handler.control.monitor.azure.com", "Machine")
[System.Environment]::SetEnvironmentVariable("MA_RoleEnvironment_Location", $env:AKSREGION, "Machine")
[System.Environment]::SetEnvironmentVariable("MA_RoleEnvironment_ResourceId", $env:CLUSTER, "Machine")
[System.Environment]::SetEnvironmentVariable("MCS_CUSTOM_RESOURCE_ID", $env:CLUSTER, "Machine")
[System.Environment]::SetEnvironmentVariable("customRegion", $env:AKSREGION, "Machine")


$mcs_endpoint = "https://monitor.azure.com/"
$mcs_globalendpoint = "https://global.handler.control.monitor.azure.com"
$customEnvironment = [System.Environment]::GetEnvironmentVariable("customEnvironment", "process").ToLower()

switch ($customEnvironment) {
"azurepubliccloud" {
if ($env:AKSREGION.ToLower() -eq "eastus2euap" -or $env:AKSREGION.ToLower() -eq "centraluseuap") {
$mcs_globalendpoint = "https://global.handler.canary.control.monitor.azure.com"
$mcs_endpoint = "https://monitor.azure.com/"
}
else {
$mcs_endpoint = "https://monitor.azure.com/"
$mcs_globalendpoint = "https://global.handler.control.monitor.azure.com"
}
}
"azureusgovernmentcloud" {
$mcs_globalendpoint = "https://global.handler.control.monitor.azure.us"
$mcs_endpoint = "https://monitor.azure.us/"
}
"azurechinacloud" {
$mcs_globalendpoint = "https://global.handler.control.monitor.azure.cn"
$mcs_endpoint = "https://monitor.azure.cn/"
}
"usnat" {
$mcs_globalendpoint = "https://global.handler.control.monitor.azure.eaglex.ic.gov"
$mcs_endpoint = "https://monitor.azure.eaglex.ic.gov/"
}
"ussec" {
$mcs_globalendpoint = "https://global.handler.control.monitor.azure.microsoft.scloud"
$mcs_endpoint = "https://monitor.azure.microsoft.scloud/"
}
default {
Write-Host "Unknown customEnvironment: $customEnvironment, setting mcs endpoint to default azurepubliccloud values"
$mcs_endpoint = "https://monitor.azure.com/"
$mcs_globalendpoint = "https://global.handler.control.monitor.azure.com"
}
}

[System.Environment]::SetEnvironmentVariable("MCS_AZURE_RESOURCE_ENDPOINT", $mcs_endpoint, "Process")
[System.Environment]::SetEnvironmentVariable("MCS_GLOBAL_ENDPOINT", $mcs_globalendpoint, "Process")
[System.Environment]::SetEnvironmentVariable("MCS_AZURE_RESOURCE_ENDPOINT", $mcs_endpoint, "Machine")
[System.Environment]::SetEnvironmentVariable("MCS_GLOBAL_ENDPOINT", $mcs_globalendpoint, "Machine")

############### Environment variables for MA {End} ###############

if ([string]::IsNullOrEmpty($env:MODE)) {
Expand Down Expand Up @@ -106,7 +147,6 @@ function Set-EnvironmentVariablesAndConfigParser {
[System.Environment]::SetEnvironmentVariable("AZMON_AGENT_CFG_FILE_VERSION", $config_file_version, "Machine")
}

$customEnvironment = [System.Environment]::GetEnvironmentVariable("customEnvironment", "process").ToLower()
switch ($customEnvironment) {
"azurepubliccloud" {
$encodedaikey = [System.Environment]::GetEnvironmentVariable("APPLICATIONINSIGHTS_AUTH_PUBLIC", "process")
Expand Down

0 comments on commit 2f82170

Please sign in to comment.