Merge pull request #1923 from anderbubble/wwclient-logs

Minor updates to wwclient log messages
This commit is contained in:
Christian Goll
2025-06-16 11:50:51 +02:00
committed by GitHub
2 changed files with 10 additions and 10 deletions

View File

@@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Added `-l` flag to `wwctl image list` within the sos plugin for better reporting. #1855 - Added `-l` flag to `wwctl image list` within the sos plugin for better reporting. #1855
- Moved `wwclient` binary to the `wwclient` overlay. - Moved `wwclient` binary to the `wwclient` overlay.
- Minor updates to `wwclient` log messages
### Removed ### Removed

View File

@@ -3,7 +3,6 @@ package wwclient
import ( import (
"errors" "errors"
"fmt" "fmt"
"log"
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
@@ -77,7 +76,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
if err != nil { if err != nil {
return fmt.Errorf("failed to change dir: %w", err) return fmt.Errorf("failed to change dir: %w", err)
} }
log.Printf("Updating live file system LIVE, cancel now if this is in error") wwlog.Warn("updating live file system: cancel now if this is in error")
time.Sleep(5000 * time.Millisecond) time.Sleep(5000 * time.Millisecond)
} else { } else {
fmt.Printf("Called via: %s\n", os.Args[0]) fmt.Printf("Called via: %s\n", os.Args[0])
@@ -101,7 +100,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
} else if conf.Warewulf.Secure() { } else if conf.Warewulf.Secure() {
// Setup local port to something privileged (<1024) // Setup local port to something privileged (<1024)
localTCPAddr.Port = 987 localTCPAddr.Port = 987
wwlog.Info("Running from trusted port") wwlog.Info("Running from trusted port: %d", localTCPAddr.Port)
} }
Webclient = &http.Client{ Webclient = &http.Client{
@@ -184,11 +183,11 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
sig := <-sigs sig := <-sigs
switch sig { switch sig {
case syscall.SIGHUP: case syscall.SIGHUP:
log.Printf("Received SIGNAL: %s\n", sig) wwlog.Info("received signal: %s", sig)
stopTimer.Stop() stopTimer.Stop()
stopTimer.Reset(0) stopTimer.Reset(0)
case syscall.SIGTERM, syscall.SIGINT: case syscall.SIGTERM, syscall.SIGINT:
wwlog.Info("termination wwclient!, %v", sig) wwlog.Info("terminating wwclient, %v", sig)
os.Exit(0) os.Exit(0)
} }
} }
@@ -227,7 +226,7 @@ func updateSystem(ipaddr string, port int, wwid string, tag string, localUUID uu
Path: fmt.Sprintf("provision/%s", wwid), Path: fmt.Sprintf("provision/%s", wwid),
RawQuery: values.Encode(), RawQuery: values.Encode(),
} }
wwlog.Debug("Making request: %s", getURL) wwlog.Debug("making request: %s", getURL)
resp, err = Webclient.Get(getURL.String()) resp, err = Webclient.Get(getURL.String())
if err == nil { if err == nil {
break break
@@ -236,23 +235,23 @@ func updateSystem(ipaddr string, port int, wwid string, tag string, localUUID uu
counter = 0 counter = 0
} }
if counter == 0 { if counter == 0 {
log.Println(err) wwlog.Error("%s", err)
} }
counter++ counter++
} }
time.Sleep(1000 * time.Millisecond) time.Sleep(1000 * time.Millisecond)
} }
if resp.StatusCode != 200 { if resp.StatusCode != 200 {
log.Printf("Not updating runtime overlay, got status code: %d\n", resp.StatusCode) wwlog.Warn("not applying runtime overlay: got status code: %d", resp.StatusCode)
time.Sleep(60000 * time.Millisecond) time.Sleep(60000 * time.Millisecond)
return return
} }
log.Printf("Updating system\n") wwlog.Info("applying runtime overlay")
command := exec.Command("/bin/sh", "-c", "gzip -dc | cpio -iu") command := exec.Command("/bin/sh", "-c", "gzip -dc | cpio -iu")
command.Stdin = resp.Body command.Stdin = resp.Body
err := command.Run() err := command.Run()
if err != nil { if err != nil {
log.Printf("ERROR: Failed running CPIO: %s\n", err) wwlog.Error("failed running cpio: %s", err)
} }
} }