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

api: fix cannot dump trace (#7255) #8754

Open
wants to merge 1 commit into
base: release-6.5
Choose a base branch
from
Open
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
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 @@

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 @@
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
Loading