Skip to content

Commit

Permalink
This is an automated cherry-pick of #7255
Browse files Browse the repository at this point in the history
close #7253

Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
nolouch authored and ti-chi-bot committed Oct 30, 2024
1 parent 6d7be9a commit b3e66ec
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ package server

import (
"context"
<<<<<<< HEAD

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / statics

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / statics

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (1)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (1)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / tso-function-test

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (2)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (2)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (3)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (3)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (4)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (4)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (5)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (5)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (6)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (6)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (7)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (7)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (8)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (8)

expected 'STRING', found '<<'

Check failure on line 19 in server/util.go

View workflow job for this annotation

GitHub Actions / chunks (10)

expected 'STRING', found '<<'
"fmt"
"math/rand"
=======
"net/http"
"net/http/pprof"
>>>>>>> bfc988bb3 (api: fix cannot dump trace (#7255))
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -160,6 +165,56 @@ func checkBootstrapRequest(clusterID uint64, req *pdpb.BootstrapRequest) error {
return nil
}

<<<<<<< HEAD
=======
func combineBuilderServerHTTPService(ctx context.Context, svr *Server, serviceBuilders ...HandlerBuilder) (map[string]http.Handler, error) {
userHandlers := make(map[string]http.Handler)
registerMap := make(map[string]http.Handler)

apiService := negroni.New()
recovery := negroni.NewRecovery()
apiService.Use(recovery)
router := mux.NewRouter()

for _, build := range serviceBuilders {
handler, info, err := build(ctx, svr)
if err != nil {
return nil, err
}
if !info.IsCore && len(info.PathPrefix) == 0 && (len(info.Name) == 0 || len(info.Version) == 0) {
return nil, errs.ErrAPIInformationInvalid.FastGenByArgs(info.Name, info.Version)
}

if err := apiutil.RegisterUserDefinedHandlers(registerMap, &info, handler); err != nil {
return nil, err
}
}

// Combine the pd service to the router. the extension service will be added to the userHandlers.
for pathPrefix, handler := range registerMap {
if strings.Contains(pathPrefix, apiutil.CorePath) || strings.Contains(pathPrefix, apiutil.ExtensionsPath) {
router.PathPrefix(pathPrefix).Handler(handler)
if pathPrefix == apiutil.CorePath {
// Deprecated
router.Path("/pd/health").Handler(handler)
// Deprecated
router.Path("/pd/ping").Handler(handler)
}
} else {
userHandlers[pathPrefix] = handler
}
}

apiService.UseHandler(router)
userHandlers[pdAPIPrefix] = apiService

// fix issue https://github.com/tikv/pd/issues/7253
// FIXME: remove me after upgrade
userHandlers["/debug/pprof/trace"] = http.HandlerFunc(pprof.Trace)
return userHandlers, nil
}

>>>>>>> bfc988bb3 (api: fix cannot dump trace (#7255))
func isPathInDirectory(path, directory string) bool {
absPath, err := filepath.Abs(path)
if err != nil {
Expand Down

0 comments on commit b3e66ec

Please sign in to comment.