Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: scheduler/appengine/apiservers/scheduler.go

Issue 2993933002: scheduler ACLs: improve ACL-related error handling in UI and API. (Closed)
Patch Set: rebase Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | scheduler/appengine/apiservers/scheduler_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. 1 // Copyright 2016 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 State: &scheduler.JobState{ 67 State: &scheduler.JobState{
68 UiStatus: string(presentation.GetPublicStateKind (ej, traits)), 68 UiStatus: string(presentation.GetPublicStateKind (ej, traits)),
69 }, 69 },
70 Paused: ej.Paused, 70 Paused: ej.Paused,
71 } 71 }
72 } 72 }
73 return &scheduler.JobsReply{Jobs: jobs, NextCursor: ""}, nil 73 return &scheduler.JobsReply{Jobs: jobs, NextCursor: ""}, nil
74 } 74 }
75 75
76 func (s SchedulerServer) GetInvocations(ctx context.Context, in *scheduler.Invoc ationsRequest) (*scheduler.InvocationsReply, error) { 76 func (s SchedulerServer) GetInvocations(ctx context.Context, in *scheduler.Invoc ationsRequest) (*scheduler.InvocationsReply, error) {
77 ejob, err := s.Engine.GetVisibleJob(ctx, getJobId(in.GetJobRef()))
78 if err != nil {
79 return nil, grpc.Errorf(codes.Internal, "internal error: %s", er r)
80 }
81 if ejob == nil {
82 return nil, grpc.Errorf(codes.NotFound, "Job does not exist or y ou have no access")
83 }
84
85 pageSize := 50 77 pageSize := 50
86 if in.PageSize > 0 && int(in.PageSize) < pageSize { 78 if in.PageSize > 0 && int(in.PageSize) < pageSize {
87 pageSize = int(in.PageSize) 79 pageSize = int(in.PageSize)
88 } 80 }
89 81
90 » einvs, cursor, err := s.Engine.ListVisibleInvocations(ctx, ejob.JobID, p ageSize, in.GetCursor()) 82 » einvs, cursor, err := s.Engine.ListVisibleInvocations(ctx, getJobId(in.G etJobRef()), pageSize, in.GetCursor())
91 » if err != nil { 83 » switch {
84 » case err == engine.ErrNoSuchJob:
85 » » return nil, grpc.Errorf(codes.NotFound, "Job does not exist or n o access")
86 » case err != nil:
92 return nil, grpc.Errorf(codes.Internal, "internal error: %s", er r) 87 return nil, grpc.Errorf(codes.Internal, "internal error: %s", er r)
93 } 88 }
94 invs := make([]*scheduler.Invocation, len(einvs)) 89 invs := make([]*scheduler.Invocation, len(einvs))
95 for i, einv := range einvs { 90 for i, einv := range einvs {
96 invs[i] = &scheduler.Invocation{ 91 invs[i] = &scheduler.Invocation{
97 InvocationRef: &scheduler.InvocationRef{ 92 InvocationRef: &scheduler.InvocationRef{
98 JobRef: &scheduler.JobRef{ 93 JobRef: &scheduler.JobRef{
99 » » » » » Project: ejob.ProjectID, 94 » » » » » Project: in.GetJobRef().GetProject(),
100 » » » » » Job: ejob.GetJobName(), 95 » » » » » Job: in.GetJobRef().GetJob(),
101 }, 96 },
102 InvocationId: einv.ID, 97 InvocationId: einv.ID,
103 }, 98 },
104 StartedTs: einv.Started.UnixNano() / 1000, 99 StartedTs: einv.Started.UnixNano() / 1000,
105 TriggeredBy: string(einv.TriggeredBy), 100 TriggeredBy: string(einv.TriggeredBy),
106 Status: string(einv.Status), 101 Status: string(einv.Status),
107 Final: einv.Status.Final(), 102 Final: einv.Status.Final(),
108 ConfigRevision: einv.Revision, 103 ConfigRevision: einv.Revision,
109 ViewUrl: einv.ViewURL, 104 ViewUrl: einv.ViewURL,
110 } 105 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 case err == engine.ErrNoSuchInvocation: 150 case err == engine.ErrNoSuchInvocation:
156 return nil, grpc.Errorf(codes.NotFound, "no such invocation") 151 return nil, grpc.Errorf(codes.NotFound, "no such invocation")
157 default: 152 default:
158 return nil, grpc.Errorf(codes.Internal, "internal error: %s", er r) 153 return nil, grpc.Errorf(codes.Internal, "internal error: %s", er r)
159 } 154 }
160 } 155 }
161 156
162 func getJobId(jobRef *scheduler.JobRef) string { 157 func getJobId(jobRef *scheduler.JobRef) string {
163 return jobRef.GetProject() + "/" + jobRef.GetJob() 158 return jobRef.GetProject() + "/" + jobRef.GetJob()
164 } 159 }
OLDNEW
« no previous file with comments | « no previous file | scheduler/appengine/apiservers/scheduler_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698