Skip to content

Commit dbdfb73

Browse files
craig[bot]golgeekandyyang890
committed
148328: roachprod: azure vm identity and role assignment r=golgeek a=golgeek 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. Resolves #149811 Epic: none Release note: None 153078: jobfrontier: change Get to accept read-only frontier r=msbutler a=andyyang890 **span: redefine Frontier in terms of ReadOnlyFrontier** The `ReadOnlyFrontier` interface is a strict subset of `Frontier` and to reduce duplicate code, this commit redefines `Frontier` in terms of `ReadOnlyFrontier`. Release note: None --- **jobfrontier: change Get to accept read-only frontier** This patch changes `Get` to accept a read-only frontier to prevent any accidental modification of the passed-in frontier. Release note: None --- Epic: None Co-authored-by: Ludovic Leroux <[email protected]> Co-authored-by: Andy Yang <[email protected]>
3 parents e8d9cfd + 0345413 + a78dff7 commit dbdfb73

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed

pkg/jobs/jobfrontier/frontier.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ func Get(
8282
// InfoStorage keys are prefixed with "frontier/", the passed name, and then a
8383
// chunk identifier.
8484
func Store(
85-
ctx context.Context, txn isql.Txn, jobID jobspb.JobID, name string, frontier span.Frontier,
85+
ctx context.Context,
86+
txn isql.Txn,
87+
jobID jobspb.JobID,
88+
name string,
89+
frontier span.ReadOnlyFrontier,
8690
) error {
8791
return storeChunked(ctx, txn, jobID, name, frontier, 2<<20 /* 2mb */)
8892
}
@@ -92,7 +96,7 @@ func storeChunked(
9296
txn isql.Txn,
9397
jobID jobspb.JobID,
9498
name string,
95-
frontier span.Frontier,
99+
frontier span.ReadOnlyFrontier,
96100
chunkSize int,
97101
) error {
98102
infoStorage := jobs.InfoStorageForJob(txn, jobID)

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

pkg/util/span/frontier.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,14 @@ import (
2727
// Frontier is not safe for concurrent modification, but MakeConcurrentFrontier
2828
// can be used to make thread safe frontier.
2929
type Frontier interface {
30+
ReadOnlyFrontier
31+
3032
// AddSpansAt adds the provided spans to the frontier at the provided timestamp.
3133
// If the span overlaps any spans already tracked by the frontier, the tree is adjusted
3234
// to hold union of the span and the overlaps, with all entries assigned startAt starting
3335
// timestamp.
3436
AddSpansAt(startAt hlc.Timestamp, spans ...roachpb.Span) error
3537

36-
// Frontier returns the minimum timestamp being tracked.
37-
Frontier() hlc.Timestamp
38-
39-
// PeekFrontierSpan returns one of the spans at the Frontier.
40-
PeekFrontierSpan() roachpb.Span
41-
4238
// Forward advances the timestamp for a span. Any part of the span that doesn't
4339
// overlap the tracked span set will be ignored. True is returned if the
4440
// frontier advanced as a result.
@@ -49,6 +45,16 @@ type Frontier interface {
4945
// letting a frontier be GCed is safe in that it won't cause a memory leak,
5046
// but it will prevent frontier nodes from being efficiently re-used.
5147
Release()
48+
}
49+
50+
// ReadOnlyFrontier is a subset of Frontier with only the methods
51+
// that are read-only.
52+
type ReadOnlyFrontier interface {
53+
// Frontier returns the minimum timestamp being tracked.
54+
Frontier() hlc.Timestamp
55+
56+
// PeekFrontierSpan returns one of the spans at the Frontier.
57+
PeekFrontierSpan() roachpb.Span
5258

5359
// Entries returns an iterator over the entries in the frontier.
5460
// Updates to the frontier are restricted until iteration is stopped.

pkg/util/span/multi_frontier.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,6 @@ func (f *MultiFrontier[P]) String() string {
241241
return buf.String()
242242
}
243243

244-
// ReadOnlyFrontier is a subset of Frontier with only the methods
245-
// that are read-only.
246-
type ReadOnlyFrontier interface {
247-
Frontier() hlc.Timestamp
248-
PeekFrontierSpan() roachpb.Span
249-
Entries() iter.Seq2[roachpb.Span, hlc.Timestamp]
250-
SpanEntries(span roachpb.Span) iter.Seq2[roachpb.Span, hlc.Timestamp]
251-
Len() int
252-
String() string
253-
}
254-
255-
var _ ReadOnlyFrontier = Frontier(nil)
256-
257244
// Frontiers returns an iterator over the sub-frontiers (with read-only access).
258245
func (f *MultiFrontier[P]) Frontiers() iter.Seq2[P, ReadOnlyFrontier] {
259246
return func(yield func(P, ReadOnlyFrontier) bool) {

0 commit comments

Comments
 (0)