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

Replace Azure Service Principal auth with Azure Workload Identity auth in functional tests #7787

Merged
merged 21 commits into from
Aug 13, 2024

Conversation

willdavsmith
Copy link
Contributor

@willdavsmith willdavsmith commented Aug 7, 2024

Description

  • Switch Azure SP auth to WI in functional tests
  • Fix issue with Azure WI + application WI in applications-rp
  • Fix issue with Azure WI in terraform
  • Adding workflow-dispatch triggers

Example successful workflow: https://github.com/radius-project/radius/actions/runs/10311808492

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).
  • This pull request adds or changes features of Radius and has an approved issue (issue link required).
  • This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional).

Fixes: #7715

Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Copy link

github-actions bot commented Aug 7, 2024

Unit Tests

3 299 tests  ±0   3 293 ✅ ±0   3m 53s ⏱️ -2s
  263 suites ±0       6 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 5529ca1. ± Comparison against base commit d01ecf9.

This pull request removes 6 and adds 6 tests. Note that renamed tests count towards both.
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_ServicePrincipal/do_not_refresh_credential
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_ServicePrincipal/invalid_credential
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_ServicePrincipal/same_credentials
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_WorkloadIdentity/do_not_refresh_credential
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_WorkloadIdentity/invalid_credential
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_WorkloadIdentity/same_credentials
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_ServicePrincipal/do_not_refresh_service_principal_credential
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_ServicePrincipal/invalid_service_principal_credential
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_ServicePrincipal/same_service_principal_credentials
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_WorkloadIdentity/do_not_refresh_workload_identity_credential
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_WorkloadIdentity/invalid_workload_identity_credential
github.com/radius-project/radius/pkg/azure/credential ‑ Test_RefreshCredentials_WorkloadIdentity/same_workload_identity_credentials

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 53.33333% with 7 lines in your changes missing coverage. Please review.

Project coverage is 61.06%. Comparing base (d01ecf9) to head (5529ca1).

Files Patch % Lines
pkg/azure/credential/ucpcredentials.go 54.54% 4 Missing and 1 partial ⚠️
...erp/handlers/azure_userassigned_managedidentity.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7787      +/-   ##
==========================================
+ Coverage   61.05%   61.06%   +0.01%     
==========================================
  Files         523      523              
  Lines       27457    27466       +9     
