Output a warning for label image labels instead of erroring
This change ignore errors during container runtime due to large image labels and instead outputs warning. This is necessary as certain image building tools like buildpacks may have large labels in the images which need not be passed to the container. Signed-off-by: Sambhav Kothari <sambhavs.email@gmail.com>
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/containerd/cmd/ctr/commands/tasks"
|
||||
"github.com/containerd/containerd/containers"
|
||||
clabels "github.com/containerd/containerd/labels"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/oci"
|
||||
gocni "github.com/containerd/go-cni"
|
||||
@@ -254,7 +255,13 @@ func fullID(ctx context.Context, c containerd.Container) string {
|
||||
func buildLabels(cmdLabels, imageLabels map[string]string) map[string]string {
|
||||
labels := make(map[string]string)
|
||||
for k, v := range imageLabels {
|
||||
labels[k] = v
|
||||
if err := clabels.Validate(k, v); err == nil {
|
||||
labels[k] = v
|
||||
} else {
|
||||
// In case the image label is invalid, we output a warning and skip adding it to the
|
||||
// container.
|
||||
logrus.WithError(err).Warnf("unable to add image label with key %s to the container", k)
|
||||
}
|
||||
}
|
||||
// labels from the command line will override image and the initial image config labels
|
||||
for k, v := range cmdLabels {
|
||||
|
Reference in New Issue
Block a user