Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebased docker/distribution #5404

Merged
merged 17 commits into from
Dec 18, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Delete tag if its history is empty
During a run of prune images, history of a tag may get emptied. When an
image with the same tag is re-pushed, the operation will fail because
the history list is not expected to be empty.

This patch checks the history list for non-emptiness before returning a
valid tag event and ensures that tag is deleted from ImageStream's
status.tags  when the last item has been removed from its history during
a prune.

Signed-off-by: Michal Minar <[email protected]>
  • Loading branch information
Michal Minar committed Dec 16, 2015
commit 0a574c7dac5ade51ce05872af3deaf8405556f38
3 changes: 3 additions & 0 deletions pkg/image/api/helper.go
Original file line number Diff line number Diff line change
@@ -300,6 +300,9 @@ func LatestTaggedImage(stream *ImageStream, tag string) *TagEvent {
// find the most recent tag event with an image reference
if stream.Status.Tags != nil {
if history, ok := stream.Status.Tags[tag]; ok {
if len(history.Items) == 0 {
return nil
}
return &history.Items[0]
}
}
7 changes: 6 additions & 1 deletion pkg/image/prune/imagepruner.go
Original file line number Diff line number Diff line change
@@ -668,7 +668,12 @@ func pruneStreams(g graph.Graph, imageNodes []*imagegraph.ImageNode, streamPrune
updatedTags.Insert(tag)
}
}
stream.Status.Tags[tag] = newHistory
if len(newHistory.Items) == 0 {
glog.V(4).Infof("Removing tag %q from status.tags of ImageStream %s/%s", tag, stream.Namespace, stream.Name)
delete(stream.Status.Tags, tag)
} else {
stream.Status.Tags[tag] = newHistory
}
}

updatedStream, err := streamPruner.PruneImageStream(stream, imageNode.Image, updatedTags.List())