Skip to content

Commit

Permalink
Fixed a race condition that can cause agent panici
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpen committed Feb 1, 2017
1 parent 1be5420 commit 94785cc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions agent/engine/image/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package image

import (
"encoding/json"
"fmt"
"sync"
"time"
Expand Down Expand Up @@ -98,3 +99,18 @@ func (imageState *ImageState) RemoveContainerReference(container *api.Container)
}
return fmt.Errorf("Container reference is not found in the image state container: %s", container.String())
}

func (imageState *ImageState) MarshalJSON() ([]byte, error) {
imageState.updateLock.Lock()
defer imageState.updateLock.Unlock()

return json.Marshal(&struct {
Image *Image
PulledAt time.Time
LastUsedAt time.Time
}{
Image: imageState.Image,
PulledAt: imageState.PulledAt,
LastUsedAt: imageState.LastUsedAt,
})
}

0 comments on commit 94785cc

Please sign in to comment.