From 9d2853ad646d7ec106baefba884c4a05ef42e039 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 11 Jul 2024 10:59:44 +0200 Subject: [PATCH 1/2] Show pending container build status during container exec, shell Signed-off-by: Christian Goll --- CHANGELOG.md | 4 ++++ internal/app/wwctl/container/exec/child/main.go | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53bca146..dfe0d8cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## v4.5.6, unreleased +### Added + +- Show more information during `wwctl container ` about when and if the container image will be rebuilt. #1302 + ### Fixed - Ensure autobuilt overlays include contextual overlay contents. #1296 diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index a6502111..715e0db8 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -21,6 +21,11 @@ import ( "github.com/warewulf/warewulf/internal/pkg/wwlog" ) +const exitEval = `$(VALU="$?" ; if [ $VALU == 0 ]; then echo write; else echo discard; fi)` +const msgStr = `Changes are written back to container and image is rebuilt +depending on exit status of last called program. +Type "true" or "false" to enforce or abort image rebuilt.` + func CobraRunE(cmd *cobra.Command, args []string) (err error) { if os.Getpid() != 1 { wwlog.Error("PID is not 1: %d", os.Getpid()) @@ -79,7 +84,8 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { if err != nil { return errors.Wrap(err, "failed to mount") } - ps1Str := fmt.Sprintf("[%s] Warewulf> ", containerName) + ps1Str := fmt.Sprintf("[%s|%s] Warewulf> ", exitEval, containerName) + wwlog.Info(msgStr) if len(lowerObjects) != 0 && nodename == "" { options := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", path.Join(runDir, "lower"), containerPath, path.Join(runDir, "work")) From 6028a6eb58dacf66a70937805972958954f30155 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Fri, 2 Aug 2024 13:29:59 -0600 Subject: [PATCH 2/2] Minor adjustments to exitEval and msgStr For grammar clarity, and consistency. Signed-off-by: Jonathon Anderson --- internal/app/wwctl/container/exec/child/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index 715e0db8..253a6ad2 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -22,9 +22,9 @@ import ( ) const exitEval = `$(VALU="$?" ; if [ $VALU == 0 ]; then echo write; else echo discard; fi)` -const msgStr = `Changes are written back to container and image is rebuilt -depending on exit status of last called program. -Type "true" or "false" to enforce or abort image rebuilt.` +const msgStr = `Container image is rebuilt depending on the exit status of the last command. + +Run "true" or "false" to enforce or abort image rebuild.` func CobraRunE(cmd *cobra.Command, args []string) (err error) { if os.Getpid() != 1 { @@ -84,7 +84,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { if err != nil { return errors.Wrap(err, "failed to mount") } - ps1Str := fmt.Sprintf("[%s|%s] Warewulf> ", exitEval, containerName) + ps1Str := fmt.Sprintf("[%s|%s] Warewulf> ", containerName, exitEval) wwlog.Info(msgStr) if len(lowerObjects) != 0 && nodename == "" { options := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s",