Skip to content

Commit d62889c

Browse files
authored
Support v2alpha1 and v1 Otterize CRD version; Report istio destination services (in addition to dst workload); Report workload kinds in order to support kind specification for clientIntents (#221)
1 parent 1348643 commit d62889c

File tree

18 files changed

+374
-208
lines changed

18 files changed

+374
-208
lines changed

helm-charts

Submodule helm-charts updated 66 files

src/go.mod

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/istio-watcher/pkg/watcher/helpers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func ToGraphQLIstioConnections(connections map[ConnectionWithPath]time.Time) []m
4242
SrcWorkloadNamespace: connWithPath.SourceNamespace,
4343
DstWorkload: connWithPath.DestinationWorkload,
4444
DstWorkloadNamespace: connWithPath.DestinationNamespace,
45+
DstServiceName: connWithPath.DestinationServiceName,
4546
Path: connWithPath.RequestPath,
4647
LastSeen: timestamp,
4748
}

src/istio-watcher/pkg/watcher/watcher.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,21 @@ var (
5353
"source_workload",
5454
"source_workload_namespace",
5555
"destination_workload",
56+
"destination_service_name",
5657
"destination_workload_namespace",
5758
"request_method",
5859
"request_path",
5960
}
6061
)
6162

6263
type ConnectionWithPath struct {
63-
SourceWorkload string `json:"source_workload"`
64-
SourceNamespace string `json:"source_workload_namespace"`
65-
DestinationWorkload string `json:"destination_workload"`
66-
DestinationNamespace string `json:"destination_workload_namespace"`
67-
RequestPath string `json:"request_path"`
68-
RequestMethod string `json:"request_method"`
64+
SourceWorkload string `json:"source_workload"`
65+
SourceNamespace string `json:"source_workload_namespace"`
66+
DestinationWorkload string `json:"destination_workload"`
67+
DestinationServiceName string `json:"destination_service_name"`
68+
DestinationNamespace string `json:"destination_workload_namespace"`
69+
RequestPath string `json:"request_path"`
70+
RequestMethod string `json:"request_method"`
6971
}
7072

