diff --git a/CHANGELOG.md b/CHANGELOG.md index bc0e55f1..12aef88a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,12 +43,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The primary hostname and warewulf server fqdn are now the canonical name in `/etc/hosts` - - Refactored `profile add` command to make it alike `node add`. #658 #659 - - The ifcfg ONBOOT parameter is no longer statically `true`, so unconfigured interfaces may not be enabled by default. (#644) - +- Write log messages to stderr rather than stdout. #768 - new subcommand `wwctl genconf` is available with following subcommands: * `completions` which will create the files used for bash-completion. Also fish an zsh completions can be generated @@ -58,19 +56,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `warwulfconf print` which will print the used `warewulf.conf`. If there is no valid `warewulf.conf` a valid configuration is provided, prefilled with default values and an IP configuration derived from the network configuration of the host - - All paths can now be configured in `warewulf.conf`, check the paths section of of `wwctl --emptyconf genconfig warewulfconf print` for the available paths. - - Added experimental dnsmasq support. - +- fix SIGSEV when build host has no network #907 - Check for formal correct IP and MAC addresses for command line options and when reading in the configurations - Added template to create genders database - Write log messages to stderr rather than stdout. #768 - Updates to Makefile for clarity, notably removing genconfig and replacing test-it with test. #890 - - realy reboot also without systemd - Specify primary network device per-node rather than per-netdev - refactored output `wwctl node/profile list` so that `-a` will only show all the diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9b394cae..14cc0e91 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -26,4 +26,5 @@ * Brian Phan * Jeffrey Frey @jtfrey * Xu Yang(Jason Yang) @JasonYangShadow +* Matt Jolly @Kangie * Arnaud LECOMTE diff --git a/internal/pkg/config/root.go b/internal/pkg/config/root.go index 67c4447a..e8d7b426 100644 --- a/internal/pkg/config/root.go +++ b/internal/pkg/config/root.go @@ -6,7 +6,6 @@ // DHCP, TFTP and NFS services that Warewulf manages. package config - import ( "fmt" "net" @@ -20,10 +19,8 @@ import ( "gopkg.in/yaml.v2" ) - var cachedConf RootConf - // RootConf is the main Warewulf configuration structure. It stores // some information about the Warewulf server locally, and has // [WarewulfConf], [DHCPConf], [TFTPConf], and [NFSConf] sub-sections. @@ -43,13 +40,12 @@ type RootConf struct { MountsContainer []*MountEntry `yaml:"container mounts" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"` Paths *BuildConfig `yaml:"paths"` - fromFile bool + fromFile bool } - // New caches and returns a new [RootConf] initialized with empty // values, clearing replacing any previously cached value. -func New() (*RootConf) { +func New() *RootConf { cachedConf = RootConf{} cachedConf.fromFile = false cachedConf.Warewulf = new(WarewulfConf) @@ -63,10 +59,9 @@ func New() (*RootConf) { return &cachedConf } - // Get returns a previously cached [RootConf] if it exists, or returns // a new RootConf. -func Get() (*RootConf) { +func Get() *RootConf { // NOTE: This function can be called before any log level is set // so using wwlog.Verbose or wwlog.Debug won't work if reflect.ValueOf(cachedConf).IsZero() { @@ -75,10 +70,9 @@ func Get() (*RootConf) { return &cachedConf } - // Read populates [RootConf] with the values from a configuration // file. -func (conf *RootConf) Read(confFileName string) (error) { +func (conf *RootConf) Read(confFileName string) error { wwlog.Debug("Reading warewulf.conf from: %s", confFileName) if data, err := os.ReadFile(confFileName); err != nil { return err @@ -90,9 +84,8 @@ func (conf *RootConf) Read(confFileName string) (error) { } } - // Parse populates [RootConf] with the values from a yaml document. -func (conf *RootConf) Parse(data []byte) (error) { +func (conf *RootConf) Parse(data []byte) error { // ipxe binaries are merged not overwritten, store defaults separate defIpxe := make(map[string]string) for k, v := range conf.TFTP.IpxeBinaries { @@ -108,7 +101,6 @@ func (conf *RootConf) Parse(data []byte) (error) { return nil } - // SetDynamicDefaults populates [RootConf] with plausible defaults for // the runtime environment. func (conf *RootConf) SetDynamicDefaults() (err error) { @@ -119,12 +111,16 @@ func (conf *RootConf) SetDynamicDefaults() (err error) { if conf.Ipaddr == "" { wwlog.Verbose("Configuration has no valid network, going to dynamic values") - conn, _ := net.Dial("udp", "8.8.8.8:80") - defer conn.Close() - ipaddr = conn.LocalAddr().(*net.UDPAddr).IP - mask = ipaddr.DefaultMask() - sz, _ := mask.Size() - conf.Ipaddr = ipaddr.String() + fmt.Sprintf("/%d", sz) + conn, err := net.Dial("udp", "8.8.8.8:80") + if err == nil { + defer conn.Close() + ipaddr = conn.LocalAddr().(*net.UDPAddr).IP + mask = ipaddr.DefaultMask() + sz, _ := mask.Size() + conf.Ipaddr = ipaddr.String() + fmt.Sprintf("/%d", sz) + } else { + conf.Ipaddr = "192.168.1.1/24" + } } _, network, err = net.ParseCIDR(conf.Ipaddr) if err == nil { @@ -175,7 +171,6 @@ func (conf *RootConf) SetDynamicDefaults() (err error) { return } - // InitializedFromFile returns true if [RootConf] memory was read from // a file, or false otherwise. func (conf *RootConf) InitializedFromFile() bool {