Skip to content

Commit e88df0a

Browse files
authored
Fix HTTP Server errors (#498)
* Use unmarshalled struct for reading plugin config * Use background context to prevent cancellation
1 parent 2060af4 commit e88df0a

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (a *API) GetGlobalConfig(_ context.Context, group *v1.Group) (*structpb.Str
100100

101101
// GetPluginConfig returns the plugin configuration of the GatewayD.
102102
func (a *API) GetPluginConfig(context.Context, *emptypb.Empty) (*structpb.Struct, error) {
103-
jsonData, err := json.Marshal(a.Config.PluginKoanf.All())
103+
jsonData, err := json.Marshal(a.Config.Plugin)
104104
if err != nil {
105105
metrics.APIRequestsErrors.WithLabelValues(
106106
"GET", "/v1/GatewayDPluginService/GetPluginConfig", codes.Internal.String(),

api/http_server.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,12 @@ func (s *HTTPServer) Shutdown(ctx context.Context) {
5050

5151
// CreateHTTPAPI creates a new HTTP API.
5252
func createHTTPAPI(options *Options) *http.Server {
53-
ctx := context.Background()
54-
ctx, cancel := context.WithCancel(ctx)
55-
defer cancel()
56-
5753
// Register gRPC server endpoint
5854
// TODO: Make this configurable with TLS and Auth.
5955
rmux := runtime.NewServeMux()
6056
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
6157
err := v1.RegisterGatewayDAdminAPIServiceHandlerFromEndpoint(
62-
ctx, rmux, options.GRPCAddress, opts)
58+
context.Background(), rmux, options.GRPCAddress, opts)
6359
if err != nil {
6460
options.Logger.Err(err).Msg("failed to start HTTP API")
6561
}

0 commit comments

Comments
 (0)