diff --git a/core/stat/node_storage.go b/core/stat/node_storage.go index cea5127e..819fcd64 100644 --- a/core/stat/node_storage.go +++ b/core/stat/node_storage.go @@ -54,6 +54,17 @@ func GetResourceNode(resource string) *ResourceNode { return resNodeMap[resource] } +func RemoveResourceNodes(resources []string) { + if len(resources) == 0 { + return + } + rnsMux.Lock() + defer rnsMux.Unlock() + for _, resource := range resources { + delete(resNodeMap, resource) + } +} + func GetOrCreateResourceNode(resource string, resourceType base.ResourceType) *ResourceNode { node := GetResourceNode(resource) if node != nil { diff --git a/core/stat/node_storage_test.go b/core/stat/node_storage_test.go new file mode 100644 index 00000000..17f86966 --- /dev/null +++ b/core/stat/node_storage_test.go @@ -0,0 +1,29 @@ +package stat + +import "testing" + +func TestRemoveResourceNodes(t *testing.T) { + type args struct { + resources []string + } + tests := []struct { + name string + args args + }{ + { + name: "empty", + args: args{}, + }, + { + name: "normal", + args: args{ + resources: []string{"test"}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + RemoveResourceNodes(tt.args.resources) + }) + } +}