|
6 | 6 | package server
|
7 | 7 |
|
8 | 8 | import (
|
9 |
| - "bytes" |
10 | 9 | "context"
|
11 | 10 | "encoding/json"
|
12 | 11 | "fmt"
|
13 |
| - "io" |
14 |
| - "net/http" |
15 | 12 | "sort"
|
16 | 13 | "strconv"
|
17 | 14 | "strings"
|
@@ -77,10 +74,8 @@ import (
|
77 | 74 | "github.com/cockroachdb/errors"
|
78 | 75 | "github.com/cockroachdb/redact"
|
79 | 76 | gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
80 |
| - gwutil "github.com/grpc-ecosystem/grpc-gateway/utilities" |
81 | 77 | "google.golang.org/grpc"
|
82 | 78 | "google.golang.org/grpc/codes"
|
83 |
| - "google.golang.org/grpc/metadata" |
84 | 79 | grpcstatus "google.golang.org/grpc/status"
|
85 | 80 | "storj.io/drpc"
|
86 | 81 | "storj.io/drpc/drpcerr"
|
@@ -280,44 +275,6 @@ func (s *adminServer) RegisterDRPCService(d drpc.Mux) error {
|
280 | 275 | func (s *adminServer) RegisterGateway(
|
281 | 276 | ctx context.Context, mux *gwruntime.ServeMux, conn *grpc.ClientConn,
|
282 | 277 | ) error {
|
283 |
| - // Register the /_admin/v1/stmtbundle endpoint, which serves statement support |
284 |
| - // bundles as files. |
285 |
| - stmtBundlePattern := gwruntime.MustPattern(gwruntime.NewPattern( |
286 |
| - 1, /* version */ |
287 |
| - []int{ |
288 |
| - int(gwutil.OpLitPush), 0, int(gwutil.OpLitPush), 1, int(gwutil.OpLitPush), 2, |
289 |
| - int(gwutil.OpPush), 0, int(gwutil.OpConcatN), 1, int(gwutil.OpCapture), 3}, |
290 |
| - []string{"_admin", "v1", "stmtbundle", "id"}, |
291 |
| - "", /* verb */ |
292 |
| - )) |
293 |
| - |
294 |
| - mux.Handle("GET", stmtBundlePattern, func( |
295 |
| - w http.ResponseWriter, req *http.Request, pathParams map[string]string, |
296 |
| - ) { |
297 |
| - idStr, ok := pathParams["id"] |
298 |
| - if !ok { |
299 |
| - http.Error(w, "missing id", http.StatusBadRequest) |
300 |
| - return |
301 |
| - } |
302 |
| - id, err := strconv.ParseInt(idStr, 10, 64) |
303 |
| - if err != nil { |
304 |
| - http.Error(w, "invalid id", http.StatusBadRequest) |
305 |
| - return |
306 |
| - } |
307 |
| - |
308 |
| - // The privilege checks in the privilege checker below checks the user in the incoming |
309 |
| - // gRPC metadata. |
310 |
| - md := authserver.TranslateHTTPAuthInfoToGRPCMetadata(req.Context(), req) |
311 |
| - authCtx := metadata.NewIncomingContext(req.Context(), md) |
312 |
| - authCtx = s.AnnotateCtx(authCtx) |
313 |
| - if err := s.privilegeChecker.RequireViewActivityAndNoViewActivityRedactedPermission(authCtx); err != nil { |
314 |
| - http.Error(w, err.Error(), http.StatusForbidden) |
315 |
| - return |
316 |
| - } |
317 |
| - s.getStatementBundle(req.Context(), id, w) |
318 |
| - }) |
319 |
| - |
320 |
| - // Register the endpoints defined in the proto. |
321 | 278 | return serverpb.RegisterAdminHandler(ctx, mux, conn)
|
322 | 279 | }
|
323 | 280 |
|
@@ -2646,55 +2603,6 @@ func (s *adminServer) QueryPlan(
|
2646 | 2603 | }, nil
|
2647 | 2604 | }
|
2648 | 2605 |
|
2649 |
| -// getStatementBundle retrieves the statement bundle with the given id and |
2650 |
| -// writes it out as an attachment. Note this function assumes the user has |
2651 |
| -// permission to access the statement bundle. |
2652 |
| -func (s *adminServer) getStatementBundle(ctx context.Context, id int64, w http.ResponseWriter) { |
2653 |
| - row, err := s.internalExecutor.QueryRowEx( |
2654 |
| - ctx, "admin-stmt-bundle", nil, /* txn */ |
2655 |
| - sessiondata.NodeUserSessionDataOverride, |
2656 |
| - "SELECT bundle_chunks FROM system.statement_diagnostics WHERE id=$1 AND bundle_chunks IS NOT NULL", |
2657 |
| - id, |
2658 |
| - ) |
2659 |
| - if err != nil { |
2660 |
| - http.Error(w, err.Error(), http.StatusInternalServerError) |
2661 |
| - return |
2662 |
| - } |
2663 |
| - if row == nil { |
2664 |
| - http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) |
2665 |
| - return |
2666 |
| - } |
2667 |
| - // Put together the entire bundle. Ideally we would stream it in chunks, |
2668 |
| - // but it's hard to return errors once we start. |
2669 |
| - var bundle bytes.Buffer |
2670 |
| - chunkIDs := row[0].(*tree.DArray).Array |
2671 |
| - for _, chunkID := range chunkIDs { |
2672 |
| - chunkRow, err := s.internalExecutor.QueryRowEx( |
2673 |
| - ctx, "admin-stmt-bundle", nil, /* txn */ |
2674 |
| - sessiondata.NodeUserSessionDataOverride, |
2675 |
| - "SELECT data FROM system.statement_bundle_chunks WHERE id=$1", |
2676 |
| - chunkID, |
2677 |
| - ) |
2678 |
| - if err != nil { |
2679 |
| - http.Error(w, err.Error(), http.StatusInternalServerError) |
2680 |
| - return |
2681 |
| - } |
2682 |
| - if chunkRow == nil { |
2683 |
| - http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) |
2684 |
| - return |
2685 |
| - } |
2686 |
| - data := chunkRow[0].(*tree.DBytes) |
2687 |
| - bundle.WriteString(string(*data)) |
2688 |
| - } |
2689 |
| - |
2690 |
| - w.Header().Set( |
2691 |
| - "Content-Disposition", |
2692 |
| - fmt.Sprintf("attachment; filename=stmt-bundle-%d.zip", id), |
2693 |
| - ) |
2694 |
| - |
2695 |
| - _, _ = io.Copy(w, &bundle) |
2696 |
| -} |
2697 |
| - |
2698 | 2606 | // DecommissionPreCheck runs checks and returns the DecommissionPreCheckResponse
|
2699 | 2607 | // for the given nodes.
|
2700 | 2608 | func (s *systemAdminServer) DecommissionPreCheck(
|
|
0 commit comments