libnetwork/osl/kernel: ApplyOSTweaks: don't log errors if not found

I noticed these errors logged inside the dev-container;

    ERRO[2025-10-14T16:15:46.603781797Z] error reading the kernel parameter net.ipv4.neigh.default.gc_thresh1  error="open /proc/sys/net/ipv4/neigh/default/gc_thresh1: no such file or directory"
    ERRO[2025-10-14T16:15:46.603808089Z] error reading the kernel parameter net.ipv4.neigh.default.gc_thresh2  error="open /proc/sys/net/ipv4/neigh/default/gc_thresh2: no such file or directory"
    ERRO[2025-10-14T16:15:46.603819922Z] error reading the kernel parameter net.ipv4.neigh.default.gc_thresh3  error="open /proc/sys/net/ipv4/neigh/default/gc_thresh3: no such file or directory"

Given that these happen during an initial check, we can probably ignore them
if there's nothing to tweak.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-10-15 02:24:34 +02:00
parent e6fd1ce06b
commit a65293c036

View File

@@ -32,14 +32,16 @@ func ApplyOSTweaks(osConfig map[string]*OSValue) {
// read the existing property from disk
oldv, err := readSystemProperty(k)
if err != nil {
log.G(context.TODO()).WithError(err).Errorf("error reading the kernel parameter %s", k)
if !os.IsNotExist(err) {
log.G(context.TODO()).WithError(err).Errorf("error reading the kernel parameter %s", k)
}
continue
}
if propertyIsValid(oldv, v.Value, v.CheckFn) {
// write new prop value to disk
if err := writeSystemProperty(k, v.Value); err != nil {
log.G(context.TODO()).WithError(err).Errorf("error setting the kernel parameter %s = %s, (leaving as %s)", k, v.Value, oldv)
log.G(context.TODO()).WithError(err).Warnf("error setting the kernel parameter %s = %s, (leaving as %s)", k, v.Value, oldv)
continue
}
log.G(context.TODO()).Debugf("updated kernel parameter %s = %s (was %s)", k, v.Value, oldv)