diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cdb509c..1835925e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added option for wwclient port number. #1349 - Additional helper directions during syncuser conflict. #1359 - Add `:cow` suffix to `wwctl container exec --bind` to temporarily copy files into the node image. #1365 +- Add `:copy` suffix to `wwctl container exec --bind` to temporarily copy files into the node image. #1365 ### Changed diff --git a/internal/app/wwctl/container/exec/child/main.go b/internal/app/wwctl/container/exec/child/main.go index ba9ad9f7..0785ba74 100644 --- a/internal/app/wwctl/container/exec/child/main.go +++ b/internal/app/wwctl/container/exec/child/main.go @@ -142,7 +142,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { } for _, mntPnt := range mountPts { - if mntPnt.Cow { + if mntPnt.Copy { continue } wwlog.Debug("bind mounting: %s -> %s", mntPnt.Source, path.Join(containerPath, mntPnt.Dest)) @@ -199,7 +199,7 @@ the invalid mount points. Directories always have '/' as suffix func checkMountPoints(containerName string, binds []*warewulfconf.MountEntry) (overlayObjects []string) { overlayObjects = []string{} for _, b := range binds { - if b.Cow { + if b.Copy { continue } _, err := os.Stat(b.Source) diff --git a/internal/app/wwctl/container/exec/main.go b/internal/app/wwctl/container/exec/main.go index bffe0993..5aed57fa 100644 --- a/internal/app/wwctl/container/exec/main.go +++ b/internal/app/wwctl/container/exec/main.go @@ -67,7 +67,7 @@ func runContainedCmd(cmd *cobra.Command, containerName string, args []string) (e // command syscall.Exec which replaces the __child process with the // exec command in the container. All the mounts, have to be done in // __child so that the used mounts don't propagate outside on the host - // (see the CLONE attributes), but as for the cow copy option we need + // (see the CLONE attributes), but as for the copy option we need // to see if a file was modified after it was copied into the container // so do this here. // At first read out conf, the parse commandline, as copy files has the @@ -177,13 +177,13 @@ func SetNode(myNode string) { } // file name and last modification time so we can remove the file if it wasn't modified -type cowFile struct { +type copyFile struct { fileName string src string modTime time.Time } -func (this *cowFile) copyToContainer(containerName string) error { +func (this *copyFile) copyToContainer(containerName string) error { containerDest := path.Join(container.RootFsDir(containerName), this.fileName) if _, err := os.Stat(path.Dir(containerDest)); err != nil { return fmt.Errorf("destination directory doesn't exist: %s", err) @@ -201,7 +201,7 @@ func (this *cowFile) copyToContainer(containerName string) error { } } -func (this *cowFile) removeFromContainer(containerName string) error { +func (this *copyFile) removeFromContainer(containerName string) error { containerDest := path.Join(container.RootFsDir(containerName), this.fileName) if this.modTime.IsZero() { return fmt.Errorf("not previously copied: %s", this.fileName) @@ -217,10 +217,10 @@ func (this *cowFile) removeFromContainer(containerName string) error { /* Check the objects we want to copy in, instead of mounting */ -func getCopyFiles(binds []*warewulfconf.MountEntry) (copyObjects []*cowFile) { +func getCopyFiles(binds []*warewulfconf.MountEntry) (copyObjects []*copyFile) { for _, bind := range binds { - if bind.Cow { - copyObjects = append(copyObjects, &cowFile{ + if bind.Copy { + copyObjects = append(copyObjects, ©File{ fileName: bind.Dest, src: bind.Source, }) diff --git a/internal/app/wwctl/container/exec/root.go b/internal/app/wwctl/container/exec/root.go index bcb8cf5a..1152fd8e 100644 --- a/internal/app/wwctl/container/exec/root.go +++ b/internal/app/wwctl/container/exec/root.go @@ -32,9 +32,9 @@ var ( func init() { baseCmd.AddCommand(child.GetCommand()) - baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, `source[:destination[:{ro|cow}]] + baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, `source[:destination[:{ro|copy}]] Bind a local path which must exist into the container. If destination is not -set, uses the same path as source. "ro" binds read-only. "cow" temporarily +set, uses the same path as source. "ro" binds read-only. "copy" temporarily copies the file into the container.`) baseCmd.PersistentFlags().BoolVar(&SyncUser, "syncuser", false, "Synchronize UIDs/GIDs from host to container") baseCmd.PersistentFlags().StringVarP(&nodeName, "node", "n", "", "Create a read only view of the container for the given node") diff --git a/internal/app/wwctl/container/shell/root.go b/internal/app/wwctl/container/shell/root.go index df9b2c6e..e1ae01d3 100644 --- a/internal/app/wwctl/container/shell/root.go +++ b/internal/app/wwctl/container/shell/root.go @@ -28,9 +28,9 @@ var ( ) func init() { - baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, `source[:destination[:{ro|cow}]] + baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, `source[:destination[:{ro|copy}]] Bind a local path which must exist into the container. If destination is not -set, uses the same path as source. "ro" binds read-only. "cow" temporarily +set, uses the same path as source. "ro" binds read-only. "copy" temporarily copies the file into the container.`) baseCmd.PersistentFlags().StringVarP(&nodeName, "node", "n", "", "Create a read only view of the container for the given node") } diff --git a/internal/pkg/config/mounts.go b/internal/pkg/config/mounts.go index 35805202..305fbad4 100644 --- a/internal/pkg/config/mounts.go +++ b/internal/pkg/config/mounts.go @@ -7,5 +7,5 @@ type MountEntry struct { Dest string `yaml:"dest,omitempty"` ReadOnly bool `yaml:"readonly,omitempty"` Options string `yaml:"options,omitempty"` // ignored at the moment - Cow bool `yaml:"cow,omitempty"` // copy the file into the container and don't remove if modified + Copy bool `yaml:"copy,omitempty"` // temporarily copy the file into the container } diff --git a/internal/pkg/container/mountpoints.go b/internal/pkg/container/mountpoints.go index 7c16a0a9..961513fb 100644 --- a/internal/pkg/container/mountpoints.go +++ b/internal/pkg/container/mountpoints.go @@ -21,19 +21,19 @@ func InitMountPnts(binds []string) (mounts []*warewulfconf.MountEntry) { dest = bind[1] } readonly := false - cow := false + copy_ := false if len(bind) >= 3 { if bind[2] == "ro" { readonly = true - } else if bind[2] == "cow" { - cow = true + } else if bind[2] == "copy" { + copy_ = true } } mntPnt := warewulfconf.MountEntry{ Source: bind[0], Dest: dest, ReadOnly: readonly, - Cow: cow, + Copy: copy_, } mounts = append(mounts, &mntPnt) } diff --git a/userdocs/contents/containers.rst b/userdocs/contents/containers.rst index b46f34eb..2ee7a236 100644 --- a/userdocs/contents/containers.rst +++ b/userdocs/contents/containers.rst @@ -223,7 +223,7 @@ can be specified in ``warewulf.conf``: readonly: true .. note:: - Instead of ``readonly: true`` you can set ``cow: true``. This causes the + Instead of ``readonly: true`` you can set ``copy: true``. This causes the source file to be copied to the container and removed if it was not modified. This can be useful for files used for registrations.