Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HTTP compression experimental flags #6772

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ For details about compatibility between different releases, see the **Commitment

### Removed

- The `http.client.transport.compression` and `http.server.transport.compression` experimental flags.

### Fixed

### Security
Expand Down
7 changes: 1 addition & 6 deletions pkg/httpclient/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ import (
"github.com/klauspost/compress/gzhttp"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.thethings.network/lorawan-stack/v3/pkg/config/tlsconfig"
"go.thethings.network/lorawan-stack/v3/pkg/experimental"
"go.thethings.network/lorawan-stack/v3/pkg/telemetry/tracing"
"go.thethings.network/lorawan-stack/v3/pkg/version"
)

var transportCompressionFeatureFlag = experimental.DefineFeature("http.client.transport.compression", true)

// defaultHTTPClientTimeout is the default timeout for the HTTP client.
const defaultHTTPClientTimeout = 10 * time.Second

Expand Down Expand Up @@ -100,9 +97,7 @@ func (p *provider) HTTPClient(ctx context.Context, opts ...Option) (*http.Client
transport.TLSClientConfig = options.tlsConfig

var rt http.RoundTripper = transport
if transportCompressionFeatureFlag.GetValue(ctx) {
rt = gzhttp.Transport(rt)
}
rt = gzhttp.Transport(rt)
rt = otelhttp.NewTransport(
rt,
otelhttp.WithTracerProvider(tracing.FromContext(ctx)),
Expand Down
18 changes: 2 additions & 16 deletions pkg/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/klauspost/compress/gzhttp"
"go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux"
"go.thethings.network/lorawan-stack/v3/pkg/errors"
"go.thethings.network/lorawan-stack/v3/pkg/experimental"
"go.thethings.network/lorawan-stack/v3/pkg/fillcontext"
"go.thethings.network/lorawan-stack/v3/pkg/log"
"go.thethings.network/lorawan-stack/v3/pkg/random"
Expand All @@ -41,19 +40,6 @@ import (
"gopkg.in/yaml.v2"
)

var responseCompressionFeatureFlag = experimental.DefineFeature("http.server.transport.compression", true)

func compressionMiddleware(ctx context.Context) (func(http.Handler) http.Handler, error) {
if !responseCompressionFeatureFlag.GetValue(ctx) {
return func(next http.Handler) http.Handler { return next }, nil
}
m, err := gzhttp.NewWrapper()
if err != nil {
return nil, err
}
return func(h http.Handler) http.Handler { return m(h) }, nil
}

// Registerer allows components to register their services to the web server.
type Registerer interface {
RegisterRoutes(s *Server)
Expand Down Expand Up @@ -189,7 +175,7 @@ func New(ctx context.Context, opts ...Option) (*Server, error) {
if err := proxyConfiguration.ParseAndAddTrusted(options.trustedProxies...); err != nil {
return nil, err
}
compressor, err := compressionMiddleware(ctx)
compressor, err := gzhttp.NewWrapper()
if err != nil {
return nil, err
}
Expand All @@ -200,7 +186,7 @@ func New(ctx context.Context, opts ...Option) (*Server, error) {
"text/html": webhandlers.Template,
}),
mux.MiddlewareFunc(webmiddleware.Recover()),
compressor,
func(next http.Handler) http.Handler { return compressor(next) },
otelmux.Middleware("ttn-lw-stack", otelmux.WithTracerProvider(tracing.FromContext(ctx))),
mux.MiddlewareFunc(webmiddleware.FillContext(options.contextFillers...)),
mux.MiddlewareFunc(webmiddleware.Peer()),
Expand Down
Loading