mirror of
https://github.com/containers/podman.git
synced 2025-09-26 08:14:14 +08:00
podman image tree: restore previous behavior
The initial version of libimage changed the order of layers which has now been restored to remain backwards compatible. Further changes: * Fix a bug in the journald logging which requires to strip trailing new lines from the message. The system tests did not pass due to empty new lines. Triggered by changing the default logger to journald in containers/common. * Fix another bug in the journald logging which embedded the container ID inside the message rather than the specifid field. That surfaced in a preceeding whitespace of each log line which broke the system tests. * Alter the system tests to make sure that the k8s-file and the journald logging drivers are executed. * A number of e2e tests have been changed to force the k8s-file driver to make them pass when running inside a root container. * Increase the timeout in a kill test which seems to take longer now. Reasons are unknown. Tests passed earlier and no signal-related changes happend. It may be CI VM flake since some system tests but other flaked. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
61
vendor/github.com/containers/common/libimage/image_tree.go
generated
vendored
61
vendor/github.com/containers/common/libimage/image_tree.go
generated
vendored
@ -35,36 +35,45 @@ func (i *Image) Tree(traverseChildren bool) (string, error) {
|
||||
fmt.Fprintf(sb, "No Image Layers")
|
||||
}
|
||||
|
||||
tree := gotree.New(sb.String())
|
||||
|
||||
layerTree, err := i.runtime.layerTree()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
imageNode := layerTree.node(i.TopLayer())
|
||||
|
||||
// Traverse the entire tree down to all children.
|
||||
if traverseChildren {
|
||||
tree := gotree.New(sb.String())
|
||||
if err := imageTreeTraverseChildren(imageNode, tree); err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else {
|
||||
// Walk all layers of the image and assemlbe their data.
|
||||
for parentNode := imageNode; parentNode != nil; parentNode = parentNode.parent {
|
||||
if parentNode.layer == nil {
|
||||
break // we're done
|
||||
}
|
||||
var tags string
|
||||
repoTags, err := parentNode.repoTags()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(repoTags) > 0 {
|
||||
tags = fmt.Sprintf(" Top Layer of: %s", repoTags)
|
||||
}
|
||||
tree.Add(fmt.Sprintf("ID: %s Size: %7v%s", parentNode.layer.ID[:12], units.HumanSizeWithPrecision(float64(parentNode.layer.UncompressedSize), 4), tags))
|
||||
return tree.Print(), nil
|
||||
}
|
||||
|
||||
// Walk all layers of the image and assemlbe their data. Note that the
|
||||
// tree is constructed in reverse order to remain backwards compatible
|
||||
// with Podman.
|
||||
contents := []string{}
|
||||
for parentNode := imageNode; parentNode != nil; parentNode = parentNode.parent {
|
||||
if parentNode.layer == nil {
|
||||
break // we're done
|
||||
}
|
||||
var tags string
|
||||
repoTags, err := parentNode.repoTags()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(repoTags) > 0 {
|
||||
tags = fmt.Sprintf(" Top Layer of: %s", repoTags)
|
||||
}
|
||||
content := fmt.Sprintf("ID: %s Size: %7v%s", parentNode.layer.ID[:12], units.HumanSizeWithPrecision(float64(parentNode.layer.UncompressedSize), 4), tags)
|
||||
contents = append(contents, content)
|
||||
}
|
||||
contents = append(contents, sb.String())
|
||||
|
||||
tree := gotree.New(contents[len(contents)-1])
|
||||
for i := len(contents) - 2; i >= 0; i-- {
|
||||
tree.Add(contents[i])
|
||||
}
|
||||
|
||||
return tree.Print(), nil
|
||||
@ -80,14 +89,22 @@ func imageTreeTraverseChildren(node *layerNode, parent gotree.Tree) error {
|
||||
tags = fmt.Sprintf(" Top Layer of: %s", repoTags)
|
||||
}
|
||||
|
||||
newNode := parent.Add(fmt.Sprintf("ID: %s Size: %7v%s", node.layer.ID[:12], units.HumanSizeWithPrecision(float64(node.layer.UncompressedSize), 4), tags))
|
||||
content := fmt.Sprintf("ID: %s Size: %7v%s", node.layer.ID[:12], units.HumanSizeWithPrecision(float64(node.layer.UncompressedSize), 4), tags)
|
||||
|
||||
if len(node.children) <= 1 {
|
||||
newNode = parent
|
||||
var newTree gotree.Tree
|
||||
if node.parent == nil || len(node.parent.children) <= 1 {
|
||||
// No parent or no siblings, so we can go linear.
|
||||
parent.Add(content)
|
||||
newTree = parent
|
||||
} else {
|
||||
// Each siblings gets a new tree, so we can branch.
|
||||
newTree = gotree.New(content)
|
||||
parent.AddTree(newTree)
|
||||
}
|
||||
|
||||
for i := range node.children {
|
||||
child := node.children[i]
|
||||
if err := imageTreeTraverseChildren(child, newNode); err != nil {
|
||||
if err := imageTreeTraverseChildren(child, newTree); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user