Skip to content

Commit 7c77714

Browse files
authored
Merge pull request #1560 from imuxin/fix-iss/1559
add periodic-report cmd arg
2 parents b5f50cb + 3018401 commit 7c77714

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

daemon/options/bpf.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ import (
2626
)
2727

2828
type BpfConfig struct {
29-
Mode string
30-
BpfFsPath string
31-
Cgroup2Path string
32-
EnableMda bool
33-
EnableMonitoring bool
34-
EnableProfiling bool
35-
EnableIPsec bool
29+
Mode string
30+
BpfFsPath string
31+
Cgroup2Path string
32+
EnableMda bool
33+
EnableMonitoring bool
34+
EnablePeriodicReport bool
35+
EnableProfiling bool
36+
EnableIPsec bool
3637
}
3738

3839
func (c *BpfConfig) AttachFlags(cmd *cobra.Command) {
@@ -41,6 +42,7 @@ func (c *BpfConfig) AttachFlags(cmd *cobra.Command) {
4142
cmd.PersistentFlags().StringVar(&c.Mode, "mode", "dual-engine", "controller plane mode, valid values are [kernel-native, dual-engine]")
4243
cmd.PersistentFlags().BoolVar(&c.EnableMda, "enable-mda", false, "enable mda")
4344
cmd.PersistentFlags().BoolVar(&c.EnableMonitoring, "monitoring", true, "enable kmesh traffic monitoring in daemon process")
45+
cmd.PersistentFlags().BoolVar(&c.EnablePeriodicReport, "periodic-report", false, "enable kmesh periodic report in daemon process")
4446
cmd.PersistentFlags().BoolVar(&c.EnableProfiling, "profiling", false, "whether to enable profiling or not, default to false")
4547
cmd.PersistentFlags().BoolVar(&c.EnableIPsec, "enable-ipsec", false, "enable ipsec encryption and authentication between nodes")
4648
}

pkg/controller/controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ func (c *Controller) Start(stopCh <-chan struct{}) error {
158158
return fmt.Errorf("failed to update config in order to start metric: %v", err)
159159
}
160160
}
161+
// kmeshConfigMap.PeriodicReport initialized to uint32(0).
162+
// If the startup parameter is true, update the kmeshConfigMap.
163+
if c.bpfConfig.EnablePeriodicReport && c.bpfConfig.EnableMonitoring {
164+
if err := c.loader.UpdateEnablePeriodicReport(constants.ENABLED); err != nil {
165+
return fmt.Errorf("failed to update config in order to start periodic report: %v", err)
166+
}
167+
}
161168

162169
c.client, err = NewXdsClient(c.mode, c.bpfAdsObj, c.bpfWorkloadObj, c.bpfConfig.EnableMonitoring, c.bpfConfig.EnableProfiling)
163170
if err != nil {

pkg/status/status_server.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,7 @@ func (s *Server) monitoringHandler(w http.ResponseWriter, r *http.Request) {
262262
http.Error(w, fmt.Sprintf("update bpf monitoring failed: %v", err), http.StatusBadRequest)
263263
return
264264
}
265-
266-
enablePeriodicReport := constants.DISABLED
267-
if enabled {
268-
enablePeriodicReport = constants.ENABLED
269-
}
270-
if err := s.loader.UpdateEnablePeriodicReport(enablePeriodicReport); err != nil {
265+
if err := s.loader.UpdateEnablePeriodicReport(enableMonitoring); err != nil {
271266
http.Error(w, fmt.Sprintf("update enable periodic report failed: %v", err), http.StatusBadRequest)
272267
return
273268
}

0 commit comments

Comments
 (0)