From 71d82d1cc81a1f8483f4ba1c9cf2410c68d1f2af Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Thu, 25 Jan 2024 09:37:43 +0300 Subject: [PATCH] [#165] Fix lint issues Signed-off-by: Denis Kirillov --- api/handler/object_list_test.go | 64 +++------------------------------ api/layer/listing.go | 2 +- config/config.env | 1 - docs/configuration.md | 10 +++--- internal/logs/logs.go | 1 + 5 files changed, 11 insertions(+), 67 deletions(-) diff --git a/api/handler/object_list_test.go b/api/handler/object_list_test.go index e7e97955..829220ca 100644 --- a/api/handler/object_list_test.go +++ b/api/handler/object_list_test.go @@ -7,7 +7,6 @@ import ( "net/url" "sort" "strconv" - "strings" "testing" "time" @@ -108,61 +107,6 @@ func TestListObjectsWithOldTreeNodes(t *testing.T) { require.Equal(t, realSize, list.Contents[0].Size) } -func prepareObjects(hc *handlerContext, bktInfo *data.BucketInfo, prefix string, size int) []string { - treeID := "version" - parentID := uint64(0) - if prefix != "" { - for _, filename := range strings.Split(prefix, "/") { - nodeID, err := hc.treeMock.AddNode(hc.Context(), bktInfo, treeID, parentID, map[string]string{ - "FileName": filename, - }) - require.NoError(hc.t, err) - parentID = nodeID - } - prefix += "/" - } - - objects := make([]string, size) - - for i := range objects { - filename := "object" + strconv.Itoa(i) - filepath := prefix + filename - - prm := layer.PrmObjectCreate{ - Container: bktInfo.CID, - Filepath: filepath, - Payload: nil, - } - - id, err := hc.tp.CreateObject(hc.Context(), prm) - require.NoError(hc.t, err) - - newVersion := &data.NodeVersion{ - BaseNodeVersion: data.BaseNodeVersion{ - OID: id, - ETag: "12345678", - FilePath: filepath, - }, - IsUnversioned: true, - IsCombined: false, - } - - _, err = hc.treeMock.AddNodeBase(hc.Context(), bktInfo, treeID, parentID, map[string]string{ - "OID": newVersion.OID.EncodeToString(), - "FileName": filename, - "IsUnversioned": "true", - }, false) - require.NoError(hc.t, err) - objects[i] = filepath - } - - hc.treeMock.Sort() - - sort.Strings(objects) - - return objects -} - func TestListObjectsContextCanceled(t *testing.T) { layerCfg := layer.DefaultCachesConfigs(zaptest.NewLogger(t)) layerCfg.SessionList.Lifetime = time.Hour @@ -182,23 +126,23 @@ func TestListObjectsContextCanceled(t *testing.T) { // invoke list again to trigger cache eviction // (use empty prefix to check that context canceled on replace) listObjectsV1(hc, bktName, "", "", "", 2) - checkContextCanceled(t, session.Context) + checkContextCanceled(session.Context, t) result2 := listObjectsV2(hc, bktName, "", "", "", "", 2) session2 := hc.cache.GetListSession(hc.owner, cache.CreateListSessionCacheKey(bktInfo.CID, "", result2.NextContinuationToken)) // invoke list again to trigger cache eviction // (use non-empty prefix to check that context canceled on cache eviction) listObjectsV2(hc, bktName, "o", "", "", "", 2) - checkContextCanceled(t, session2.Context) + checkContextCanceled(session2.Context, t) result3 := listObjectsVersions(hc, bktName, "", "", "", "", 2) session3 := hc.cache.GetListSession(hc.owner, cache.CreateListSessionCacheKey(bktInfo.CID, "", result3.NextVersionIDMarker)) // invoke list again to trigger cache eviction listObjectsVersions(hc, bktName, "o", "", "", "", 2) - checkContextCanceled(t, session3.Context) + checkContextCanceled(session3.Context, t) } -func checkContextCanceled(t *testing.T, ctx context.Context) { +func checkContextCanceled(ctx context.Context, t *testing.T) { select { case <-ctx.Done(): case <-time.After(10 * time.Second): diff --git a/api/layer/listing.go b/api/layer/listing.go index f41b5e04..f02f3445 100644 --- a/api/layer/listing.go +++ b/api/layer/listing.go @@ -537,7 +537,7 @@ func (n *layer) initWorkerPool(ctx context.Context, size int, p commonVersionsLi realSize, err := GetObjectSize(oi) if err != nil { - reqLog.Debug("failed to get real object size", zap.Error(err)) + reqLog.Debug(logs.FailedToGetRealObjectSize, zap.Error(err)) realSize = oi.Size } diff --git a/config/config.env b/config/config.env index 6ce53864..7291a8fc 100644 --- a/config/config.env +++ b/config/config.env @@ -213,4 +213,3 @@ S3_GW_PROXY_CONTRACT=proxy.frostfs # Namespaces configuration S3_GW_NAMESPACES_CONFIG=namespaces.json - diff --git a/docs/configuration.md b/docs/configuration.md index 2ec1da5a..dcecdfaf 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -365,7 +365,7 @@ control: - 035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11 - 028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6 grpc: - endpoint: localhost:8083 + endpoint: localhost:8083 ``` | Parameter | Type | SIGHUP reload | Default value | Description | @@ -643,7 +643,7 @@ FrostfsID contract configuration. To enable this functionality the `rpc_endpoint ```yaml frostfsid: contract: frostfsid.frostfs - validation: + validation: enabled: false ``` @@ -693,10 +693,10 @@ namespaces: |-----------|----------|---------------|---------------|-----------------------------------------------------| | `config` | `string` | yes | | Path to json file with config value for namespaces. | -## `namespaces.config` subsection +## `namespaces.config` subsection Example of `namespaces.json`. -Note that config values from `namespaces.json` can override config values for default namespaces +Note that config values from `namespaces.json` can override config values for default namespaces (value for which are fetched from regular config value e.g. [placement-policy](#placement_policy-section)). To override config values for default namespaces use namespace names that are provided in `kludge.default_namespaces`. @@ -705,7 +705,7 @@ To override config values for default namespaces use namespace names that are pr "namespaces": { "namespace1": { "location_constraints": { - "default": "REP 3", + "default": "REP 3", "test": "{\"replicas\":[{\"count\":1,\"selector\":\"\"}],\"containerBackupFactor\":0,\"selectors\":[],\"filters\":[],\"unique\":false}" }, "copies_numbers": { diff --git a/internal/logs/logs.go b/internal/logs/logs.go index 510a3bac..7aba6c34 100644 --- a/internal/logs/logs.go +++ b/internal/logs/logs.go @@ -139,4 +139,5 @@ const ( ControlAPIListPolicies = "list policies request" PolicyValidationFailed = "policy validation failed" ParseTreeNode = "parse tree node" + FailedToGetRealObjectSize = "failed to get real object size" )