Ejemplo n.º 1
0
func newImgListLoadError(err error, imj []byte, blobKey string) error {
	var lines []string
	im := lastditch.ImageManifest{}
	imErr := im.UnmarshalJSON(imj)
	if imErr == nil {
		lines = append(lines, fmt.Sprintf("Unable to load manifest of image %s (spec version %s) because it is invalid:", im.Name, im.ACVersion))
		lines = append(lines, fmt.Sprintf("  %v", err))
	} else {
		lines = append(lines, "Unable to load manifest of an image because it is invalid:")
		lines = append(lines, fmt.Sprintf("  %v", err))
		lines = append(lines, "  Also, failed to get any information about invalid image manifest:")
		lines = append(lines, fmt.Sprintf("    %v", imErr))
	}
	lines = append(lines, "ID of the invalid image:")
	lines = append(lines, fmt.Sprintf("  %s", blobKey))
	return fmt.Errorf("%s", strings.Join(lines, "\n"))
}
Ejemplo n.º 2
0
func newPodListImageLoadFailure(p *pod, err error, pm *schema.PodManifest, imj []byte, app schema.RuntimeApp) error {
	im := lastditch.ImageManifest{}
	imErr := im.UnmarshalJSON(imj)
	acVersion := "unknown"
	if imErr == nil {
		acVersion = im.ACVersion
	}
	lines := []string{
		fmt.Sprintf("Unable to load image %s manifest (spec version %s) because it is invalid:", app.Image.ID.String(), acVersion),
		fmt.Sprintf("  %v", err),
	}
	if imErr != nil {
		lines = append(lines, "  Also, failed to get any information about invalid image manifest:")
		lines = append(lines, fmt.Sprintf("    %v", imErr))
	}
	lines = append(lines, "Objects related to this error:")
	lines = append(lines, fmt.Sprintf("  App: %q from failing image %q (%s)",
		app.Name, app.Image.Name, app.Image.ID))
	lines = append(lines, fmt.Sprintf("  Pod %s (spec version %s) with following apps:", p.uuid.String(), pm.ACVersion.String()))
	for _, pApp := range pm.Apps {
		lines = append(lines, fmt.Sprintf("    %s", appLine(degradeRuntimeApp(pApp))))
	}
	return fmt.Errorf("%s", strings.Join(lines, "\n"))
}