From ee9f0e776feb36127bcdb7d7ddcaf94ef99f8c4e Mon Sep 17 00:00:00 2001 From: matst80 Date: Sun, 10 Nov 2024 00:46:35 +0100 Subject: [PATCH] less duplicate logs --- main.go | 12 ++++++++---- synced-pool.go | 3 --- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index f64fc2a..ecc8c60 100644 --- a/main.go +++ b/main.go @@ -86,12 +86,14 @@ func (a *App) HandleSave(w http.ResponseWriter, r *http.Request) { } type PoolServer struct { - pool GrainPool + pod_name string + pool GrainPool } -func NewPoolServer(pool GrainPool) *PoolServer { +func NewPoolServer(pool GrainPool, pod_name string) *PoolServer { return &PoolServer{ - pool: pool, + pod_name: pod_name, + pool: pool, } } @@ -104,6 +106,7 @@ func (s *PoolServer) HandleGet(w http.ResponseWriter, r *http.Request) { return } w.Header().Set("Content-Type", "application/json") + w.Header().Set("X-Pod-Name", s.pod_name) w.WriteHeader(http.StatusOK) w.Write(data) } @@ -121,6 +124,7 @@ func (s *PoolServer) HandleAddSku(w http.ResponseWriter, r *http.Request) { return } w.Header().Set("Content-Type", "application/json") + w.Header().Set("X-Pod-Name", s.pod_name) w.WriteHeader(http.StatusOK) w.Write(data) } @@ -186,7 +190,7 @@ func main() { } }() - syncedServer := NewPoolServer(syncedPool) + syncedServer := NewPoolServer(syncedPool, name) mux := http.NewServeMux() mux.Handle("/api/", http.StripPrefix("/api", syncedServer.Serve())) mux.HandleFunc("GET /add/remote/{host}", func(w http.ResponseWriter, r *http.Request) { diff --git a/synced-pool.go b/synced-pool.go index efa7160..e085a4f 100644 --- a/synced-pool.go +++ b/synced-pool.go @@ -302,11 +302,9 @@ func (p *SyncedPool) handleConnection(conn net.Conn) { case RemoteGrainChanged: // remote grain changed grainSyncCount.Inc() - log.Printf("Remote grain changed\n") idAndHost := make([]byte, packet.DataLength) _, err = conn.Read(idAndHost) - log.Printf("Remote grain %s changed\n", idAndHost) if err != nil { break } @@ -328,7 +326,6 @@ func (p *SyncedPool) handleConnection(conn net.Conn) { if !found { log.Printf("Remote host %s not found\n", idAndHostParts[1]) - log.Printf("Remotes %v\n", p.remotes) } else { SendPacket(conn, AckChange, func(w io.Writer) error { _, err := w.Write([]byte("ok"))