Skip to content

Commit

Permalink
Revert "Adding get cluster id call and bumping go version on dockerfi…
Browse files Browse the repository at this point in the history
…le (#208)"

This reverts commit d15ce8f.
  • Loading branch information
orishoshan committed Apr 28, 2024
1 parent d15ce8f commit 3515f31
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build/kafka-watcher.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.22.1-alpine as buildenv
FROM --platform=$BUILDPLATFORM golang:1.21-alpine as buildenv
RUN apk add --no-cache ca-certificates git protoc
RUN apk add build-base libpcap-dev
WORKDIR /src
Expand Down
2 changes: 1 addition & 1 deletion build/mapper.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.22.1-alpine as buildenv
FROM --platform=$BUILDPLATFORM golang:1.21-alpine as buildenv
RUN apk add --no-cache ca-certificates git protoc
RUN apk add build-base libpcap-dev
WORKDIR /src
Expand Down
4 changes: 2 additions & 2 deletions build/sniffer.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 golang:1.22.1-alpine as buildenv
FROM --platform=linux/amd64 golang:1.21-alpine as buildenv
RUN apk add --no-cache ca-certificates git protoc
RUN apk add build-base libpcap-dev
WORKDIR /src
Expand All @@ -14,7 +14,7 @@ RUN go test ./sniffer/... && echo dep > /dep

# We start from the base image again, only this time it's using the target arch instead of always amd64. This is done to make the build faster.
# Unlike the mapper, it can't be amd64 throughout and use Go's cross-compilation, since the sniffer depends on libpcap (C library).
FROM golang:1.22.1-alpine as builder
FROM golang:1.21-alpine as builder
COPY --from=test /dep /dep
RUN apk add --no-cache ca-certificates git protoc
RUN apk add build-base libpcap-dev
Expand Down
2 changes: 1 addition & 1 deletion helm-charts
Submodule helm-charts updated 27 files
+2 −2 credentials-operator/Chart.yaml
+28 −0 credentials-operator/templates/configmap.yaml
+0 −44 credentials-operator/templates/credentials-operator-aws-mutating-webhook-configuration.yaml
+9 −13 credentials-operator/templates/credentials-operator-deployment.yaml
+0 −35 credentials-operator/templates/credentials-operator-manager-clusterrole.yaml
+13 −4 credentials-operator/templates/credentials-operator-mutating-webhook-configuration.yaml
+0 −29 credentials-operator/templates/extended-config-configmap.yaml
+0 −1 credentials-operator/values.yaml
+2 −2 intents-operator/Chart.yaml
+27 −18 intents-operator/README.md
+0 −87 intents-operator/crds/clientintents-customresourcedefinition.yaml
+0 −2 intents-operator/crds/kafkaserverconfigs-customresourcedefinition.yaml
+0 −79 intents-operator/crds/postgresqlserverconfigs-customresourcedefinition.yaml
+0 −2 intents-operator/crds/protectedservices-customresourcedefinition.yaml
+0 −29 intents-operator/templates/extended-config-configmap.yaml
+15 −15 intents-operator/templates/intents-operator-deployment.yaml
+0 −45 intents-operator/templates/intents-operator-manager-clusterrole.yaml
+38 −0 intents-operator/templates/intents-operator-manager-configmap.yaml
+88 −100 intents-operator/templates/otterize-validating-webhook-configuration.yaml
+0 −2 intents-operator/values.yaml
+2 −2 network-mapper/Chart.yaml
+4 −12 network-mapper/templates/mapper-deployment.yaml
+0 −1 network-mapper/templates/sniffer-daemonset.yaml
+1 −1 network-mapper/templates/visibility-dns-webhook-config.yaml
+0 −1 network-mapper/values.yaml
+1 −1 otterize-kubernetes/Chart.yaml
+11 −19 otterize-kubernetes/README.md
10 changes: 5 additions & 5 deletions src/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 21 additions & 7 deletions src/mapper/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"fmt"
"github.com/bombsimon/logrusr/v3"
"github.com/google/uuid"
"github.com/labstack/echo-contrib/echoprometheus"
mutatingwebhookconfiguration "github.com/otterize/intents-operator/src/operator/controllers/mutating_webhook_controller"
"github.com/otterize/intents-operator/src/shared/clusterutils"
"github.com/otterize/intents-operator/src/shared/errors"
"github.com/otterize/intents-operator/src/shared/filters"
"github.com/otterize/intents-operator/src/shared/telemetries/componentinfo"
Expand All @@ -21,8 +21,11 @@ import (
"github.com/otterize/network-mapper/src/mapper/pkg/pod_webhook"
"github.com/otterize/network-mapper/src/shared/echologrus"
"golang.org/x/sync/errgroup"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/metadata"
"net/http"
"os"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
Expand Down Expand Up @@ -53,6 +56,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
clientconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
)

var (
Expand Down Expand Up @@ -104,9 +108,8 @@ func main() {
if err != nil {
logrus.Panicf("unable to set up overall controller manager: %s", err)
}
signalHandlerCtx := ctrl.SetupSignalHandler()

errgrp, errGroupCtx := errgroup.WithContext(signalHandlerCtx)
errgrp, errGroupCtx := errgroup.WithContext(signals.SetupSignalHandler())

dnsCache := dnscache.NewDNSCache()
dnsPublisher, dnsPublisherEnabled, err := dnsintentspublisher.InitWithManager(errGroupCtx, mgr, dnsCache)
Expand Down Expand Up @@ -136,12 +139,23 @@ func main() {
return nil
})

clusterUID, err := clusterutils.GetOrCreateClusterUID(signalHandlerCtx)
metadataClient, err := metadata.NewForConfig(clientconfig.GetConfigOrDie())
if err != nil {
logrus.WithError(err).Panic("Failed fetching cluster UID")
logrus.WithError(err).Panic("unable to create metadata client")
}

componentinfo.SetGlobalContextId(telemetrysender.Anonymize(clusterUID))
mapping, err := mgr.GetRESTMapper().RESTMapping(schema.GroupKind{Group: "", Kind: "Namespace"}, "v1")
if err != nil {
logrus.WithError(err).Panic("unable to create Kubernetes API REST mapping")
}
kubeSystemUID := ""
kubeSystemNs, err := metadataClient.Resource(mapping.Resource).Get(context.Background(), "kube-system", metav1.GetOptions{})
if err != nil || kubeSystemNs == nil {
logrus.Warningf("failed getting kubesystem UID: %s", err)
kubeSystemUID = fmt.Sprintf("rand-%s", uuid.New().String())
} else {
kubeSystemUID = string(kubeSystemNs.UID)
}
componentinfo.SetGlobalContextId(telemetrysender.Anonymize(kubeSystemUID))

// start API server
mapperServer.GET("/healthz", func(c echo.Context) error {
Expand Down

0 comments on commit 3515f31

Please sign in to comment.