Skip to content

Commit 92771e9

Browse files
committed
deps: upgrade Cilium from v1.18.0-pre.1 to v1.19.3
Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
1 parent e30cfb3 commit 92771e9

File tree

78 files changed

+2244
-1968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2244
-1968
lines changed

.github/workflows/golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
with:
3636
go-version-file: go.mod
3737
- name: Build golangci-lint
38-
run: GOOS=linux GOARCH=amd64 go build -o "$RUNNER_TEMP/golangci-lint" github.com/golangci/golangci-lint/cmd/golangci-lint
38+
run: GOOS=linux GOARCH=amd64 go build -o "$RUNNER_TEMP/golangci-lint" github.com/golangci/golangci-lint/v2/cmd/golangci-lint
3939
- name: golangci-lint
4040
run: |
4141
"$RUNNER_TEMP/golangci-lint" run --new-from-rev=${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.event.before || 'HEAD~1' }} --concurrency 4 --verbose --config=.golangci.yaml --timeout=25m

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ help: ## Display this help
9595
##@ Tools
9696

9797
GOFUMPT = go tool mvdan.cc/gofumpt
98-
GOLANGCI_LINT = go tool github.com/golangci/golangci-lint/cmd/golangci-lint
98+
GOLANGCI_LINT = go tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
9999
GORELEASER = go tool github.com/goreleaser/goreleaser
100100
CONTROLLER_GEN = go tool sigs.k8s.io/controller-tools/cmd/controller-gen
101101
GINKGO = go tool github.com/onsi/ginkgo

cmd/hubble/cells_linux.go

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@
55
package hubble
66

