Skip to content

Commit

Permalink
add startTime and completionTime
Browse files Browse the repository at this point in the history
  • Loading branch information
senthilrch committed Dec 2, 2018
1 parent 1392a6d commit d04f889
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
10 changes: 10 additions & 0 deletions cmd/app/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
switch wqKey.WorkType {
case images.ImageCacheCreate, images.ImageCacheUpdate, images.ImageCacheRefresh, images.ImageCachePurge:

startTime := metav1.Now()
status.StartTime = &startTime
// Get the ImageCache resource with this namespace/name
imageCache, err := c.imageCachesLister.ImageCaches(namespace).Get(name)
if err != nil {
Expand Down Expand Up @@ -601,6 +603,10 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
return err
}

if imageCache.Status.StartTime != nil {
status.StartTime = imageCache.Status.StartTime
}

failures := false
for _, v := range *wqKey.Status {
if v.Status == images.ImageWorkResultStatusSucceeded && !failures {
Expand Down Expand Up @@ -677,6 +683,10 @@ func (c *Controller) updateImageCacheStatus(imageCache *fledgedv1alpha1.ImageCac
// Or create a copy manually for better performance
imageCacheCopy := imageCache.DeepCopy()
imageCacheCopy.Status = *status
if imageCacheCopy.Status.Status != fledgedv1alpha1.ImageCacheActionStatusProcessing {
completionTime := metav1.Now()
imageCacheCopy.Status.CompletionTime = &completionTime
}
// If the CustomResourceSubresources feature gate is not enabled,
// we must use Update instead of UpdateStatus to update the Status block of the ImageCache resource.
// UpdateStatus will not allow changes to the Spec of the resource,
Expand Down
10 changes: 6 additions & 4 deletions pkg/apis/fledged/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ type ImageCacheSpec struct {

// ImageCacheStatus is the status for a ImageCache resource
type ImageCacheStatus struct {
Status ImageCacheActionStatus `json:"status"`
Reason string `json:"reason"`
Message string `json:"message"`
Failures map[string][]NodeReasonMessage `json:"failures,omitempty"`
Status ImageCacheActionStatus `json:"status"`
Reason string `json:"reason"`
Message string `json:"message"`
Failures map[string][]NodeReasonMessage `json:"failures,omitempty"`
StartTime *metav1.Time `json:"startTime,omitempty"`
CompletionTime *metav1.Time `json:"completionTime,omitempty"`
}

// NodeReasonMessage has failure reason and message for a node
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/fledged/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d04f889

Please sign in to comment.