From ff3d46637d7adaf364f6384c3d631d16c9741363 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 7 Sep 2024 12:38:34 -0700 Subject: [PATCH] better logging for volume growth --- weed/server/master_grpc_server_assign.go | 6 +++++- weed/server/master_grpc_server_volume.go | 3 +++ weed/server/master_server_handlers.go | 1 + weed/topology/volume_growth.go | 2 +- weed/topology/volume_layout.go | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/weed/server/master_grpc_server_assign.go b/weed/server/master_grpc_server_assign.go index c45184541..a85045f7d 100644 --- a/weed/server/master_grpc_server_assign.go +++ b/weed/server/master_grpc_server_assign.go @@ -93,10 +93,11 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest ms.volumeGrowthRequestChan <- &topology.VolumeGrowRequest{ Option: option, Count: req.WritableVolumeCount, + Reason: "grpc assign", } } if err != nil { - glog.V(0).Infof("assign %v %v: %v", req, option.String(), err) + glog.V(1).Infof("assign %v %v: %v", req, option.String(), err) stats.MasterPickForWriteErrorCounter.Inc() lastErr = err time.Sleep(200 * time.Millisecond) @@ -128,5 +129,8 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest Replicas: replicas, }, nil } + if lastErr != nil { + glog.V(0).Infof("assign %v %v: %v", req, option.String(), lastErr) + } return nil, lastErr } diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.go index ec0dcf8a1..db0976fb7 100644 --- a/weed/server/master_grpc_server_volume.go +++ b/weed/server/master_grpc_server_volume.go @@ -51,6 +51,7 @@ func (ms *MasterServer) ProcessGrowRequest() { ms.volumeGrowthRequestChan <- &topology.VolumeGrowRequest{ Option: vlc.ToGrowOption(), Count: vl.GetLastGrowCount(), + Reason: "collection autogrow", } } else { for _, dc := range dcs { @@ -62,6 +63,7 @@ func (ms *MasterServer) ProcessGrowRequest() { Option: volumeGrowOption, Count: vl.GetLastGrowCount(), Force: true, + Reason: "per-dc autogrow", } } } @@ -108,6 +110,7 @@ func (ms *MasterServer) ProcessGrowRequest() { filter.Store(req, nil) // we have lock called inside vg + glog.V(0).Infof("volume grow %+v", req) go func(req *topology.VolumeGrowRequest, vl *topology.VolumeLayout) { ms.DoAutomaticVolumeGrow(req) vl.DoneGrowRequest() diff --git a/weed/server/master_server_handlers.go b/weed/server/master_server_handlers.go index 5e17bcca8..f49b04e8c 100644 --- a/weed/server/master_server_handlers.go +++ b/weed/server/master_server_handlers.go @@ -151,6 +151,7 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request) ms.volumeGrowthRequestChan <- &topology.VolumeGrowRequest{ Option: option, Count: uint32(writableVolumeCount), + Reason: "http assign", } } if err != nil { diff --git a/weed/topology/volume_growth.go b/weed/topology/volume_growth.go index 44462aa87..d856bbc22 100644 --- a/weed/topology/volume_growth.go +++ b/weed/topology/volume_growth.go @@ -34,7 +34,7 @@ type VolumeGrowRequest struct { } func (vg *VolumeGrowRequest) Equals(req *VolumeGrowRequest) bool { - return reflect.DeepEqual(existingReq.Option, req.Option) && vg.Count == req.Count + return reflect.DeepEqual(vg.Option, req.Option) && vg.Count == req.Count && vg.Force == req.Force } type volumeGrowthStrategy struct { diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go index baa9b91d4..0951da60e 100644 --- a/weed/topology/volume_layout.go +++ b/weed/topology/volume_layout.go @@ -301,7 +301,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi lenWriters := len(vl.writables) if lenWriters <= 0 { - return 0, 0, nil, true, fmt.Errorf("%s in volume layout", noWritableVolumes) + return 0, 0, nil, true, fmt.Errorf("%s", noWritableVolumes) } if option.DataCenter == "" && option.Rack == "" && option.DataNode == "" { vid := vl.writables[rand.Intn(lenWriters)]