Skip to content

Commit 0345413

Browse files
committed
roachprod: azure vm identities
Previously Azure VMs didn't have an identity attached at creation, which meant they couldn't perform actions requiring authentication via the Azure metadata server. As some roachtests require access to an Azure storage container to pull and push fixtures, a User Managed Identity will now be assigned to the VMs at creation in order to simplify the credentials management. One `rp-roachtest` UMI has been created in each subscription used to run roachtests. These UMIs have been assigned a `roachtest` role that grants blob management in Azure storage containers in the same subscription. Since VMs are only attached a single identity, this is compatible with `DefaultAzureCredential` without specifying any other credentials. The subscription scope ensures that no test-production fixtures will be created or updated during tests development (in the `Sponsorship` sub), and that the nightly tests triggered from TeamCity (in the `e2e-infra` sub) will always be isolated. This requires the creation of one storage account per subscription roachtests are triggered on, and will require the tests to implement logic to determine the storage account to use based on the current subscription ID, which can be accessed via the `AZURE_SUBSCRIPTION_ID` environment variable. Epic: none Release note: None
1 parent 9e0ba6b commit 0345413

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pkg/roachprod/vm/azure/azure.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ const (
4646
remoteUser = "ubuntu"
4747
tagComment = "comment"
4848
tagSubnet = "subnetPrefix"
49+
50+
// UserManagedIdentity expected to exist in the subscription.
51+
// This identity will be associated to the VMs and will grant permissions
52+
// for roachprod testing.
53+
userManagedIdentityName = "rp-roachtest"
54+
userManagedIdentityResourceGroup = "rp-roachtest"
4955
)
5056

5157
// providerInstance is the instance to be registered into vm.Providers by Init.
@@ -983,6 +989,17 @@ func (p *Provider) createVM(
983989
Location: group.Location,
984990
Zones: to.StringSlicePtr([]string{zone.AvailabilityZone}),
985991
Tags: tags,
992+
Identity: &compute.VirtualMachineIdentity{
993+
Type: compute.ResourceIdentityTypeUserAssigned,
994+
UserAssignedIdentities: map[string]*compute.UserAssignedIdentitiesValue{
995+
fmt.Sprintf(
996+
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ManagedIdentity/userAssignedIdentities/%s",
997+
sub,
998+
userManagedIdentityResourceGroup,
999+
userManagedIdentityName,
1000+
): {},
1001+
},
1002+
},
9861003
VirtualMachineProperties: &compute.VirtualMachineProperties{
9871004
HardwareProfile: &compute.HardwareProfile{
9881005
VMSize: compute.VirtualMachineSizeTypes(providerOpts.MachineType),
@@ -1102,6 +1119,7 @@ func (p *Provider) createVM(
11021119
if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
11031120
return
11041121
}
1122+
11051123
return future.Result(client)
11061124
}
11071125

0 commit comments

Comments
 (0)