Skip to content

Commit

Permalink
Improve audit logs
Browse files Browse the repository at this point in the history
Signed-off-by: Atanas Dinov <atanas.dinov@suse.com>
  • Loading branch information
atanasdinov committed May 28, 2024
1 parent 8e5d37a commit 2b55a04
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ func (b *Builder) Build() error {
log.Audit("Generating image customization components...")

if err := b.imageConfigurator.Configure(b.context); err != nil {
log.Audit("Error configuring customization components, check the logs under the build directory for more information.")
log.Audit("Error configuring customization components.")
return fmt.Errorf("configuring image: %w", err)
}

switch b.context.ImageDefinition.Image.ImageType {
case image.TypeISO:
log.Audit("Building ISO image...")
if err := b.buildIsoImage(); err != nil {
log.Audit("Error building ISO image, check the logs under the build directory for more information.")
log.Audit("Error building ISO image.")
return err
}
case image.TypeRAW:
log.Audit("Building RAW image...")
if err := b.buildRawImage(); err != nil {
log.Audit("Error building RAW image, check the logs under the build directory for more information.")
log.Audit("Error building RAW image.")
return err
}
default:
Expand Down
3 changes: 2 additions & 1 deletion pkg/cli/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ func Run(_ *cli.Context) error {

defer func() {
if r := recover(); r != nil {
log.AuditInfo("Build failed unexpectedly, check the logs under the build directory for more information.")
log.Auditf("Build failed unexpectedly. %s", checkBuildLogMessage)
zap.S().Fatalf("Unexpected error occurred: %s", r)
}
}()

if err = eib.Run(ctx, rootBuildDir); err != nil {
log.Audit(checkBuildLogMessage)
zap.S().Fatalf("An error occurred building the image: %s", err)
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/eib/eib.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

func Run(ctx *image.Context, rootBuildDir string) error {
if err := appendKubernetesSELinuxRPMs(ctx); err != nil {
log.Auditf("Bootstrapping dependency services failed.")
return fmt.Errorf("configuring kubernetes selinux policy: %w", err)
}

Expand All @@ -33,6 +34,7 @@ func Run(ctx *image.Context, rootBuildDir string) error {

c, err := buildCombustion(ctx, rootBuildDir)
if err != nil {
log.Audit("Bootstrapping dependency services failed.")
return fmt.Errorf("building combustion: %w", err)
}

Expand Down

0 comments on commit 2b55a04

Please sign in to comment.