11From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2233Date: Wed, 9 Jun 2021 16:32:33 +0800
4- Subject: [PATCH] run operator
4+ Subject: run operator
55
66Signed-off-by: l1b0k <
[email protected] >
77---
8- daemon/cmd/daemon_main.go | 25 +++--
9- operator/Makefile | 2 +-
10- operator/main.go | 225 --------------------------------------
11- 3 files changed, 19 insertions(+), 233 deletions(-)
8+ operator/Makefile | 2 +-
9+ operator/main.go | 243 ++--------------------------------------------
10+ 2 files changed, 11 insertions(+), 234 deletions(-)
1211
13- diff --git a/daemon/cmd/daemon_main.go b/daemon/cmd/daemon_main.go
14- index 28bf66a7a9..1f2796810b 100644
15- --- a/daemon/cmd/daemon_main.go
16- +++ b/daemon/cmd/daemon_main.go
17- @@ -14,13 +14,6 @@ import (
18- "strings"
19- "time"
20-
21- - "github.com/go-openapi/loads"
22- - gops "github.com/google/gops/agent"
23- - "github.com/sirupsen/logrus"
24- - "github.com/spf13/cobra"
25- - "github.com/spf13/viper"
26- - "google.golang.org/grpc"
27- -
28- "github.com/cilium/cilium/api/v1/server"
29- "github.com/cilium/cilium/api/v1/server/restapi"
30- "github.com/cilium/cilium/pkg/aws/eni"
31- @@ -28,6 +21,7 @@ import (
32- "github.com/cilium/cilium/pkg/bgpv1/gobgp"
33- "github.com/cilium/cilium/pkg/bpf"
34- "github.com/cilium/cilium/pkg/cgroups"
35- + "github.com/cilium/cilium/pkg/command/exec"
36- "github.com/cilium/cilium/pkg/common"
37- "github.com/cilium/cilium/pkg/components"
38- "github.com/cilium/cilium/pkg/controller"
39- @@ -75,6 +69,12 @@ import (
40- "github.com/cilium/cilium/pkg/version"
41- wireguard "github.com/cilium/cilium/pkg/wireguard/agent"
42- wireguardTypes "github.com/cilium/cilium/pkg/wireguard/types"
43- + "github.com/go-openapi/loads"
44- + gops "github.com/google/gops/agent"
45- + "github.com/sirupsen/logrus"
46- + "github.com/spf13/cobra"
47- + "github.com/spf13/viper"
48- + "google.golang.org/grpc"
49- )
50-
51- const (
52- @@ -1624,6 +1624,17 @@ func (d *Daemon) initKVStore() {
53- }
54-
55- func runDaemon() {
56- + go func() {
57- + if os.Getenv("DISABLE_CILIUM_OPERATOR") == "true" {
58- + return
59- + }
60- + cmd := exec.CommandContext(server.ServerCtx, "cilium-operator-generic", "--skip-crd-creation", "--k8s-namespace", os.Getenv("CILIUM_K8S_NAMESPACE"), "--identity-gc-interval", "10m", "--identity-heartbeat-timeout", "20m")
61- + cmd.Stdout = os.Stdout
62- + cmd.Stderr = os.Stderr
63- + err := cmd.Run()
64- + log.Fatal(fmt.Errorf("cilium-operator exited, %w", err))
65- + }()
66- +
67- datapathConfig := linuxdatapath.DatapathConfiguration{
68- HostDevice: defaults.HostDevice,
69- ProcFs: option.Config.ProcFs,
7012diff --git a/operator/Makefile b/operator/Makefile
7113index ebd1285e3d..1710880c84 100644
7214--- a/operator/Makefile
@@ -81,7 +23,7 @@ index ebd1285e3d..1710880c84 100644
8123 cilium-operator-aws: GO_TAGS_FLAGS+=ipam_provider_aws
8224 cilium-operator-azure: GO_TAGS_FLAGS+=ipam_provider_azure
8325diff --git a/operator/main.go b/operator/main.go
84- index 756b218121..ec71d565dc 100644
26+ index 756b218121..ec0a329109 100644
8527--- a/operator/main.go
8628+++ b/operator/main.go
8729@@ -15,30 +15,22 @@ import (
@@ -123,7 +65,33 @@ index 756b218121..ec71d565dc 100644
12365 "github.com/cilium/cilium/pkg/rand"
12466 "github.com/cilium/cilium/pkg/rate"
12567 "github.com/cilium/cilium/pkg/version"
126- @@ -250,14 +241,6 @@ func runOperator() {
68+ @@ -72,15 +63,17 @@ var (
69+ }
70+
71+ // Open socket for using gops to get stacktraces of the agent.
72+ - addr := fmt.Sprintf("127.0.0.1:%d", viper.GetInt(option.GopsPort))
73+ - addrField := logrus.Fields{"address": addr}
74+ - if err := gops.Listen(gops.Options{
75+ - Addr: addr,
76+ - ReuseSocketAddrAndPort: true,
77+ - }); err != nil {
78+ - log.WithError(err).WithFields(addrField).Fatal("Cannot start gops server")
79+ + if viper.GetInt(option.GopsPort) > 0 {
80+ + addr := fmt.Sprintf("127.0.0.1:%d", viper.GetInt(option.GopsPort))
81+ + addrField := logrus.Fields{"address": addr}
82+ + if err := gops.Listen(gops.Options{
83+ + Addr: addr,
84+ + ReuseSocketAddrAndPort: true,
85+ + }); err != nil {
86+ + log.WithError(err).WithFields(addrField).Fatal("Cannot start gops server")
87+ + }
88+ + log.WithFields(addrField).Info("Started gops server")
89+ }
90+ - log.WithFields(addrField).Info("Started gops server")
91+
92+ initEnv()
93+ runOperator()
94+ @@ -250,14 +243,6 @@ func runOperator() {
12795 }
12896 }()
12997
@@ -138,7 +106,7 @@ index 756b218121..ec71d565dc 100644
138106 initK8s(k8sInitDone)
139107
140108 capabilities := k8sversion.Capabilities()
141- @@ -367,189 +350 ,6 @@ func onOperatorStartLeading(ctx context.Context) {
109+ @@ -367,189 +352 ,6 @@ func onOperatorStartLeading(ctx context.Context) {
142110 go cesController.Run(operatorWatchers.CiliumEndpointStore, stopCh)
143111 }
144112
@@ -328,7 +296,7 @@ index 756b218121..ec71d565dc 100644
328296 if operatorOption.Config.IdentityGCInterval != 0 {
329297 identityRateLimiter = rate.NewLimiter(
330298 operatorOption.Config.IdentityGCRateInterval,
331- @@ -583,31 +383 ,6 @@ func onOperatorStartLeading(ctx context.Context) {
299+ @@ -583,31 +385 ,6 @@ func onOperatorStartLeading(ctx context.Context) {
332300 enableCiliumEndpointSyncGC(true)
333301 }
334302
@@ -361,5 +329,5 @@ index 756b218121..ec71d565dc 100644
361329
362330 <-shutdownSignal
363331- -
364- 2.39.1
332+ 2.39.5 (Apple Git-154)
365333
0 commit comments