From 46936a4e6759f07619b52c81a37f87b651c07fff Mon Sep 17 00:00:00 2001 From: Ben Brooks Date: Tue, 23 Jul 2024 19:12:10 +0100 Subject: [PATCH 1/2] Create base.AuditIDClusterInfoRead event --- rest/admin_api.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/rest/admin_api.go b/rest/admin_api.go index eb4109851d..c6f1989bfa 100644 --- a/rest/admin_api.go +++ b/rest/admin_api.go @@ -2147,36 +2147,36 @@ type BucketInfo struct { // information (registry) for each func (h *handler) handleGetClusterInfo() error { - // If not using persistent config, returns legacy_config:true - if h.server.persistentConfig == false { - clusterInfo := ClusterInfo{ - LegacyConfig: true, - } - h.writeJSON(clusterInfo) - return nil - } - clusterInfo := ClusterInfo{ - Buckets: make(map[string]BucketInfo), + LegacyConfig: true, } - bucketNames, err := h.server.GetBucketNames() - if err != nil { - return err - } + if !h.server.persistentConfig { - for _, bucketName := range bucketNames { - registry, err := h.server.BootstrapContext.getGatewayRegistry(h.ctx(), bucketName) + bucketNames, err := h.server.GetBucketNames() if err != nil { - base.InfofCtx(h.ctx(), base.KeyAll, "Unable to retrieve registry for bucket %s during getClusterInfo: %v", base.MD(bucketName), err) - continue + return err } - bucketInfo := BucketInfo{ - Registry: *registry, + clusterInfo = ClusterInfo{ + Buckets: make(map[string]BucketInfo, len(bucketNames)), + } + + for _, bucketName := range bucketNames { + registry, err := h.server.BootstrapContext.getGatewayRegistry(h.ctx(), bucketName) + if err != nil { + base.InfofCtx(h.ctx(), base.KeyAll, "Unable to retrieve registry for bucket %s during getClusterInfo: %v", base.MD(bucketName), err) + continue + } + + bucketInfo := BucketInfo{ + Registry: *registry, + } + clusterInfo.Buckets[bucketName] = bucketInfo } - clusterInfo.Buckets[bucketName] = bucketInfo } + + base.Audit(h.ctx(), base.AuditIDClusterInfoRead, nil) h.writeJSON(clusterInfo) return nil } From d407d4a3587f735a231c001b82ceb1065daa0d9c Mon Sep 17 00:00:00 2001 From: Ben Brooks Date: Tue, 23 Jul 2024 21:46:39 +0100 Subject: [PATCH 2/2] Update rest/admin_api.go --- rest/admin_api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/admin_api.go b/rest/admin_api.go index c6f1989bfa..143a85f49c 100644 --- a/rest/admin_api.go +++ b/rest/admin_api.go @@ -2151,7 +2151,7 @@ func (h *handler) handleGetClusterInfo() error { LegacyConfig: true, } - if !h.server.persistentConfig { + if h.server.persistentConfig { bucketNames, err := h.server.GetBucketNames() if err != nil {