Merge pull request #108 from gmkurtzer/container_resolvconf

Container resolv.conf optimizations
This commit is contained in:
Gregory M. Kurtzer
2021-09-02 16:11:31 -07:00
committed by GitHub
4 changed files with 10 additions and 8 deletions

View File

@@ -14,4 +14,4 @@ Include: dnf
shadow-utils rsyslog tzdata util-linux words zlib tar less \
gzip which util-linux openssh-clients openssh-server dhclient \
pciutils vim-minimal shadow-utils strace cronie crontabs cpio \
wget rocky-release ipmitool yum NetworkManager
wget rocky-release ipmitool yum NetworkManager

View File

@@ -11,7 +11,6 @@ import (
"syscall"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
)
@@ -35,10 +34,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
syscall.Mount("", "/", "", syscall.MS_PRIVATE, "")
syscall.Mount("/dev", path.Join(containerPath, "/dev"), "", syscall.MS_BIND, "")
if util.IsFile(path.Join(containerPath, "/etc/resolv.conf")) == true {
syscall.Mount("/etc/resolv.conf", path.Join(containerPath, "/etc/resolv.conf"), "", syscall.MS_BIND, "")
}
for _, b := range binds {
var source string
var dest string
@@ -67,6 +62,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
ps1string := fmt.Sprintf("[%s] Warewulf> ", containerName)
os.Setenv("PS1", ps1string)
os.Setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin")
os.Setenv("HISTFILE", "/dev/null")
err := syscall.Exec(args[1], args[1:], os.Environ())

View File

@@ -121,8 +121,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
fmt.Printf("Updating the container's /etc/resolv.conf\n")
err := util.CopyFile("/etc/resolv.conf", path.Join(container.RootFsDir(name), "/etc/resolv.conf"))
if err != nil {
wwlog.Printf(wwlog.WARN, "Could not copy /etc/resolv.conf into container: %s\n", err)
}
fmt.Printf("Building container: %s\n", name)
err := container.Build(name, true)
err = container.Build(name, true)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", name, err)
os.Exit(1)

View File

@@ -111,7 +111,7 @@ func CopyFiles(source string, dest string) error {
if err != nil {
return err
}
err = CopyUIDGID(source,dest)
err = CopyUIDGID(source, dest)
if err != nil {
return err
}