Skip to content

Commit ce6e2e0

Browse files
Merge pull request #4226 from Monokaix/release-1.10
[Cherry-pick v1.10] fix security related issues
2 parents 7b8b9b0 + 799b253 commit ce6e2e0

39 files changed

+62
-17
lines changed

.github/workflows/e2e_spark.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
k8s-integration-tests:
1212
name: "E2E about Spark Integration test"
13-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-24.04
1414
steps:
1515

1616
- name: Checkout current Volcano repository

.github/workflows/licenses_lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
licenses-lint:
1212
name: Licenses Lint
1313
timeout-minutes: 40
14-
runs-on: ubuntu-22.04
14+
runs-on: ubuntu-24.04
1515
steps:
1616
- name: Install Go
1717
uses: actions/setup-go@v4

cmd/scheduler/app/options/options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type ServerOption struct {
6767
DefaultQueue string
6868
PrintVersion bool
6969
EnableMetrics bool
70+
EnablePprof bool
7071
ListenAddress string
7172
EnablePriorityClass bool
7273
EnableCSIStorage bool
@@ -141,6 +142,7 @@ func (s *ServerOption) AddFlags(fs *pflag.FlagSet) {
141142
"Enable tracking of available storage capacity that CSI drivers provide; it is false by default")
142143
fs.BoolVar(&s.EnableHealthz, "enable-healthz", false, "Enable the health check; it is false by default")
143144
fs.BoolVar(&s.EnableMetrics, "enable-metrics", false, "Enable the metrics function; it is false by default")
145+
fs.BoolVar(&s.EnablePprof, "enable-pprof", false, "Enable the pprof endpoint; it is false by default")
144146
fs.StringSliceVar(&s.NodeSelector, "node-selector", nil, "volcano only work with the labeled node, like: --node-selector=volcano.sh/role:train --node-selector=volcano.sh/role:serving")
145147
fs.BoolVar(&s.EnableCacheDumper, "cache-dumper", true, "Enable the cache dumper, it's true by default")
146148
fs.StringVar(&s.CacheDumpFileDir, "cache-dump-dir", "/tmp", "The target dir where the json file put at when dump cache info to json file")

cmd/scheduler/app/server.go

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020
"context"
2121
"fmt"
2222
"net/http"
23+
"net/http/pprof"
2324
"os"
2425

2526
"volcano.sh/apis/pkg/apis/helpers"
26-
2727
"volcano.sh/volcano/cmd/scheduler/app/options"
2828
"volcano.sh/volcano/pkg/kube"
2929
"volcano.sh/volcano/pkg/scheduler"
@@ -73,11 +73,8 @@ func Run(opt *options.ServerOption) error {
7373
panic(err)
7474
}
7575

76-
if opt.EnableMetrics {
77-
go func() {
78-
http.Handle("/metrics", promHandler())
79-
klog.Fatalf("Prometheus Http Server failed %s", http.ListenAndServe(opt.ListenAddress, nil))
80-
}()
76+
if opt.EnableMetrics || opt.EnablePprof {
77+
go startMetricsServer(opt)
8178
}
8279

8380
if opt.EnableHealthz {
@@ -151,3 +148,31 @@ func promHandler() http.Handler {
151148
prometheus.DefaultRegisterer.Unregister(collectors.NewGoCollector())
152149
return promhttp.InstrumentMetricHandler(prometheus.DefaultRegisterer, promhttp.HandlerFor(prometheus.Gatherers{prometheus.DefaultGatherer, legacyregistry.DefaultGatherer}, promhttp.HandlerOpts{}))
153150
}
151+
152+
func startMetricsServer(opt *options.ServerOption) {
153+
mux := http.NewServeMux()
154+
155+
if opt.EnableMetrics {
156+
mux.Handle("/metrics", promHandler())
157+
}
158+
159+
if opt.EnablePprof {
160+
mux.HandleFunc("/debug/pprof/", pprof.Index)
161+
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
162+
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
163+
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
164+
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
165+
}
166+
167+
server := &http.Server{
168+
Addr: opt.ListenAddress,
169+
Handler: mux,
170+
ReadHeaderTimeout: helpers.DefaultReadHeaderTimeout,
171+
ReadTimeout: helpers.DefaultReadTimeout,
172+
WriteTimeout: helpers.DefaultWriteTimeout,
173+
}
174+
175+
if err := server.ListenAndServe(); err != nil {
176+
klog.Errorf("start metrics/pprof http server failed: %v", err)
177+
}
178+
}

cmd/scheduler/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ import (
2929
componentbaseoptions "k8s.io/component-base/config/options"
3030
"k8s.io/klog/v2"
3131

32-
// init pprof server
33-
_ "net/http/pprof"
34-
3532
"volcano.sh/volcano/cmd/scheduler/app"
3633
"volcano.sh/volcano/cmd/scheduler/app/options"
3734
commonutil "volcano.sh/volcano/pkg/util"

cmd/webhook-manager/app/server.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ func Run(config *options.Config) error {
9696
signal.Notify(stopChannel, syscall.SIGTERM, syscall.SIGINT)
9797

9898
server := &http.Server{
99-
Addr: config.ListenAddress + ":" + strconv.Itoa(config.Port),
100-
TLSConfig: configTLS(config, restConfig),
99+
Addr: config.ListenAddress + ":" + strconv.Itoa(config.Port),
100+
TLSConfig: configTLS(config, restConfig),
101+
ReadHeaderTimeout: helpers.DefaultReadHeaderTimeout,
102+
ReadTimeout: helpers.DefaultReadTimeout,
103+
WriteTimeout: helpers.DefaultWriteTimeout,
101104
}
102105
go func() {
103106
err = server.ListenAndServeTLS("", "")

docs/design/jobflow/README.md

100755100644
File mode changed.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ require (
4040
sigs.k8s.io/controller-runtime v0.13.0
4141
sigs.k8s.io/yaml v1.3.0
4242
stathat.com/c/consistent v1.0.0
43-
volcano.sh/apis v1.10.1
43+
volcano.sh/apis v1.10.2
4444
)
4545

4646
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,5 +406,5 @@ sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
406406
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
407407
stathat.com/c/consistent v1.0.0 h1:ezyc51EGcRPJUxfHGSgJjWzJdj3NiMU9pNfLNGiXV0c=
408408
stathat.com/c/consistent v1.0.0/go.mod h1:QkzMWzcbB+yQBL2AttO6sgsQS/JSTapcDISJalmCDS0=
409-
volcano.sh/apis v1.10.1 h1:Xq5CrrePLRU1d21gJXLNcGy2dUjgI5nc1EuIiqoK5C8=
410-
volcano.sh/apis v1.10.1/go.mod h1:z8hhFZ2qcUMR1JIjVYmBqL98CVaXNzsQAcqKiytQW9s=
409+
volcano.sh/apis v1.10.2 h1:EfN1vB8AISgD/NKTCQPIPrfRUaaclS5oMuE327x8ZMs=
410+
volcano.sh/apis v1.10.2/go.mod h1:z8hhFZ2qcUMR1JIjVYmBqL98CVaXNzsQAcqKiytQW9s=

installer/helm/chart/volcano/templates/scheduler.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ spec:
179179
- --scheduler-conf=/volcano.scheduler/{{base .Values.basic.scheduler_config_file}}
180180
- --enable-healthz=true
181181
- --enable-metrics=true
182+
{{- if .Values.custom.scheduler_pprof_enable }}
183+
- --enable-pprof=true
184+
{{- end }}
182185
- --leader-elect={{ .Values.custom.leader_elect_enable }}
183186
{{- if .Values.custom.leader_elect_enable }}
184187
- --leader-elect-resource-namespace={{ .Release.Namespace }}

0 commit comments

Comments
 (0)