@@ -89,24 +89,25 @@ func NewAcquirer(ctx context.Context, logger slog.Logger, store AcquirerStore, p
89
89
// done, or the database returns an error _other_ than that no jobs are available.
90
90
// If no jobs are available, this method handles retrying as appropriate.
91
91
func (a * Acquirer ) AcquireJob (
92
- ctx context.Context , worker uuid.UUID , pt []database.ProvisionerType , tags Tags ,
92
+ ctx context.Context , organization uuid. UUID , worker uuid.UUID , pt []database.ProvisionerType , tags Tags ,
93
93
) (
94
94
retJob database.ProvisionerJob , retErr error ,
95
95
) {
96
96
logger := a .logger .With (
97
+ slog .F ("organization_id" , organization ),
97
98
slog .F ("worker_id" , worker ),
98
99
slog .F ("provisioner_types" , pt ),
99
100
slog .F ("tags" , tags ))
100
101
logger .Debug (ctx , "acquiring job" )
101
- dk := domainKey (pt , tags )
102
+ dk := domainKey (organization , pt , tags )
102
103
dbTags , err := tags .ToJSON ()
103
104
if err != nil {
104
105
return database.ProvisionerJob {}, err
105
106
}
106
107
// buffer of 1 so that cancel doesn't deadlock while writing to the channel
107
108
clearance := make (chan struct {}, 1 )
108
109
for {
109
- a .want (pt , tags , clearance )
110
+ a .want (organization , pt , tags , clearance )
110
111
select {
111
112
case <- ctx .Done ():
112
113
err := ctx .Err ()
@@ -120,6 +121,7 @@ func (a *Acquirer) AcquireJob(
120
121
case <- clearance :
121
122
logger .Debug (ctx , "got clearance to call database" )
122
123
job , err := a .store .AcquireProvisionerJob (ctx , database.AcquireProvisionerJobParams {
124
+ OrganizationID : organization ,
123
125
StartedAt : sql.NullTime {
124
126
Time : dbtime .Now (),
125
127
Valid : true ,
@@ -152,8 +154,8 @@ func (a *Acquirer) AcquireJob(
152
154
}
153
155
154
156
// want signals that an acquiree wants clearance to query for a job with the given dKey.
155
- func (a * Acquirer ) want (pt []database.ProvisionerType , tags Tags , clearance chan <- struct {}) {
156
- dk := domainKey (pt , tags )
157
+ func (a * Acquirer ) want (organization uuid. UUID , pt []database.ProvisionerType , tags Tags , clearance chan <- struct {}) {
158
+ dk := domainKey (organization , pt , tags )
157
159
a .mu .Lock ()
158
160
defer a .mu .Unlock ()
159
161
cleared := false
@@ -404,13 +406,16 @@ type dKey string
404
406
// unprintable control character and won't show up in any "reasonable" set of
405
407
// string tags, even in non-Latin scripts. It is important that Tags are
406
408
// validated not to contain this control character prior to use.
407
- func domainKey (pt []database.ProvisionerType , tags Tags ) dKey {
409
+ func domainKey (orgID uuid.UUID , pt []database.ProvisionerType , tags Tags ) dKey {
410
+ sb := strings.Builder {}
411
+ _ , _ = sb .WriteString (orgID .String ())
412
+ _ = sb .WriteByte (0x00 )
413
+
408
414
// make a copy of pt before sorting, so that we don't mutate the original
409
415
// slice or underlying array.
410
416
pts := make ([]database.ProvisionerType , len (pt ))
411
417
copy (pts , pt )
412
418
slices .Sort (pts )
413
- sb := strings.Builder {}
414
419
for _ , t := range pts {
415
420
_ , _ = sb .WriteString (string (t ))
416
421
_ = sb .WriteByte (0x00 )
0 commit comments