forked from TrueCloudLab/frostfs-s3-gw
Compare commits
1 commit
f215d200e8
...
309b53f1fb
Author | SHA1 | Date | |
---|---|---|---|
309b53f1fb |
7 changed files with 24 additions and 85 deletions
|
@ -4,12 +4,6 @@ This document outlines major changes between releases.
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [0.31.1] - 2024-11-28
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Ignore precondition headers with invalid date format (#563)
|
|
||||||
- MD5 calculation of object-part with SSE-C (#543)
|
|
||||||
|
|
||||||
## [0.31.0] - Rongbuk - 2024-11-20
|
## [0.31.0] - Rongbuk - 2024-11-20
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -348,5 +342,4 @@ To see CHANGELOG for older versions, refer to https://github.com/nspcc-dev/neofs
|
||||||
[0.30.7]: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/compare/v0.30.6...v0.30.7
|
[0.30.7]: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/compare/v0.30.6...v0.30.7
|
||||||
[0.30.8]: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/compare/v0.30.7...v0.30.8
|
[0.30.8]: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/compare/v0.30.7...v0.30.8
|
||||||
[0.31.0]: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/compare/v0.30.8...v0.31.0
|
[0.31.0]: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/compare/v0.30.8...v0.31.0
|
||||||
[0.31.1]: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/compare/v0.31.0...v0.31.1
|
[Unreleased]: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/compare/v0.31.0...master
|
||||||
[Unreleased]: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/compare/v0.31.1...master
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
v0.31.1
|
v0.31.0
|
||||||
|
|
|
@ -84,17 +84,11 @@ type (
|
||||||
bucketResolver *resolver.BucketResolver
|
bucketResolver *resolver.BucketResolver
|
||||||
services []*Service
|
services []*Service
|
||||||
settings *appSettings
|
settings *appSettings
|
||||||
loggerSettings *loggerSettings
|
|
||||||
|
|
||||||
webDone chan struct{}
|
webDone chan struct{}
|
||||||
wrkDone chan struct{}
|
wrkDone chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
loggerSettings struct {
|
|
||||||
mu sync.RWMutex
|
|
||||||
appMetrics *metrics.AppMetrics
|
|
||||||
}
|
|
||||||
|
|
||||||
appSettings struct {
|
appSettings struct {
|
||||||
logLevel zap.AtomicLevel
|
logLevel zap.AtomicLevel
|
||||||
httpLogging s3middleware.LogHTTPConfig
|
httpLogging s3middleware.LogHTTPConfig
|
||||||
|
@ -142,25 +136,7 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *loggerSettings) DroppedLogsInc() {
|
func newApp(ctx context.Context, log *Logger, v *viper.Viper) *App {
|
||||||
s.mu.RLock()
|
|
||||||
defer s.mu.RUnlock()
|
|
||||||
|
|
||||||
if s.appMetrics != nil {
|
|
||||||
s.appMetrics.Statistic().DroppedLogsInc()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *loggerSettings) setMetrics(appMetrics *metrics.AppMetrics) {
|
|
||||||
s.mu.Lock()
|
|
||||||
defer s.mu.Unlock()
|
|
||||||
|
|
||||||
s.appMetrics = appMetrics
|
|
||||||
}
|
|
||||||
|
|
||||||
func newApp(ctx context.Context, v *viper.Viper) *App {
|
|
||||||
logSettings := &loggerSettings{}
|
|
||||||
log := pickLogger(v, logSettings)
|
|
||||||
settings := newAppSettings(log, v)
|
settings := newAppSettings(log, v)
|
||||||
|
|
||||||
objPool, treePool, key := getPools(ctx, log.logger, v, settings.dialerSource)
|
objPool, treePool, key := getPools(ctx, log.logger, v, settings.dialerSource)
|
||||||
|
@ -176,7 +152,6 @@ func newApp(ctx context.Context, v *viper.Viper) *App {
|
||||||
wrkDone: make(chan struct{}, 1),
|
wrkDone: make(chan struct{}, 1),
|
||||||
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
loggerSettings: logSettings,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.init(ctx)
|
app.init(ctx)
|
||||||
|
@ -576,7 +551,6 @@ func (a *App) initMetrics() {
|
||||||
|
|
||||||
a.metrics = metrics.NewAppMetrics(cfg)
|
a.metrics = metrics.NewAppMetrics(cfg)
|
||||||
a.metrics.State().SetHealth(metrics.HealthStatusStarting)
|
a.metrics.State().SetHealth(metrics.HealthStatusStarting)
|
||||||
a.loggerSettings.setMetrics(a.metrics)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) initFrostfsID(ctx context.Context) {
|
func (a *App) initFrostfsID(ctx context.Context) {
|
||||||
|
|
|
@ -1131,11 +1131,7 @@ func mergeConfig(v *viper.Viper, fileName string) error {
|
||||||
return v.MergeConfig(cfgFile)
|
return v.MergeConfig(cfgFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
type LoggerAppSettings interface {
|
func pickLogger(v *viper.Viper) *Logger {
|
||||||
DroppedLogsInc()
|
|
||||||
}
|
|
||||||
|
|
||||||
func pickLogger(v *viper.Viper, settings LoggerAppSettings) *Logger {
|
|
||||||
lvl, err := getLogLevel(v)
|
lvl, err := getLogLevel(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -1145,9 +1141,9 @@ func pickLogger(v *viper.Viper, settings LoggerAppSettings) *Logger {
|
||||||
|
|
||||||
switch dest {
|
switch dest {
|
||||||
case destinationStdout:
|
case destinationStdout:
|
||||||
return newStdoutLogger(v, lvl, settings)
|
return newStdoutLogger(v, lvl)
|
||||||
case destinationJournald:
|
case destinationJournald:
|
||||||
return newJournaldLogger(v, lvl, settings)
|
return newJournaldLogger(v, lvl)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("wrong destination for logger: %s", dest))
|
panic(fmt.Sprintf("wrong destination for logger: %s", dest))
|
||||||
}
|
}
|
||||||
|
@ -1167,13 +1163,13 @@ func pickLogger(v *viper.Viper, settings LoggerAppSettings) *Logger {
|
||||||
// Logger records a stack trace for all messages at or above fatal level.
|
// Logger records a stack trace for all messages at or above fatal level.
|
||||||
//
|
//
|
||||||
// See also zapcore.Level, zap.NewProductionConfig, zap.AddStacktrace.
|
// See also zapcore.Level, zap.NewProductionConfig, zap.AddStacktrace.
|
||||||
func newStdoutLogger(v *viper.Viper, lvl zapcore.Level, settings LoggerAppSettings) *Logger {
|
func newStdoutLogger(v *viper.Viper, lvl zapcore.Level) *Logger {
|
||||||
stdout := zapcore.AddSync(os.Stderr)
|
stdout := zapcore.AddSync(os.Stderr)
|
||||||
level := zap.NewAtomicLevelAt(lvl)
|
level := zap.NewAtomicLevelAt(lvl)
|
||||||
|
|
||||||
consoleOutCore := zapcore.NewCore(newLogEncoder(), stdout, level)
|
consoleOutCore := zapcore.NewCore(newLogEncoder(), stdout, level)
|
||||||
|
|
||||||
consoleOutCore = applyZapCoreMiddlewares(consoleOutCore, v, settings)
|
consoleOutCore = samplingEnabling(v, consoleOutCore)
|
||||||
|
|
||||||
return &Logger{
|
return &Logger{
|
||||||
logger: zap.New(consoleOutCore, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel))),
|
logger: zap.New(consoleOutCore, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel))),
|
||||||
|
@ -1181,7 +1177,7 @@ func newStdoutLogger(v *viper.Viper, lvl zapcore.Level, settings LoggerAppSettin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newJournaldLogger(v *viper.Viper, lvl zapcore.Level, settings LoggerAppSettings) *Logger {
|
func newJournaldLogger(v *viper.Viper, lvl zapcore.Level) *Logger {
|
||||||
level := zap.NewAtomicLevelAt(lvl)
|
level := zap.NewAtomicLevelAt(lvl)
|
||||||
|
|
||||||
encoder := zapjournald.NewPartialEncoder(newLogEncoder(), zapjournald.SyslogFields)
|
encoder := zapjournald.NewPartialEncoder(newLogEncoder(), zapjournald.SyslogFields)
|
||||||
|
@ -1193,7 +1189,7 @@ func newJournaldLogger(v *viper.Viper, lvl zapcore.Level, settings LoggerAppSett
|
||||||
zapjournald.SyslogPid(),
|
zapjournald.SyslogPid(),
|
||||||
})
|
})
|
||||||
|
|
||||||
coreWithContext = applyZapCoreMiddlewares(coreWithContext, v, settings)
|
coreWithContext = samplingEnabling(v, coreWithContext)
|
||||||
|
|
||||||
l := zap.New(coreWithContext, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)))
|
l := zap.New(coreWithContext, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)))
|
||||||
|
|
||||||
|
@ -1210,17 +1206,19 @@ func newLogEncoder() zapcore.Encoder {
|
||||||
return zapcore.NewConsoleEncoder(c)
|
return zapcore.NewConsoleEncoder(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyZapCoreMiddlewares(core zapcore.Core, v *viper.Viper, settings LoggerAppSettings) zapcore.Core {
|
func samplingEnabling(v *viper.Viper, core zapcore.Core) zapcore.Core {
|
||||||
|
// Zap samples by logging the first cgfLoggerSamplingInitial entries with a given level
|
||||||
|
// and message within the specified time interval.
|
||||||
|
// In the above config, only the first cgfLoggerSamplingInitial log entries with the same level and message
|
||||||
|
// are recorded in cfgLoggerSamplingInterval interval. Every other log entry will be dropped within the interval since
|
||||||
|
// cfgLoggerSamplingThereafter is specified here.
|
||||||
if v.GetBool(cfgLoggerSamplingEnabled) {
|
if v.GetBool(cfgLoggerSamplingEnabled) {
|
||||||
core = zapcore.NewSamplerWithOptions(core,
|
core = zapcore.NewSamplerWithOptions(
|
||||||
|
core,
|
||||||
v.GetDuration(cfgLoggerSamplingInterval),
|
v.GetDuration(cfgLoggerSamplingInterval),
|
||||||
v.GetInt(cfgLoggerSamplingInitial),
|
v.GetInt(cfgLoggerSamplingInitial),
|
||||||
v.GetInt(cfgLoggerSamplingThereafter),
|
v.GetInt(cfgLoggerSamplingThereafter),
|
||||||
zapcore.SamplerHook(func(_ zapcore.Entry, dec zapcore.SamplingDecision) {
|
)
|
||||||
if dec&zapcore.LogDropped > 0 {
|
|
||||||
settings.DroppedLogsInc()
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return core
|
return core
|
||||||
|
|
|
@ -8,9 +8,11 @@ import (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
g, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
g, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||||
v := newSettings()
|
|
||||||
|
|
||||||
a := newApp(g, v)
|
v := newSettings()
|
||||||
|
l := pickLogger(v)
|
||||||
|
|
||||||
|
a := newApp(g, l, v)
|
||||||
|
|
||||||
go a.Serve(g)
|
go a.Serve(g)
|
||||||
|
|
||||||
|
|
|
@ -93,13 +93,6 @@ var appMetricsDesc = map[string]map[string]Description{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
statisticSubsystem: {
|
statisticSubsystem: {
|
||||||
droppedLogs: Description{
|
|
||||||
Type: dto.MetricType_COUNTER,
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: statisticSubsystem,
|
|
||||||
Name: droppedLogs,
|
|
||||||
Help: "Dropped logs (by sampling) count",
|
|
||||||
},
|
|
||||||
requestsSecondsMetric: Description{
|
requestsSecondsMetric: Description{
|
||||||
Type: dto.MetricType_HISTOGRAM,
|
Type: dto.MetricType_HISTOGRAM,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
|
@ -259,12 +252,3 @@ func mustNewHistogramVec(description Description, buckets []float64) *prometheus
|
||||||
description.VariableLabels,
|
description.VariableLabels,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustNewCounter(description Description) prometheus.Counter {
|
|
||||||
if description.Type != dto.MetricType_COUNTER {
|
|
||||||
panic("invalid metric type")
|
|
||||||
}
|
|
||||||
return prometheus.NewCounter(
|
|
||||||
prometheus.CounterOpts(newOpts(description)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ type (
|
||||||
APIStatMetrics struct {
|
APIStatMetrics struct {
|
||||||
stats *httpStats
|
stats *httpStats
|
||||||
httpRequestsDuration *prometheus.HistogramVec
|
httpRequestsDuration *prometheus.HistogramVec
|
||||||
droppedLogs prometheus.Counter
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -48,7 +47,6 @@ const (
|
||||||
requestsTotalMetric = "requests_total"
|
requestsTotalMetric = "requests_total"
|
||||||
errorsTotalMetric = "errors_total"
|
errorsTotalMetric = "errors_total"
|
||||||
bytesTotalMetric = "bytes_total"
|
bytesTotalMetric = "bytes_total"
|
||||||
droppedLogs = "dropped_logs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -63,7 +61,6 @@ func newAPIStatMetrics() *APIStatMetrics {
|
||||||
stats: newHTTPStats(),
|
stats: newHTTPStats(),
|
||||||
httpRequestsDuration: mustNewHistogramVec(histogramDesc,
|
httpRequestsDuration: mustNewHistogramVec(histogramDesc,
|
||||||
[]float64{.05, .1, .25, .5, 1, 2.5, 5, 10}),
|
[]float64{.05, .1, .25, .5, 1, 2.5, 5, 10}),
|
||||||
droppedLogs: mustNewCounter(appMetricsDesc[statisticSubsystem][droppedLogs]),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +119,6 @@ func (a *APIStatMetrics) Describe(ch chan<- *prometheus.Desc) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
a.stats.Describe(ch)
|
a.stats.Describe(ch)
|
||||||
a.droppedLogs.Describe(ch)
|
|
||||||
a.httpRequestsDuration.Describe(ch)
|
a.httpRequestsDuration.Describe(ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,17 +127,9 @@ func (a *APIStatMetrics) Collect(ch chan<- prometheus.Metric) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
a.stats.Collect(ch)
|
a.stats.Collect(ch)
|
||||||
a.droppedLogs.Collect(ch)
|
|
||||||
a.httpRequestsDuration.Collect(ch)
|
a.httpRequestsDuration.Collect(ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIStatMetrics) DroppedLogsInc() {
|
|
||||||
if a == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
a.droppedLogs.Inc()
|
|
||||||
}
|
|
||||||
|
|
||||||
func newHTTPStats() *httpStats {
|
func newHTTPStats() *httpStats {
|
||||||
return &httpStats{
|
return &httpStats{
|
||||||
currentS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsCurrentMetric]),
|
currentS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsCurrentMetric]),
|
||||||
|
|
Loading…
Add table
Reference in a new issue