Merge pull request #1302 from warewulf/ContainerVerbose

be more verbose on container exec
This commit is contained in:
Jonathon Anderson
2024-08-02 13:45:10 -06:00
committed by GitHub
2 changed files with 11 additions and 1 deletions

View File

@@ -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 <shell|exec>` about when and if the container image will be rebuilt. #1302
### Fixed
- Ensure autobuilt overlays include contextual overlay contents. #1296

View File

@@ -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 = `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 {
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> ", containerName, exitEval)
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"))