Skip to content

Commit

Permalink
Add go profiling flag, and enable on integration tests (#1382)
Browse files Browse the repository at this point in the history
  • Loading branch information
kradalby authored Apr 27, 2023
1 parent d011373 commit 56dd734
Show file tree
Hide file tree
Showing 44 changed files with 333 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
6 changes: 6 additions & 0 deletions .github/workflows/test-integration-v2-TestEnablingRoutes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
6 changes: 6 additions & 0 deletions .github/workflows/test-integration-v2-TestEphemeral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
6 changes: 6 additions & 0 deletions .github/workflows/test-integration-v2-TestExpireNode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
6 changes: 6 additions & 0 deletions .github/workflows/test-integration-v2-TestHeadscale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
6 changes: 6 additions & 0 deletions .github/workflows/test-integration-v2-TestPingAllByIP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
6 changes: 6 additions & 0 deletions .github/workflows/test-integration-v2-TestTaildrop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
6 changes: 6 additions & 0 deletions .github/workflows/test-integration-v2-TestUserCommand.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ jobs:
with:
name: logs
path: "control_logs/*.log"

- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Changes

- Add environment flags to enable pprof (profiling) [#1382](https://github.com/juanfont/headscale/pull/1382)
- Profiles are continously generated in our integration tests.

## 0.22.1 (2023-04-20)

### Changes
Expand Down
1 change: 0 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ func (h *Headscale) Serve() error {

// And we're done:
cancel()
os.Exit(0)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/gh-action-integration-generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ jobs:
with:
name: logs
path: "control_logs/*.log"
- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
with:
name: pprof
path: "control_logs/*.pprof.tar"
`),
)
)
Expand Down
14 changes: 14 additions & 0 deletions cmd/headscale/headscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ import (

"github.com/efekarakus/termcolor"
"github.com/juanfont/headscale/cmd/headscale/cli"
"github.com/pkg/profile"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)

func main() {
if _, enableProfile := os.LookupEnv("HEADSCALE_PROFILING_ENABLED"); enableProfile {
if profilePath, ok := os.LookupEnv("HEADSCALE_PROFILING_PATH"); ok {
err := os.MkdirAll(profilePath, os.ModePerm)
if err != nil {
log.Fatal().Err(err).Msg("failed to create profiling directory")
}

defer profile.Start(profile.ProfilePath(profilePath)).Stop()
} else {
defer profile.Start().Stop()
}
}

var colors bool
switch l := termcolor.SupportLevel(os.Stderr); l {
case termcolor.Level16M:
Expand Down
Loading

0 comments on commit 56dd734

Please sign in to comment.