[#70] Support client cut

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2023-08-21 16:50:23 +03:00 committed by Alexey Vanin
parent e61b4867c9
commit 9b34413e17
8 changed files with 44 additions and 1 deletions

View file

@ -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)

View file

@ -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() {

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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
@ -269,3 +270,16 @@ 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. |
# `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. |

View file

@ -23,6 +23,7 @@ import (
type Config interface {
DefaultTimestamp() bool
ZipCompression() bool
ClientCut() bool
}
type Handler struct {

View file

@ -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 {