Skip to content

Commit

Permalink
fix(admin): refresh cluster metadata while adding storage node
Browse files Browse the repository at this point in the history
It fixes a transient error caused by fetching cluster metadata too lately while handling
AddStorageNode. This PR lets the AddStorageNode RPC handler fetch the cluster metadata forcibly.
Although it isn't a critical error and can be resolved through a simple retry, it is resolved
quickly by fetching the cluster metadata.

Error example:

```
--- FAIL: TestVarlogAppend (5.38s)
    controller.go:62:
        	Error Trace:	/home/runner/work/varlog/varlog/tests/ee/controller/controller.go:62
        	            				/home/runner/work/varlog/varlog/tests/ee/cluster/local/cluster.go:238
        	            				/home/runner/work/varlog/varlog/tests/ee/cluster/local/cluster.go:63
        	            				/home/runner/work/varlog/varlog/tests/ee/ee_test.go:32
        	Error:      	Received unexpected error:
        	            	exit status 255
        	Test:       	TestVarlogAppend
        	Messages:   	/home/runner/work/varlog/varlog/bin/varlogctl storagenode add --storage-node-id 1 --storage-node-address 127.0.0.1:20001 --admin 127.0.0.1:9093: rpc error: code = Unavailable desc = add storage node: call again
```
  • Loading branch information
ijsong committed Jul 31, 2023
1 parent e5b6a2e commit 342598c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ func (adm *Admin) addStorageNode(ctx context.Context, snid types.StorageNodeID,
}

adm.snmgr.AddStorageNode(ctx, snmd.StorageNode.StorageNodeID, addr)
_, _ = adm.mrmgr.ClusterMetadataView().ClusterMetadata(ctx) // Fetch new cluster metadata.
adm.statRepository.Report(ctx, snmd, now)
snm, ok := adm.statRepository.GetStorageNode(snid)
if !ok {
Expand Down

0 comments on commit 342598c

Please sign in to comment.