==========================================
+ Hits        16763    16772       +9     
- Misses       9209     9210       +1     
+ Partials     1485     1484       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: willdavsmith <[email protected]>
@@ -171,14 +171,21 @@ func refreshAzureWorkloadIdentityCredentials(ctx context.Context, c *UCPCredenti

logger.Info("Retrieved Azure Credential - ClientID: " + azureWorkloadIdentityCredential.ClientID)

var opt *azidentity.DefaultAzureCredentialOptions
var opt *azidentity.WorkloadIdentityCredentialOptions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood what this code did on the first workload identity PR. this should have been WorkloadIdentityCredential instead.

// this well known path.
// https://azure.github.io/azure-workload-identity/docs/installation/mutating-admission-webhook.html
// https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs#argument-reference
azureOIDCTokenFilePath = "/var/run/secrets/azure/tokens/azure-identity-token"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are the changes to make Terraform + Azure WI work.

configMap[azureUseCLIParam] = false
configMap[azureUseOIDCParam] = true
configMap[azureOIDCTokenFilePathParam] = azureOIDCTokenFilePath
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now this should work for AKS and non-AKS clusters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

@@ -1,6 +1,6 @@
module github.com/radius-project/radius/test/magpiego

go 1.22
go 1.22.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this because I was getting an error trying to build this image on arm64

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Can you share the error message? It was working fine for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go: downloading go1.22 (darwin/arm64)
go: download go1.22 for darwin/arm64: toolchain not available

@@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0.0"
version = "~> 3.114.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~> 3.0.0 will only match 3.0.*, but workload identity for azurerm needs greater than 3.7. 3.114 is the latest version as of today

@willdavsmith willdavsmith changed the title [WIP/ Do not review] Replacing Azure SP auth with WI in functional tests Replacing Azure SP auth with WI in functional tests Aug 8, 2024
@willdavsmith willdavsmith marked this pull request as ready for review August 8, 2024 21:58
@willdavsmith willdavsmith requested review from a team as code owners August 8, 2024 21:58
@@ -95,7 +95,7 @@ jobs:
build:
name: Build Radius for test
runs-on: ubuntu-latest
if: github.event_name == 'repository_dispatch' || (github.event_name == 'schedule' && github.repository == 'radius-project/radius') || github.event_name == 'workflow_run'
if: github.event_name == 'repository_dispatch' || (github.event_name == 'schedule' && github.repository == 'radius-project/radius') || github.event_name == 'workflow_run' || github.event_name == 'workflow_dispatch'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workflow_dispatch won't work yet unless you set up the federated credential to allow your branch. for testing this is what I did. in the future we should switch to github environments, but for now it doesn't hurt to have this.

Signed-off-by: willdavsmith <[email protected]>
@@ -49,6 +49,9 @@ type UCPCredentialOptions struct {

// ClientOptions is the options for azure client.
ClientOptions *azcore.ClientOptions

// TokenFilePath is the path to the azure token file (for use with Azure workload identity)
TokenFilePath string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this to make this file unit testable. the azure sdk library will use the environment variable in the real world

@willdavsmith willdavsmith changed the title Replacing Azure SP auth with WI in functional tests Replacing Azure Service Principal auth with Azure Workload Identity auth in functional tests Aug 9, 2024
@willdavsmith willdavsmith changed the title Replacing Azure Service Principal auth with Azure Workload Identity auth in functional tests Replace Azure Service Principal auth with Azure Workload Identity auth in functional tests Aug 9, 2024
// this well known path.
// https://azure.github.io/azure-workload-identity/docs/installation/mutating-admission-webhook.html
// https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs#argument-reference
azureOIDCTokenFilePath = "/var/run/secrets/azure/tokens/azure-identity-token"
Copy link
Contributor

@lakshmimsft lakshmimsft Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: will we be able to retrieve the TokenFilePath in the fetchAzureCredentials() call (eg line 129 below) instead of the const value here, say, in a future PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we totally could - if we have a user ask us to make this configurable then we can. for now it looks like most if not everyone uses the standard well known file path established by the azure ad workload identity project.

@radius-functional-tests
Copy link

radius-functional-tests bot commented Aug 9, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository radius-project/radius
Commit ref 0bac281
Unique ID funccb8288cc69
Image tag pr-funccb8288cc69
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.1.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funccb8288cc69
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funccb8288cc69
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funccb8288cc69
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funccb8288cc69
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting datastoresrp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
✅ datastoresrp-cloud functional tests succeeded
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

Copy link
Contributor

@lakshmimsft lakshmimsft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@radius-functional-tests
Copy link

radius-functional-tests bot commented Aug 13, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository radius-project/radius
Commit ref 5529ca1
Unique ID funcb622ff36c4
Image tag pr-funcb622ff36c4
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.1.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funcb622ff36c4
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funcb622ff36c4
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcb622ff36c4
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcb622ff36c4
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting datastoresrp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ datastoresrp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@willdavsmith willdavsmith merged commit 9ed50f4 into main Aug 13, 2024
30 checks passed
@willdavsmith willdavsmith deleted the willdavsmith/ft-wi-main branch August 13, 2024 18:24
superbeeny pushed a commit to superbeeny/radius that referenced this pull request Aug 14, 2024
…h in functional tests (radius-project#7787)

# Description

* Switch Azure SP auth to WI in functional tests
* Fix issue with Azure WI + application WI in applications-rp
* Fix issue with Azure WI in terraform
* Adding `workflow-dispatch` triggers

Example successful workflow:
https://github.com/radius-project/radius/actions/runs/10311808492

## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->

- This pull request fixes a bug in Radius and has an approved issue
(issue link required).
- This pull request adds or changes features of Radius and has an
approved issue (issue link required).
- This pull request is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
(issue link optional).

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: radius-project#7715

---------

Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: Will Smith <[email protected]>
Reshrahim pushed a commit to Reshrahim/radius that referenced this pull request Aug 27, 2024
…h in functional tests (radius-project#7787)

# Description

* Switch Azure SP auth to WI in functional tests
* Fix issue with Azure WI + application WI in applications-rp
* Fix issue with Azure WI in terraform
* Adding `workflow-dispatch` triggers

Example successful workflow:
https://github.com/radius-project/radius/actions/runs/10311808492

## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->

- This pull request fixes a bug in Radius and has an approved issue
(issue link required).
- This pull request adds or changes features of Radius and has an
approved issue (issue link required).
- This pull request is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
(issue link optional).

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: radius-project#7715

---------

Signed-off-by: willdavsmith <[email protected]>
Signed-off-by: Will Smith <[email protected]>
Signed-off-by: Reshma Abdul Rahim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Azure Workload Identity in functional test runs
4 participants