Skip to content

Commit

Permalink
Using subject as key in list handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanbp committed Jul 6, 2017
1 parent 0f8a864 commit c8baae5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func Spawn(token *jwt.Token, name, image string, options Options) (*Info, error)
for {
t0 := time.Now().UnixNano()
select {
case <-time.After(1000 * time.Millisecond):
ms := (time.Now().UnixNano() - t0) / 1e6
case <-time.After(time.Second):
ms := (time.Now().UnixNano() - t0) / 1e9
if err := options.Meter.Record(int(ms)); err != nil {
log.WithError(err).Warn("Could not record time spent - kill and exit")
if err := container.Kill(uname, false, false); err != nil {
Expand All @@ -93,7 +93,11 @@ func Spawn(token *jwt.Token, name, image string, options Options) (*Info, error)

// List the daemons running on this token.
func List(token *jwt.Token) ([]docker.APIContainers, error) {
return container.List(nil, container.WithLabel("token", token.Raw))
claims, ok := token.Claims.(jwt.MapClaims)
if !ok {
return nil, fmt.Errorf("Could extract claims from token")
}
return container.List(nil, container.WithLabel("subject", claims["sub"].(string)))
}

// SpawnHandler handles spawn requests
Expand Down

0 comments on commit c8baae5

Please sign in to comment.