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

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

Issue 2986033003: [scheduler]: ACLs phase 1 - per Job ACL specification and enforcement. (Closed)
Patch Set: pcg 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
OLDNEW
1 // Copyright 2015 The LUCI Authors. 1 // Copyright 2015 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 30 matching lines...) Expand all
41 "github.com/luci/luci-go/common/data/rand/mathrand" 41 "github.com/luci/luci-go/common/data/rand/mathrand"
42 "github.com/luci/luci-go/common/data/stringset" 42 "github.com/luci/luci-go/common/data/stringset"
43 "github.com/luci/luci-go/common/errors" 43 "github.com/luci/luci-go/common/errors"
44 "github.com/luci/luci-go/common/logging" 44 "github.com/luci/luci-go/common/logging"
45 "github.com/luci/luci-go/common/retry/transient" 45 "github.com/luci/luci-go/common/retry/transient"
46 "github.com/luci/luci-go/server/auth" 46 "github.com/luci/luci-go/server/auth"
47 "github.com/luci/luci-go/server/auth/identity" 47 "github.com/luci/luci-go/server/auth/identity"
48 "github.com/luci/luci-go/server/auth/signing" 48 "github.com/luci/luci-go/server/auth/signing"
49 "github.com/luci/luci-go/server/tokens" 49 "github.com/luci/luci-go/server/tokens"
50 50
51 "github.com/luci/luci-go/scheduler/appengine/acl"
51 "github.com/luci/luci-go/scheduler/appengine/catalog" 52 "github.com/luci/luci-go/scheduler/appengine/catalog"
52 "github.com/luci/luci-go/scheduler/appengine/schedule" 53 "github.com/luci/luci-go/scheduler/appengine/schedule"
53 "github.com/luci/luci-go/scheduler/appengine/task" 54 "github.com/luci/luci-go/scheduler/appengine/task"
54 ) 55 )
55 56
56 var ( 57 var (
57 ErrNoSuchJob = errors.New("no such job") 58 ErrNoSuchJob = errors.New("no such job")
58 ErrNoSuchInvocation = errors.New("the invocation doesn't exist") 59 ErrNoSuchInvocation = errors.New("the invocation doesn't exist")
59 ) 60 )
60 61
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // an appropriate revision. 263 // an appropriate revision.
263 RevisionURL string `gae:",noindex"` 264 RevisionURL string `gae:",noindex"`
264 265
265 // Schedule is the job's schedule in regular cron expression format. 266 // Schedule is the job's schedule in regular cron expression format.
266 Schedule string `gae:",noindex"` 267 Schedule string `gae:",noindex"`
267 268
268 // Task is the job's payload in serialized form. Opaque from the point o f view 269 // Task is the job's payload in serialized form. Opaque from the point o f view
269 // of the engine. See Catalog.UnmarshalTask(). 270 // of the engine. See Catalog.UnmarshalTask().
270 Task []byte `gae:",noindex"` 271 Task []byte `gae:",noindex"`
271 272
273 // ACLs are the latest ACLs applied to Job and all its invocations.
274 Acls acl.GrantsByRole `gae:",noindex"`
275
272 // State is the job's state machine state, see StateMachine. 276 // State is the job's state machine state, see StateMachine.
273 State JobState 277 State JobState
274 } 278 }
275 279
276 // GetJobName returns name of this Job as defined its project's config. 280 // GetJobName returns name of this Job as defined its project's config.
277 func (e *Job) GetJobName() string { 281 func (e *Job) GetJobName() string {
278 // JobID has form <project>/<id>. Split it into components. 282 // JobID has form <project>/<id>. Split it into components.
279 chunks := strings.Split(e.JobID, "/") 283 chunks := strings.Split(e.JobID, "/")
280 return chunks[1] 284 return chunks[1]
281 } 285 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 e.State == other.State) 325 e.State == other.State)
322 } 326 }
323 327
324 // matches returns true if job definition in the entity matches the one 328 // matches returns true if job definition in the entity matches the one
325 // specified by catalog.Definition struct. UpdateProjectJobs skips updates for 329 // specified by catalog.Definition struct. UpdateProjectJobs skips updates for
326 // such jobs (assuming they are up-to-date). 330 // such jobs (assuming they are up-to-date).
327 func (e *Job) matches(def catalog.Definition) bool { 331 func (e *Job) matches(def catalog.Definition) bool {
328 return e.JobID == def.JobID && 332 return e.JobID == def.JobID &&
329 e.Flavor == def.Flavor && 333 e.Flavor == def.Flavor &&
330 e.Schedule == def.Schedule && 334 e.Schedule == def.Schedule &&
335 def.Acls.Equal(&e.Acls) &&
Vadim Sh. 2017/08/01 01:56:19 nit: swap e.Acls.Equal(&def.Acls)
tandrii(chromium) 2017/08/01 22:50:01 Done.
331 bytes.Equal(e.Task, def.Task) 336 bytes.Equal(e.Task, def.Task)
332 } 337 }
333 338
334 // Invocation entity stores single attempt to run a job. Its parent entity 339 // Invocation entity stores single attempt to run a job. Its parent entity
335 // is corresponding Job, its ID is generated based on time. 340 // is corresponding Job, its ID is generated based on time.
336 type Invocation struct { 341 type Invocation struct {
337 _kind string `gae:"$kind,Invocation"` 342 _kind string `gae:"$kind,Invocation"`
338 _extra ds.PropertyMap `gae:"-,extra"` 343 _extra ds.PropertyMap `gae:"-,extra"`
339 344
340 // ID is identifier of this particular attempt to run a job. Multiple at tempts 345 // ID is identifier of this particular attempt to run a job. Multiple at tempts
(...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 } 1957 }
1953 if hasFinished { 1958 if hasFinished {
1954 return ctl.eng.rollSM(c, job, func(sm *StateMachine) err or { 1959 return ctl.eng.rollSM(c, job, func(sm *StateMachine) err or {
1955 sm.OnInvocationDone(saving.ID) 1960 sm.OnInvocationDone(saving.ID)
1956 return nil 1961 return nil
1957 }) 1962 })
1958 } 1963 }
1959 return nil 1964 return nil
1960 }) 1965 })
1961 } 1966 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698