77
import (
8+
"log/slog"
9+
"sync"
10+
11+
"github.com/cilium/cilium/pkg/datapath/link"
812
"github.com/cilium/cilium/pkg/defaults"
913
"github.com/cilium/cilium/pkg/gops"
1014
hubblecell "github.com/cilium/cilium/pkg/hubble/cell"
11-
exportercell "github.com/cilium/cilium/pkg/hubble/exporter/cell"
15+
metricscell "github.com/cilium/cilium/pkg/hubble/metrics/cell"
16+
ciliumparser "github.com/cilium/cilium/pkg/hubble/parser"
1217
k8sClient "github.com/cilium/cilium/pkg/k8s/client"
13-
"github.com/cilium/cilium/pkg/logging"
18+
"github.com/cilium/cilium/pkg/kpr"
19+
"github.com/cilium/cilium/pkg/kvstore"
1420
"github.com/cilium/cilium/pkg/logging/logfields"
1521
"github.com/cilium/cilium/pkg/node/manager"
1622
"github.com/cilium/cilium/pkg/option"
1723
"github.com/cilium/cilium/pkg/pprof"
18-
"github.com/cilium/cilium/pkg/recorder"
1924
"github.com/cilium/hive/cell"
25+
"github.com/cilium/statedb"
2026
"k8s.io/client-go/rest"
2127

2228
"github.com/microsoft/retina/internal/buildinfo"
@@ -25,21 +31,50 @@ import (
2531
"github.com/microsoft/retina/pkg/hubble/parser"
2632
"github.com/microsoft/retina/pkg/hubble/resources"
2733
retinak8s "github.com/microsoft/retina/pkg/k8s"
34+
retinalog "github.com/microsoft/retina/pkg/log"
2835
"github.com/microsoft/retina/pkg/managers/pluginmanager"
2936
"github.com/microsoft/retina/pkg/monitoragent"
3037
"github.com/microsoft/retina/pkg/servermanager"
3138
"github.com/microsoft/retina/pkg/shared/telemetry"
3239
)
3340

41+
// disabledKVStoreClient wraps a kvstore.Client but returns IsEnabled() = false.
42+
// This is needed because K8sCiliumEndpointsWatcher only initializes if kvstore is disabled.
43+
// When kvstore is enabled, Cilium expects CiliumEndpoint data to come from kvstore,
44+
// but Retina watches CiliumEndpoint CRDs directly and needs the watcher to populate IPCache.
45+
type disabledKVStoreClient struct {
46+
kvstore.Client
47+
}
48+
49+
// IsEnabled returns false to indicate kvstore is not being used for CiliumEndpoint sync.
50+
// This allows the K8sCiliumEndpointsWatcher to initialize and populate IPCache with K8sMetadata.
51+
func (d *disabledKVStoreClient) IsEnabled() bool {
52+
return false
53+
}
54+
55+
const daemonSubsys = "daemon"
56+
57+
var (
58+
loggerOnce sync.Once
59+
cachedLogger *slog.Logger
60+
)
61+
62+
// logger returns a zap-backed slog logger. Resolved lazily so it reaches
63+
// Application Insights once SetupZapLogger has run.
64+
func logger() *slog.Logger {
65+
loggerOnce.Do(func() {
66+
cachedLogger = retinalog.SlogLogger().With(logfields.LogSubsys, daemonSubsys)
67+
})
68+
return cachedLogger
69+
}
70+
3471
var (
3572
Agent = cell.Module(
3673
"agent",
3774
"Retina-Agent",
3875
Infrastructure,
3976
ControlPlane,
4077
)
41-
daemonSubsys = "daemon"
42-
logger = logging.DefaultLogger.WithField(logfields.LogSubsys, daemonSubsys)
4378

4479
Infrastructure = cell.Module(
4580
"infrastructure",
@@ -61,6 +96,19 @@ var (
6196
// Kubernetes client
6297
k8sClient.Cell,
6398

99+
// Kube proxy replacement config (needed by loadbalancer cells)
100+
kpr.Cell,
101+
102+
// Provide a disabled kvstore client for Retina.
103+
// This is important: the K8sCiliumEndpointsWatcher only initializes
104+
// if kvstore.IsEnabled() returns false (because with a real kvstore,
105+
// CiliumEndpoint data would come from kvstore instead of watching CRDs).
106+
// Since Retina doesn't use etcd/consul and relies on watching CiliumEndpoint CRDs,
107+
// we need IsEnabled() to return false so the watcher populates IPCache with K8sMetadata.
108+
cell.Provide(func(db *statedb.DB) kvstore.Client {
109+
return &disabledKVStoreClient{Client: kvstore.NewInMemoryClient(db, "default")}
110+
}),
111+
64112
cell.Provide(func(cfg config.Config, k8sCfg *rest.Config) telemetry.Config {
65113
return telemetry.Config{
66114
Component: "retina-agent",
@@ -92,11 +140,11 @@ var (
92140

93141
retinak8s.Cell,
94142

95-
recorder.Cell,
96-
97143
// Provides resources for hubble
98144
resources.Cell,
99-
cell.Provide(parser.New),
145+
146+
// Provides link cache needed by hubble parser
147+
link.Cell,
100148

101149
// Provides the node reconciler as node manager
102150
rnode.Cell,
@@ -106,9 +154,17 @@ var (
106154
},
107155
),
108156

109-
exportercell.Cell,
110-
// Provides the hubble agent
111-
hubblecell.Core,
157+
// Provides the full hubble agent (includes parser, exporter, metrics, and TLS)
158+
hubblecell.Cell,
159+
160+
// Force the Hubble metrics server to start. Without this, the DI system
161+
// prunes newMetricsServer because nothing in Retina consumes metricscell.Server.
162+
cell.Invoke(func(_ metricscell.Server) {}),
163+
164+
// Override Cilium's parser with Retina's parser that understands v1.Event from plugins
165+
cell.DecorateAll(func(_ ciliumparser.Decoder, params parser.Params) ciliumparser.Decoder {
166+
return parser.New(params)
167+
}),
112168

113169
telemetry.Heartbeat,
114170
)

cmd/hubble/daemon_linux.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ package hubble
77
import (
88
"context"
99
"fmt"
10+
"log/slog"
1011

1112
"github.com/pkg/errors"
12-
"github.com/sirupsen/logrus"
1313

1414
"github.com/microsoft/retina/pkg/config"
15+
"github.com/microsoft/retina/pkg/log"
1516
"github.com/microsoft/retina/pkg/managers/pluginmanager"
1617
"github.com/microsoft/retina/pkg/managers/servermanager"
1718

@@ -20,7 +21,6 @@ import (
2021
v1 "github.com/cilium/cilium/pkg/hubble/api/v1"
2122
hubblecell "github.com/cilium/cilium/pkg/hubble/cell"
2223
"github.com/cilium/cilium/pkg/ipcache"
23-
"github.com/cilium/cilium/pkg/k8s"
2424
k8sClient "github.com/cilium/cilium/pkg/k8s/client"
2525
"github.com/cilium/cilium/pkg/k8s/watchers"
2626
monitoragent "github.com/cilium/cilium/pkg/monitor/agent"
@@ -34,7 +34,6 @@ import (
3434
ctrl "sigs.k8s.io/controller-runtime"
3535
"sigs.k8s.io/controller-runtime/pkg/client"
3636
logf "sigs.k8s.io/controller-runtime/pkg/log"
37-
zapf "sigs.k8s.io/controller-runtime/pkg/log/zap"
3837
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3938
)
4039

@@ -44,7 +43,9 @@ var (
4443
"daemon",
4544
"Retina-Agent Daemon",
4645
// Create the controller manager, provides the hive with the controller manager and its client
47-
cell.Provide(func(k8sCfg *rest.Config, logger logrus.FieldLogger, rcfg config.RetinaHubbleConfig) (ctrl.Manager, client.Client, error) {
46+
cell.Provide(func(
47+
k8sCfg *rest.Config, logger *slog.Logger, rcfg config.RetinaHubbleConfig,
48+
) (ctrl.Manager, client.Client, error) {
4849
if err := corev1.AddToScheme(scheme); err != nil { //nolint:govet // intentional shadow
4950
logger.Error("failed to add corev1 to scheme")
5051
return nil, nil, errors.Wrap(err, "failed to add corev1 to scheme")
@@ -60,7 +61,7 @@ var (
6061
LeaderElectionID: "ecaf1259.retina.io",
6162
}
6263

63-
logf.SetLogger(zapf.New())
64+
logf.SetLogger(log.LogrLogger())
6465
ctrlManager, err := ctrl.NewManager(k8sCfg, mgrOption)
6566
if err != nil {
6667
logger.Error("failed to create manager")
@@ -71,7 +72,7 @@ var (
7172
}),
7273

7374
// Start the controller manager
74-
cell.Invoke(func(l logrus.FieldLogger, lifecycle cell.Lifecycle, ctrlManager ctrl.Manager) {
75+
cell.Invoke(func(l *slog.Logger, lifecycle cell.Lifecycle, ctrlManager ctrl.Manager) {
7576
var wp *workerpool.WorkerPool
7677
lifecycle.Append(
7778
cell.Hook{
@@ -99,7 +100,7 @@ var (
99100
type Daemon struct {
100101
clientset k8sClient.Clientset
101102

102-
log logrus.FieldLogger
103+
log *slog.Logger
103104
monitorAgent monitoragent.Agent
104105
pluginManager *pluginmanager.PluginManager
105106
HTTPServer *servermanager.HTTPServer
@@ -108,7 +109,6 @@ type Daemon struct {
108109
k8swatcher *watchers.K8sWatcher
109110
localNodeStore *node.LocalNodeStore
110111
ipc *ipcache.IPCache
111-
svcCache k8s.ServiceCache
112112
hubble hubblecell.HubbleIntegration
113113
}
114114

@@ -124,17 +124,12 @@ func newDaemon(params *daemonParams) *Daemon {
124124
k8swatcher: params.K8sWatcher,
125125
localNodeStore: params.Lnds,
126126
ipc: params.IPC,
127-
svcCache: params.SvcCache,
128127
hubble: params.Hubble,
129128
}
130129
}
131130

132131
func (d *Daemon) Run(ctx context.Context) error {
133-
// Start K8s watcher
134-
d.log.WithField("localNodeStore", d.localNodeStore).Info("Starting local node store")
135-
136-
// Start K8s watcher. Will block till sync is complete or timeout.
137-
// If sync doesn't complete within timeout (3 minutes), causes fatal error.
132+
// Start K8s watcher. Blocks until sync completes or times out (3 min).
138133
retinak8s.Start(ctx, d.k8swatcher)
139134

140135
go d.generateEvents(ctx)
@@ -147,10 +142,8 @@ func (d *Daemon) generateEvents(ctx context.Context) {
147142
case <-ctx.Done():
148143
return
149144
case event := <-d.eventChan:
150-
d.log.WithField("event", event).Debug("Sending event to monitor agent")
151-
err := d.monitorAgent.SendEvent(0, event)
152-
if err != nil {
153-
d.log.WithError(err).Error("Unable to send event to monitor agent")
145+
if err := d.monitorAgent.SendEvent(0, event); err != nil {
146+
d.log.Error("Unable to send event to monitor agent", "error", err)
154147
}
155148
}
156149
}

0 commit comments

Comments
 (0)