-
Notifications
You must be signed in to change notification settings - Fork 127
/
submit.go
604 lines (534 loc) · 20.4 KB
/
submit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
package submit
import (
"context"
"fmt"
"math"
"github.com/gogo/protobuf/types"
"github.com/gogo/status"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"k8s.io/apimachinery/pkg/util/clock"
"github.com/armadaproject/armada/internal/armada/configuration"
"github.com/armadaproject/armada/internal/armada/permissions"
"github.com/armadaproject/armada/internal/armada/repository"
"github.com/armadaproject/armada/internal/armada/submit/conversion"
"github.com/armadaproject/armada/internal/armada/submit/validation"
"github.com/armadaproject/armada/internal/common/armadacontext"
"github.com/armadaproject/armada/internal/common/armadaerrors"
"github.com/armadaproject/armada/internal/common/auth"
"github.com/armadaproject/armada/internal/common/auth/permission"
"github.com/armadaproject/armada/internal/common/pulsarutils"
"github.com/armadaproject/armada/internal/common/slices"
"github.com/armadaproject/armada/internal/common/util"
"github.com/armadaproject/armada/pkg/api"
"github.com/armadaproject/armada/pkg/armadaevents"
"github.com/armadaproject/armada/pkg/client/queue"
)
// Server is a service that accepts API calls according to the original Armada submit API and publishes messages
// to Pulsar based on those calls.
type Server struct {
publisher pulsarutils.Publisher
queueRepository repository.QueueRepository
queueCache repository.ReadOnlyQueueRepository
submissionConfig configuration.SubmissionConfig
deduplicator Deduplicator
authorizer auth.ActionAuthorizer
// Below are used only for testing
clock clock.Clock
idGenerator func() *armadaevents.Uuid
}
func NewServer(
publisher pulsarutils.Publisher,
queueRepository repository.QueueRepository,
queueCache repository.ReadOnlyQueueRepository,
submissionConfig configuration.SubmissionConfig,
deduplicator Deduplicator,
authorizer auth.ActionAuthorizer,
) *Server {
return &Server{
publisher: publisher,
queueRepository: queueRepository,
queueCache: queueCache,
submissionConfig: submissionConfig,
deduplicator: deduplicator,
authorizer: authorizer,
clock: clock.RealClock{},
idGenerator: func() *armadaevents.Uuid {
return armadaevents.MustProtoUuidFromUlidString(util.NewULID())
},
}
}
// SubmitJobs allows users to submit jobs to Armada. On receipt of a request, the following actions are performed:
// - The request is validated to make sure it is well formed. If this fails then an error is returned
// - Each JobRequestItem inside the request is checked to see if it is a duplicate
// - Each non-duplicate is converted into an armadaevents.SubmitMessage
// - All SubmitMessages are checked to see if the job they define can be scheduled (an example of a job that cannot
// be scheduled would be a job that requires more resources than exists on any node). If any message fails this
// check then an error is returned.
// - The SubmitMessages are published to Pulsar.
func (s *Server) SubmitJobs(grpcCtx context.Context, req *api.JobSubmitRequest) (*api.JobSubmitResponse, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
// Check that the user is actually allowed to submit jobs
userId, groups, err := s.authorize(ctx, req.Queue, permissions.SubmitAnyJobs, queue.PermissionVerbSubmit)
if err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
// Validate the request is well-formed
if err = validation.ValidateSubmitRequest(req, s.submissionConfig); err != nil {
return nil, status.Errorf(codes.InvalidArgument, err.Error())
}
// Get a mapping between req.ClientId and existing jobId. If such a mapping exists, it means that
// this job has already been submitted.
originalIds, err := s.deduplicator.GetOriginalJobIds(ctx, req.Queue, req.JobRequestItems)
if err != nil {
// Deduplication is best-effort, therefore this is not fatal
log.WithError(err).Warn("Error fetching original job ids, deduplication will not occur.")
}
submitMsgs := make([]*armadaevents.EventSequence_Event, 0, len(req.JobRequestItems))
jobResponses := make([]*api.JobSubmitResponseItem, 0, len(req.JobRequestItems))
idMappings := make(map[string]string, len(req.JobRequestItems))
for _, jobRequest := range req.JobRequestItems {
// Check if this job has already been submitted. If so we can simply return the previously submitted id
originalId, isDuplicate := originalIds[jobRequest.ClientId]
if isDuplicate {
ctx.Infof("Job with client id %s is a duplicate of %s", jobRequest.ClientId, originalId)
jobResponses = append(jobResponses, &api.JobSubmitResponseItem{JobId: originalId})
continue
}
// If we get to here then it isn't a duplicate. Create a Job submission and a job response
submitMsg := conversion.SubmitJobFromApiRequest(jobRequest, s.submissionConfig, req.JobSetId, req.Queue, userId, s.idGenerator)
eventTime := s.clock.Now().UTC()
submitMsgs = append(submitMsgs, &armadaevents.EventSequence_Event{
Created: &eventTime,
Event: &armadaevents.EventSequence_Event_SubmitJob{
SubmitJob: submitMsg,
},
})
jobResponses = append(jobResponses, &api.JobSubmitResponseItem{
JobId: armadaevents.MustUlidStringFromProtoUuid(submitMsg.JobId),
})
if jobRequest.ClientId != "" {
idMappings[jobRequest.ClientId] = armadaevents.MustUlidStringFromProtoUuid(submitMsg.JobId)
}
}
// If we have no submit msgs then we can return early
if len(submitMsgs) == 0 {
return &api.JobSubmitResponse{JobResponseItems: jobResponses}, nil
}
// Check if all jobs can be scheduled.
es := &armadaevents.EventSequence{
Queue: req.Queue,
JobSetName: req.JobSetId,
UserId: userId,
Groups: groups,
Events: submitMsgs,
}
err = s.publisher.PublishMessages(ctx, es)
if err != nil {
log.WithError(err).Error("failed send events to Pulsar")
return nil, status.Error(codes.Internal, "Failed to send events to Pulsar")
}
// Store the deduplication ids. Note that this will not be called if pulsar submission has failed, hence
// a partial pulsar submission can result in duplicate jobs.
if err = s.deduplicator.StoreOriginalJobIds(ctx, req.Queue, idMappings); err != nil {
log.WithError(err).Warn("failed to store deduplication ids")
}
return &api.JobSubmitResponse{JobResponseItems: jobResponses}, nil
}
func (s *Server) CancelJobs(grpcCtx context.Context, req *api.JobCancelRequest) (*api.CancellationResult, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
jobIds := []string{}
jobIds = append(jobIds, req.JobIds...)
if req.JobId != "" {
jobIds = append(jobIds, req.JobId)
}
jobIds = slices.Unique(jobIds)
if len(jobIds) == 0 {
log.Warnf("CancelJobs called for queue=%s and jobset=%s but with empty job id. Redirecting to CancelJobSet()", req.Queue, req.JobSetId)
_, err := s.CancelJobSet(ctx, &api.JobSetCancelRequest{
Queue: req.Queue,
JobSetId: req.JobSetId,
Reason: req.Reason,
})
if err != nil {
return nil, err
}
return &api.CancellationResult{
CancelledIds: []string{req.JobId}, // we return an empty string here which seems a bit nonsensical- but that's what the old code did!
}, nil
}
err := validation.ValidateQueueAndJobSet(req)
if err != nil {
return nil, err
}
userId, groups, err := s.authorize(ctx, req.Queue, permissions.CancelAnyJobs, queue.PermissionVerbCancel)
if err != nil {
return nil, err
}
var cancelledIds []string
es, cancelledIds := eventSequenceForJobIds(s.clock, jobIds, req.Queue, req.JobSetId, userId, groups, req.Reason)
err = s.publisher.PublishMessages(ctx, es)
if err != nil {
log.WithError(err).Error("failed send to Pulsar")
return nil, status.Error(codes.Internal, "Failed to send message")
}
return &api.CancellationResult{
CancelledIds: cancelledIds,
}, nil
}
func (s *Server) PreemptJobs(grpcCtx context.Context, req *api.JobPreemptRequest) (*types.Empty, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
err := validation.ValidateQueueAndJobSet(req)
if err != nil {
return nil, err
}
userId, groups, err := s.authorize(ctx, req.Queue, permissions.PreemptAnyJobs, queue.PermissionVerbPreempt)
if err != nil {
return nil, err
}
sequence, err := preemptJobEventSequenceForJobIds(s.clock, req.JobIds, req.Queue, req.JobSetId, userId, groups)
if err != nil {
return nil, err
}
err = s.publisher.PublishMessages(ctx, sequence)
if err != nil {
log.WithError(err).Error("failed send to Pulsar")
return nil, status.Error(codes.Internal, "Failed to send message")
}
return &types.Empty{}, nil
}
func preemptJobEventSequenceForJobIds(clock clock.Clock, jobIds []string, q, jobSet, userId string, groups []string) (*armadaevents.EventSequence, error) {
sequence := &armadaevents.EventSequence{
Queue: q,
JobSetName: jobSet,
UserId: userId,
Groups: groups,
Events: []*armadaevents.EventSequence_Event{},
}
eventTime := clock.Now().UTC()
for _, jobIdStr := range jobIds {
jobId, err := armadaevents.ProtoUuidFromUlidString(jobIdStr)
if err != nil {
log.WithError(err).Errorf("could not convert job id to uuid: %s", jobIdStr)
return nil, fmt.Errorf("could not convert job id to uuid: %s", jobIdStr)
}
sequence.Events = append(sequence.Events, &armadaevents.EventSequence_Event{
Created: &eventTime,
Event: &armadaevents.EventSequence_Event_JobPreemptionRequested{
JobPreemptionRequested: &armadaevents.JobPreemptionRequested{
JobId: jobId,
},
},
})
}
return sequence, nil
}
func (s *Server) ReprioritizeJobs(grpcCtx context.Context, req *api.JobReprioritizeRequest) (*api.JobReprioritizeResponse, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
err := validation.ValidateQueueAndJobSet(req)
if err != nil {
return nil, err
}
userId, groups, err := s.authorize(ctx, req.Queue, permissions.ReprioritizeAnyJobs, queue.PermissionVerbReprioritize)
if err != nil {
return nil, err
}
// results maps job ids to strings containing error messages.
results := make(map[string]string)
priority := conversion.PriorityAsInt32(req.NewPriority)
sequence := &armadaevents.EventSequence{
Queue: req.Queue,
JobSetName: req.JobSetId,
UserId: userId,
Groups: groups,
Events: make([]*armadaevents.EventSequence_Event, len(req.JobIds), len(req.JobIds)),
}
eventTime := s.clock.Now().UTC()
// No job ids implicitly indicates that all jobs in the job set should be re-prioritised.
if len(req.JobIds) == 0 {
sequence.Events = append(sequence.Events, &armadaevents.EventSequence_Event{
Created: &eventTime,
Event: &armadaevents.EventSequence_Event_ReprioritiseJobSet{
ReprioritiseJobSet: &armadaevents.ReprioritiseJobSet{
Priority: priority,
},
},
})
results[fmt.Sprintf("all jobs in job set %s", req.JobSetId)] = ""
}
// Otherwise, only the specified jobs should be re-prioritised.
for i, jobIdString := range req.JobIds {
jobId, err := armadaevents.ProtoUuidFromUlidString(jobIdString)
if err != nil {
results[jobIdString] = err.Error()
continue
}
sequence.Events[i] = &armadaevents.EventSequence_Event{
Created: &eventTime,
Event: &armadaevents.EventSequence_Event_ReprioritiseJob{
ReprioritiseJob: &armadaevents.ReprioritiseJob{
JobId: jobId,
Priority: priority,
},
},
}
results[jobIdString] = "" // empty string indicates no error
}
err = s.publisher.PublishMessages(ctx, sequence)
if err != nil {
log.WithError(err).Error("failed send to Pulsar")
return nil, status.Error(codes.Internal, "Failed to send message")
}
return &api.JobReprioritizeResponse{
ReprioritizationResults: results,
}, nil
}
func (s *Server) CancelJobSet(grpcCtx context.Context, req *api.JobSetCancelRequest) (*types.Empty, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
err := validation.ValidateQueueAndJobSet(req)
if err != nil {
return nil, err
}
err = validation.ValidateJobSetFilter(req.Filter)
if err != nil {
return nil, err
}
userId, groups, err := s.authorize(ctx, req.Queue, permissions.CancelAnyJobs, queue.PermissionVerbCancel)
if err != nil {
return nil, err
}
states := make([]armadaevents.JobState, len(req.GetFilter().GetStates()))
for i := 0; i < len(states); i++ {
switch req.GetFilter().GetStates()[i] {
case api.JobState_PENDING:
states[i] = armadaevents.JobState_PENDING
case api.JobState_QUEUED:
states[i] = armadaevents.JobState_QUEUED
case api.JobState_RUNNING:
states[i] = armadaevents.JobState_RUNNING
}
}
eventTime := s.clock.Now().UTC()
pulsarSchedulerSequence := &armadaevents.EventSequence{
Queue: req.Queue,
JobSetName: req.JobSetId,
UserId: userId,
Groups: groups,
Events: []*armadaevents.EventSequence_Event{
{
Created: &eventTime,
Event: &armadaevents.EventSequence_Event_CancelJobSet{
CancelJobSet: &armadaevents.CancelJobSet{
States: states,
Reason: util.Truncate(req.Reason, 512),
},
},
},
},
}
err = s.publisher.PublishMessages(ctx, pulsarSchedulerSequence)
if err != nil {
log.WithError(err).Error("failed to send cancel jobset message to pulsar")
return nil, status.Error(codes.Internal, "failed to send cancel jobset message to pulsar")
}
return &types.Empty{}, err
}
// Returns event sequence along with all valid job ids in the sequence
func eventSequenceForJobIds(clock clock.Clock, jobIds []string, queue, jobSet, userId string, groups []string, reason string) (*armadaevents.EventSequence, []string) {
sequence := &armadaevents.EventSequence{
Queue: queue,
JobSetName: jobSet,
UserId: userId,
Groups: groups,
Events: []*armadaevents.EventSequence_Event{},
}
var validIds []string
truncatedReason := util.Truncate(reason, 512)
eventTime := clock.Now().UTC()
for _, jobIdStr := range jobIds {
jobId, err := armadaevents.ProtoUuidFromUlidString(jobIdStr)
if err != nil {
log.WithError(err).Errorf("could not convert job id to uuid: %s", jobIdStr)
continue
}
validIds = append(validIds, jobIdStr)
sequence.Events = append(sequence.Events, &armadaevents.EventSequence_Event{
Created: &eventTime,
Event: &armadaevents.EventSequence_Event_CancelJob{
CancelJob: &armadaevents.CancelJob{
JobId: jobId,
Reason: truncatedReason,
},
},
})
}
return sequence, validIds
}
func (s *Server) CreateQueue(grpcCtx context.Context, req *api.Queue) (*types.Empty, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
err := s.authorizer.AuthorizeAction(ctx, permissions.CreateQueue)
var ep *armadaerrors.ErrUnauthorized
if errors.As(err, &ep) {
return nil, status.Errorf(codes.PermissionDenied, "[CreateQueue] error creating queue %s: %s", req.Name, ep)
} else if err != nil {
return nil, status.Errorf(codes.Unavailable, "[CreateQueue] error checking permissions: %s", err)
}
if len(req.UserOwners) == 0 {
principal := auth.GetPrincipal(ctx)
req.UserOwners = []string{principal.GetName()}
}
queue, err := queue.NewQueue(req)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "[CreateQueue] error validating queue: %s", err)
}
err = s.queueRepository.CreateQueue(ctx, queue)
var eq *repository.ErrQueueAlreadyExists
if errors.As(err, &eq) {
return nil, status.Errorf(codes.AlreadyExists, "[CreateQueue] error creating queue: %s", err)
} else if err != nil {
return nil, status.Errorf(codes.Unavailable, "[CreateQueue] error creating queue: %s", err)
}
return &types.Empty{}, nil
}
func (s *Server) CreateQueues(grpcCtx context.Context, req *api.QueueList) (*api.BatchQueueCreateResponse, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
var failedQueues []*api.QueueCreateResponse
// Create a queue for each element of the request body and return the failures.
for _, queue := range req.Queues {
_, err := s.CreateQueue(ctx, queue)
if err != nil {
failedQueues = append(failedQueues, &api.QueueCreateResponse{
Queue: queue,
Error: err.Error(),
})
}
}
return &api.BatchQueueCreateResponse{
FailedQueues: failedQueues,
}, nil
}
func (s *Server) UpdateQueue(grpcCtx context.Context, req *api.Queue) (*types.Empty, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
err := s.authorizer.AuthorizeAction(ctx, permissions.CreateQueue)
var ep *armadaerrors.ErrUnauthorized
if errors.As(err, &ep) {
return nil, status.Errorf(codes.PermissionDenied, "[UpdateQueue] error updating queue %s: %s", req.Name, ep)
} else if err != nil {
return nil, status.Errorf(codes.Unavailable, "[UpdateQueue] error checking permissions: %s", err)
}
queue, err := queue.NewQueue(req)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "[UpdateQueue] error: %s", err)
}
err = s.queueRepository.UpdateQueue(ctx, queue)
var e *repository.ErrQueueNotFound
if errors.As(err, &e) {
return nil, status.Errorf(codes.NotFound, "[UpdateQueue] error: %s", err)
} else if err != nil {
return nil, status.Errorf(codes.Unavailable, "[UpdateQueue] error getting queue %q: %s", queue.Name, err)
}
return &types.Empty{}, nil
}
func (s *Server) UpdateQueues(grpcCtx context.Context, req *api.QueueList) (*api.BatchQueueUpdateResponse, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
var failedQueues []*api.QueueUpdateResponse
// Create a queue for each element of the request body and return the failures.
for _, queue := range req.Queues {
_, err := s.UpdateQueue(ctx, queue)
if err != nil {
failedQueues = append(failedQueues, &api.QueueUpdateResponse{
Queue: queue,
Error: err.Error(),
})
}
}
return &api.BatchQueueUpdateResponse{
FailedQueues: failedQueues,
}, nil
}
func (s *Server) DeleteQueue(grpcCtx context.Context, req *api.QueueDeleteRequest) (*types.Empty, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
err := s.authorizer.AuthorizeAction(ctx, permissions.DeleteQueue)
var ep *armadaerrors.ErrUnauthorized
if errors.As(err, &ep) {
return nil, status.Errorf(codes.PermissionDenied, "[DeleteQueue] error deleting queue %s: %s", req.Name, ep)
} else if err != nil {
return nil, status.Errorf(codes.Unavailable, "[DeleteQueue] error checking permissions: %s", err)
}
err = s.queueRepository.DeleteQueue(ctx, req.Name)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "[DeleteQueue] error deleting queue %s: %s", req.Name, err)
}
return &types.Empty{}, nil
}
func (s *Server) GetQueue(grpcCtx context.Context, req *api.QueueGetRequest) (*api.Queue, error) {
ctx := armadacontext.FromGrpcCtx(grpcCtx)
queue, err := s.queueRepository.GetQueue(ctx, req.Name)
var e *repository.ErrQueueNotFound
if errors.As(err, &e) {
return nil, status.Errorf(codes.NotFound, "[GetQueue] error: %s", err)
} else if err != nil {
return nil, status.Errorf(codes.Unavailable, "[GetQueue] error getting queue %q: %s", req.Name, err)
}
return queue.ToAPI(), nil
}
func (s *Server) GetQueues(req *api.StreamingQueueGetRequest, stream api.Submit_GetQueuesServer) error {
ctx := armadacontext.FromGrpcCtx(stream.Context())
// Receive once to get information about the number of queues to return
numToReturn := req.GetNum()
if numToReturn < 1 {
numToReturn = math.MaxUint32
}
queues, err := s.queueRepository.GetAllQueues(ctx)
if err != nil {
return err
}
for i, queue := range queues {
if uint32(i) < numToReturn {
err := stream.Send(&api.StreamingQueueMessage{
Event: &api.StreamingQueueMessage_Queue{Queue: queue.ToAPI()},
})
if err != nil {
return err
}
}
}
err = stream.Send(&api.StreamingQueueMessage{
Event: &api.StreamingQueueMessage_End{
End: &api.EndMarker{},
},
})
if err != nil {
return err
}
return nil
}
// authorize authorizes a user request to submit a state transition message to the log.
// User information used for authorization is extracted from the provided context.
// Checks that the user has either anyPerm (e.g., permissions.SubmitAnyJobs) or perm (e.g., PermissionVerbSubmit) for this queue.
// Returns the userId and groups extracted from the context.
func (s *Server) authorize(
ctx *armadacontext.Context,
queueName string,
anyPerm permission.Permission,
perm queue.PermissionVerb,
) (string, []string, error) {
principal := auth.GetPrincipal(ctx)
userId := principal.GetName()
groups := principal.GetGroupNames()
q, err := s.queueCache.GetQueue(ctx, queueName)
if err != nil {
return userId, groups, err
}
err = s.authorizer.AuthorizeQueueAction(ctx, q, anyPerm, perm)
return userId, groups, err
}
func (s *Server) GetUser(ctx *armadacontext.Context) string {
principal := auth.GetPrincipal(ctx)
return principal.GetName()
}
func (s *Server) Health(_ context.Context, _ *types.Empty) (*api.HealthCheckResponse, error) {
// For now, lets make the health check really simple.
return &api.HealthCheckResponse{Status: api.HealthCheckResponse_SERVING}, nil
}