7173
type IstioWatcher struct {
@@ -311,6 +313,8 @@ func extractRegexGroups(inputString string, groupNames []string) (*ConnectionWit
311313
connection.RequestPath = groupValue
312314
case "request_method":
313315
connection.RequestMethod = groupValue
316+
case "destination_service_name":
317+
connection.DestinationServiceName = groupValue
314318
default:
315319
return nil, errors.Errorf("unknown group name: %s", groupName)
316320
}

src/kafka-watcher/cmd/main.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ package main
22

33
import (
44
"context"
5-
"github.com/otterize/intents-operator/src/shared"
6-
"github.com/otterize/intents-operator/src/shared/errors"
7-
"github.com/otterize/intents-operator/src/shared/telemetries/componentinfo"
8-
"github.com/otterize/network-mapper/src/shared/componentutils"
9-
105
"fmt"
116
"github.com/bombsimon/logrusr/v3"
127
"github.com/labstack/echo-contrib/echoprometheus"
138
"github.com/labstack/echo/v4"
9+
"github.com/otterize/intents-operator/src/shared"
10+
"github.com/otterize/intents-operator/src/shared/clusterutils"
11+
"github.com/otterize/intents-operator/src/shared/errors"
12+
"github.com/otterize/intents-operator/src/shared/telemetries/componentinfo"
1413
"github.com/otterize/intents-operator/src/shared/telemetries/errorreporter"
14+
"github.com/otterize/intents-operator/src/shared/telemetries/telemetrysender"
1515
"github.com/otterize/network-mapper/src/kafka-watcher/pkg/config"
1616
logwatcher2 "github.com/otterize/network-mapper/src/kafka-watcher/pkg/logwatcher"
1717
"github.com/otterize/network-mapper/src/kafka-watcher/pkg/mapperclient"
@@ -36,19 +36,22 @@ func main() {
3636
logrus.SetFormatter(&logrus.JSONFormatter{
3737
TimestampFormat: time.RFC3339,
3838
})
39-
errorreporter.Init("kafka-watcher", version.Version(), viper.GetString(sharedconfig.TelemetryErrorsAPIKeyKey))
39+
errgrp, errGroupCtx := errgroup.WithContext(signals.SetupSignalHandler())
40+
clusterUID, err := clusterutils.GetOrCreateClusterUID(errGroupCtx)
41+
if err != nil {
42+
logrus.WithError(err).Panic("Failed fetching cluster UID")
43+
}
44+
componentinfo.SetGlobalContextId(telemetrysender.Anonymize(clusterUID))
45+
errorreporter.Init("kafka-watcher", version.Version())
4046
defer errorreporter.AutoNotify()
4147
shared.RegisterPanicHandlers()
4248

4349
ctrl.SetLogger(logrusr.New(logrus.StandardLogger()))
44-
componentutils.SetCloudClientId()
45-
componentinfo.SetGlobalComponentInstanceId()
4650

4751
mapperClient := mapperclient.NewMapperClient(viper.GetString(sharedconfig.MapperApiUrlKey))
4852

4953
mode := viper.GetString(config.KafkaLogReadModeKey)
5054

51-
var err error
5255
var watcher logwatcher2.Watcher
5356

5457
switch mode {
@@ -103,7 +106,6 @@ func main() {
103106
metricsServer.HideBanner = true
104107

105108
metricsServer.GET("/metrics", echoprometheus.NewHandler())
106-
errgrp, errGroupCtx := errgroup.WithContext(signals.SetupSignalHandler())
107109
errgrp.Go(func() error {
108110
defer errorreporter.AutoNotify()
109111
return metricsServer.Start(fmt.Sprintf(":%d", viper.GetInt(sharedconfig.PrometheusMetricsPortKey)))

src/mapper/cmd/main.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"github.com/bombsimon/logrusr/v3"
77
"github.com/labstack/echo-contrib/echoprometheus"
8+
otterizev2alpha1 "github.com/otterize/intents-operator/src/operator/api/v2alpha1"
89
mutatingwebhookconfiguration "github.com/otterize/intents-operator/src/operator/controllers/mutating_webhook_controller"
910
"github.com/otterize/intents-operator/src/shared"
1011
"github.com/otterize/intents-operator/src/shared/clusterutils"
@@ -35,6 +36,7 @@ import (
3536

3637
"github.com/labstack/echo/v4"
3738
"github.com/labstack/echo/v4/middleware"
39+
otterizev1 "github.com/otterize/intents-operator/src/operator/api/v1"
3840
otterizev1alpha2 "github.com/otterize/intents-operator/src/operator/api/v1alpha2"
3941
otterizev1alpha3 "github.com/otterize/intents-operator/src/operator/api/v1alpha3"
4042
"github.com/otterize/intents-operator/src/shared/serviceidresolver"
@@ -67,6 +69,8 @@ func init() {
6769
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
6870
utilruntime.Must(otterizev1alpha2.AddToScheme(scheme))
6971
utilruntime.Must(otterizev1alpha3.AddToScheme(scheme))
72+
utilruntime.Must(otterizev1.AddToScheme(scheme))
73+
utilruntime.Must(otterizev2alpha1.AddToScheme(scheme))
7074
}
7175

7276
func getClusterDomainOrDefault() string {
@@ -88,7 +92,16 @@ func main() {
8892
logrus.SetFormatter(&logrus.JSONFormatter{
8993
TimestampFormat: time.RFC3339,
9094
})
91-
errorreporter.Init("network-mapper", version.Version(), viper.GetString(sharedconfig.TelemetryErrorsAPIKeyKey))
95+
signalHandlerCtx := ctrl.SetupSignalHandler()
96+
97+
clusterUID, err := clusterutils.GetOrCreateClusterUID(signalHandlerCtx)
98+
if err != nil {
99+
logrus.WithError(err).Panic("Failed fetching cluster UID")
100+
}
101+
102+
componentinfo.SetGlobalContextId(telemetrysender.Anonymize(clusterUID))
103+
104+
errorreporter.Init("network-mapper", version.Version())
92105
defer errorreporter.AutoNotify()
93106
shared.RegisterPanicHandlers()
94107

@@ -111,7 +124,6 @@ func main() {
111124
if err != nil {
112125
logrus.Panicf("unable to set up overall controller manager: %s", err)
113126
}
114-
signalHandlerCtx := ctrl.SetupSignalHandler()
115127

116128
errgrp, errGroupCtx := errgroup.WithContext(signalHandlerCtx)
117129

@@ -143,13 +155,6 @@ func main() {
143155
return nil
144156
})
145157

146-
clusterUID, err := clusterutils.GetOrCreateClusterUID(signalHandlerCtx)
147-
if err != nil {
148-
logrus.WithError(err).Panic("Failed fetching cluster UID")
149-
}
150-
151-
componentinfo.SetGlobalContextId(telemetrysender.Anonymize(clusterUID))
152-
153158
// start API server
154159
mapperServer.GET("/healthz", func(c echo.Context) error {
155160
return c.NoContent(http.StatusOK)
@@ -302,7 +307,6 @@ func main() {
302307
return nil
303308
})
304309

305-
componentinfo.SetGlobalVersion(version.Version())
306310
telemetrysender.SendNetworkMapper(telemetriesgql.EventTypeStarted, 1)
307311
telemetrysender.NetworkMapperRunActiveReporter(errGroupCtx)
308312

src/mapper/pkg/cloudclient/generated.go

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)