From 0364f1c9ca649214563e41dfa15f1cc5c9108bda Mon Sep 17 00:00:00 2001 From: Matt Jolly Date: Thu, 7 Sep 2023 18:52:34 +1000 Subject: [PATCH] add error handling to dynamic network configuration --- CHANGELOG.md | 1 + CONTRIBUTORS.md | 1 + internal/pkg/config/root.go | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc0e55f1..db644f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add EL9 Quickstart guide to index.rst - Container file gids are now updated properly during syncuser. #840 - Fix build for API. +- Add error handling to `wwctl`'s dynamic IP configuration attempt. ### Changed diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9b394cae..45127882 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -27,3 +27,4 @@ * Jeffrey Frey @jtfrey * Xu Yang(Jason Yang) @JasonYangShadow * Arnaud LECOMTE +* Matt Jolly diff --git a/internal/pkg/config/root.go b/internal/pkg/config/root.go index 67c4447a..3e641e6a 100644 --- a/internal/pkg/config/root.go +++ b/internal/pkg/config/root.go @@ -119,7 +119,10 @@ 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") + conn, err := net.Dial("udp", "8.8.8.8:80") + if err != nil { + return errors.Wrap(err, "Couldn't establish a connection to remote") + } defer conn.Close() ipaddr = conn.LocalAddr().(*net.UDPAddr).IP mask = ipaddr.DefaultMask()