From 9b34413e17757af891cd56bd5ff74b99416ce3f2 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 21 Aug 2023 16:50:23 +0300 Subject: [PATCH] [#70] Support client cut Signed-off-by: Denis Kirillov --- CHANGELOG.md | 1 + cmd/http-gw/app.go | 14 ++++++++++++++ cmd/http-gw/settings.go | 3 +++ config/config.env | 4 ++++ config/config.yaml | 5 +++++ docs/gate-configuration.md | 16 +++++++++++++++- internal/handler/handler.go | 1 + internal/handler/upload.go | 1 + 8 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d323c89..d660f10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This document outlines major changes between releases. - Support impersonate bearer token (#40, #45) - Tracing support (#20, #44, #60) - Object name resolving with tree service (#30) +- Add new `frostfs.client_cut` config param (#70) ### Changed - Update prometheus to v1.15.0 (#35) diff --git a/cmd/http-gw/app.go b/cmd/http-gw/app.go index e8ac917..93a6b6c 100644 --- a/cmd/http-gw/app.go +++ b/cmd/http-gw/app.go @@ -75,6 +75,7 @@ type ( mu sync.RWMutex defaultTimestamp bool zipCompression bool + clientCut bool } ) @@ -164,6 +165,18 @@ func (s *appSettings) setZipCompression(val bool) { s.mu.Unlock() } +func (s *appSettings) ClientCut() bool { + s.mu.RLock() + defer s.mu.RUnlock() + return s.clientCut +} + +func (s *appSettings) setClientCut(val bool) { + s.mu.Lock() + s.clientCut = val + s.mu.Unlock() +} + func (a *app) initAppSettings() { a.settings = &appSettings{} @@ -448,6 +461,7 @@ func (a *app) configReload(ctx context.Context) { func (a *app) updateSettings() { a.settings.setDefaultTimestamp(a.cfg.GetBool(cfgUploaderHeaderEnableDefaultTimestamp)) a.settings.setZipCompression(a.cfg.GetBool(cfgZipCompression)) + a.settings.setClientCut(a.cfg.GetBool(cfgClientCut)) } func (a *app) startServices() { diff --git a/cmd/http-gw/settings.go b/cmd/http-gw/settings.go index 6708ad4..86718eb 100644 --- a/cmd/http-gw/settings.go +++ b/cmd/http-gw/settings.go @@ -96,6 +96,9 @@ const ( // Runtime. cfgSoftMemoryLimit = "runtime.soft_memory_limit" + // Enabling client side object preparing for PUT operations. + cfgClientCut = "frostfs.client_cut" + // Command line args. cmdHelp = "help" cmdVersion = "version" diff --git a/config/config.env b/config/config.env index 62920a2..58e6814 100644 --- a/config/config.env +++ b/config/config.env @@ -98,3 +98,7 @@ HTTP_GW_TRACING_ENDPOINT="localhost:4317" HTTP_GW_TRACING_EXPORTER="otlp_grpc" HTTP_GW_RUNTIME_SOFT_MEMORY_LIMIT=1073741824 + +# Parameters of requests to FrostFS +# This flag enables client side object preparing. +HTTP_GW_FROSTFS_CLIENT_CUT=false diff --git a/config/config.yaml b/config/config.yaml index d2804d6..3eae752 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -104,3 +104,8 @@ zip: runtime: soft_memory_limit: 1gb + +# Parameters of requests to FrostFS +frostfs: + # This flag enables client side object preparing. + client_cut: false diff --git a/docs/gate-configuration.md b/docs/gate-configuration.md index 95e6c8e..25d068b 100644 --- a/docs/gate-configuration.md +++ b/docs/gate-configuration.md @@ -54,6 +54,7 @@ $ cat http.log | `prometheus` | [Prometheus configuration](#prometheus-section) | | `tracing` | [Tracing configuration](#tracing-section) | | `runtime` | [Runtime configuration](#runtime-section) | +| `frostfs` | [Frostfs configuration](#frostfs-section) | # General section @@ -268,4 +269,17 @@ runtime: | Parameter | Type | SIGHUP reload | Default value | Description | |---------------------|--------|---------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `soft_memory_limit` | `size` | yes | maxint64 | Soft memory limit for the runtime. Zero or no value stands for no limit. If `GOMEMLIMIT` environment variable is set, the value from the configuration file will be ignored. | \ No newline at end of file +| `soft_memory_limit` | `size` | yes | maxint64 | Soft memory limit for the runtime. Zero or no value stands for no limit. If `GOMEMLIMIT` environment variable is set, the value from the configuration file will be ignored. | + +# `frostfs` section + +Contains parameters of requests to FrostFS. + +```yaml +frostfs: + client_cut: false +``` + +| Parameter | Type | SIGHUP reload | Default value | Description | +|--------------|--------|---------------|---------------|-------------------------------------------------| +| `client_cut` | `bool` | yes | `false` | This flag enables client side object preparing. | diff --git a/internal/handler/handler.go b/internal/handler/handler.go index 579a55f..2bb4347 100644 --- a/internal/handler/handler.go +++ b/internal/handler/handler.go @@ -23,6 +23,7 @@ import ( type Config interface { DefaultTimestamp() bool ZipCompression() bool + ClientCut() bool } type Handler struct { diff --git a/internal/handler/upload.go b/internal/handler/upload.go index f5e0459..a8c4365 100644 --- a/internal/handler/upload.go +++ b/internal/handler/upload.go @@ -136,6 +136,7 @@ func (h *Handler) Upload(req *fasthttp.RequestCtx) { var prm pool.PrmObjectPut prm.SetHeader(*obj) prm.SetPayload(file) + prm.SetClientCut(h.config.ClientCut()) bt := h.fetchBearerToken(ctx) if bt != nil {