From 5567e435a8dca20e8248f18a4ecb46f96bc6027c Mon Sep 17 00:00:00 2001 From: Chwila Date: Mon, 20 May 2024 08:21:01 +0200 Subject: [PATCH 01/10] Use distinct path for Istio telemetries --- config/ui-extensions/telemetries/general | 2 +- tests/ui/support/navigation.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/ui-extensions/telemetries/general b/config/ui-extensions/telemetries/general index bd9d2962b5..e0f021baed 100644 --- a/config/ui-extensions/telemetries/general +++ b/config/ui-extensions/telemetries/general @@ -2,7 +2,7 @@ resource: kind: Telemetry group: telemetry.istio.io version: v1alpha1 -urlPath: telemetries +urlPath: istio-telemetries category: Istio name: Telemetries scope: namespace diff --git a/tests/ui/support/navigation.ts b/tests/ui/support/navigation.ts index dfa8b82d46..fc5fb166b5 100644 --- a/tests/ui/support/navigation.ts +++ b/tests/ui/support/navigation.ts @@ -37,14 +37,14 @@ Cypress.Commands.add('navigateToAuthorizationPolicies', (namespace: string): voi Cypress.Commands.add('navigateToTelemetries', (namespace: string): void => { cy.wrap(getK8sCurrentContext()).then((context) => { - cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/telemetries`) + cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/istio-telemetries`) cy.wait(2000); }); }); Cypress.Commands.add('navigateToTelemetry', (namespace: string, name: string): void => { cy.wrap(getK8sCurrentContext()).then((context) => { - cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/telemetries/${name}`) + cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/istio-telemetries/${name}`) cy.wait(2000); }); }); From 760b13e9a225891b77dc081860da012650cd492d Mon Sep 17 00:00:00 2001 From: Chwila Date: Wed, 29 May 2024 16:08:50 +0200 Subject: [PATCH 02/10] Remove deepcopy from gathering pods for restart --- pkg/lib/sidecars/pods/get.go | 16 +++++++-------- pkg/lib/sidecars/remove/remove.go | 2 +- pkg/lib/sidecars/restart/restart.go | 2 +- pkg/lib/sidecars/restart/restart_test.go | 26 ++++++++++++------------ 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/pkg/lib/sidecars/pods/get.go b/pkg/lib/sidecars/pods/get.go index a5c80f1a7c..92447322bf 100644 --- a/pkg/lib/sidecars/pods/get.go +++ b/pkg/lib/sidecars/pods/get.go @@ -51,32 +51,32 @@ func getAllRunningPods(ctx context.Context, c client.Client) (*v1.PodList, error return podList, nil } -func GetPodsToRestart(ctx context.Context, c client.Client, expectedImage SidecarImage, expectedResources v1.ResourceRequirements, predicates []filter.SidecarProxyPredicate, logger *logr.Logger) (outputPodsList v1.PodList, err error) { +func GetPodsToRestart(ctx context.Context, c client.Client, expectedImage SidecarImage, expectedResources v1.ResourceRequirements, predicates []filter.SidecarProxyPredicate, logger *logr.Logger) (outputPodsList *v1.PodList, err error) { podList, err := getAllRunningPods(ctx, c) if err != nil { - return outputPodsList, err + return nil, err } - podList.DeepCopyInto(&outputPodsList) - outputPodsList.Items = []v1.Pod{} - //Add predicate for image version and resources configuration predicates = append(predicates, NewRestartProxyPredicate(expectedImage, expectedResources)) for _, predicate := range predicates { evaluator, err := predicate.NewProxyRestartEvaluator(ctx) if err != nil { - return v1.PodList{}, err + return &v1.PodList{}, err } + outputPodsList = &v1.PodList{} for _, pod := range podList.Items { if evaluator.RequiresProxyRestart(pod) { - outputPodsList.Items = append(outputPodsList.Items, *pod.DeepCopy()) + outputPodsList.Items = append(outputPodsList.Items, pod) } } } - logger.Info("Pods to restart", "number of pods", len(outputPodsList.Items)) + if outputPodsList != nil { + logger.Info("Pods to restart", "number of pods", len(outputPodsList.Items)) + } return outputPodsList, nil } diff --git a/pkg/lib/sidecars/remove/remove.go b/pkg/lib/sidecars/remove/remove.go index 770f2e3a1c..16aede487f 100644 --- a/pkg/lib/sidecars/remove/remove.go +++ b/pkg/lib/sidecars/remove/remove.go @@ -15,5 +15,5 @@ func RemoveSidecars(ctx context.Context, k8sclient client.Client, logger *logr.L return nil, err } - return restart.Restart(ctx, k8sclient, *toRestart, logger) + return restart.Restart(ctx, k8sclient, toRestart, logger) } diff --git a/pkg/lib/sidecars/restart/restart.go b/pkg/lib/sidecars/restart/restart.go index 0570b1f4a9..fbf2c71916 100644 --- a/pkg/lib/sidecars/restart/restart.go +++ b/pkg/lib/sidecars/restart/restart.go @@ -26,7 +26,7 @@ func newRestartWarning(o actionObject, message string) RestartWarning { } } -func Restart(ctx context.Context, c client.Client, podList v1.PodList, logger *logr.Logger) ([]RestartWarning, error) { +func Restart(ctx context.Context, c client.Client, podList *v1.PodList, logger *logr.Logger) ([]RestartWarning, error) { warnings := make([]RestartWarning, 0) processedActionObjects := make(map[string]bool) diff --git a/pkg/lib/sidecars/restart/restart_test.go b/pkg/lib/sidecars/restart/restart_test.go index fc6b329661..602d17a25d 100644 --- a/pkg/lib/sidecars/restart/restart_test.go +++ b/pkg/lib/sidecars/restart/restart_test.go @@ -46,7 +46,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -67,7 +67,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -88,7 +88,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -109,7 +109,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -134,7 +134,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -158,7 +158,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -181,7 +181,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -204,7 +204,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -230,7 +230,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -256,7 +256,7 @@ var _ = Describe("Restart Pods", func() { c := fakeClient(&pod) // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -291,7 +291,7 @@ var _ = Describe("Restart Pods", func() { }}) // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -316,7 +316,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -351,7 +351,7 @@ var _ = Describe("Restart Pods", func() { }}) // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) From 006cb1ff4a735c10c402ca3d95b109de0e9604a9 Mon Sep 17 00:00:00 2001 From: Chwila Date: Wed, 29 May 2024 16:26:47 +0200 Subject: [PATCH 03/10] Revert unneded --- config/ui-extensions/telemetries/general | 2 +- tests/ui/package-lock.json | 8 ++++---- tests/ui/package.json | 2 +- tests/ui/support/navigation.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/ui-extensions/telemetries/general b/config/ui-extensions/telemetries/general index e0f021baed..bd9d2962b5 100644 --- a/config/ui-extensions/telemetries/general +++ b/config/ui-extensions/telemetries/general @@ -2,7 +2,7 @@ resource: kind: Telemetry group: telemetry.istio.io version: v1alpha1 -urlPath: istio-telemetries +urlPath: telemetries category: Istio name: Telemetries scope: namespace diff --git a/tests/ui/package-lock.json b/tests/ui/package-lock.json index 643873a122..6794865947 100644 --- a/tests/ui/package-lock.json +++ b/tests/ui/package-lock.json @@ -7,7 +7,7 @@ "name": "ui-tests", "devDependencies": { "@kubernetes/client-node": "0.21.0", - "cypress": "13.9.0", + "cypress": "13.10.0", "cypress-file-upload": "5.0.8", "js-yaml": "4.1.0", "typescript": "5.4.5" @@ -786,9 +786,9 @@ } }, "node_modules/cypress": { - "version": "13.9.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.9.0.tgz", - "integrity": "sha512-atNjmYfHsvTuCaxTxLZr9xGoHz53LLui3266WWxXJHY7+N6OdwJdg/feEa3T+buez9dmUXHT1izCOklqG82uCQ==", + "version": "13.10.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.10.0.tgz", + "integrity": "sha512-tOhwRlurVOQbMduX+KonoMeQILs2cwR3yHGGENoFvvSoLUBHmJ8b9/n21gFSDqjlOJ+SRVcwuh+fG/JDsHsT6Q==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/tests/ui/package.json b/tests/ui/package.json index abc119cc2b..ee001dc387 100644 --- a/tests/ui/package.json +++ b/tests/ui/package.json @@ -9,7 +9,7 @@ "start-k3d": "./scripts/k3d-local-dev.sh" }, "devDependencies": { - "cypress": "13.9.0", + "cypress": "13.10.0", "cypress-file-upload": "5.0.8", "js-yaml": "4.1.0", "typescript": "5.4.5", diff --git a/tests/ui/support/navigation.ts b/tests/ui/support/navigation.ts index fc5fb166b5..dfa8b82d46 100644 --- a/tests/ui/support/navigation.ts +++ b/tests/ui/support/navigation.ts @@ -37,14 +37,14 @@ Cypress.Commands.add('navigateToAuthorizationPolicies', (namespace: string): voi Cypress.Commands.add('navigateToTelemetries', (namespace: string): void => { cy.wrap(getK8sCurrentContext()).then((context) => { - cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/istio-telemetries`) + cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/telemetries`) cy.wait(2000); }); }); Cypress.Commands.add('navigateToTelemetry', (namespace: string, name: string): void => { cy.wrap(getK8sCurrentContext()).then((context) => { - cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/istio-telemetries/${name}`) + cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/telemetries/${name}`) cy.wait(2000); }); }); From 110efb2afaf9c4c2231669b8825353ead83f900e Mon Sep 17 00:00:00 2001 From: Chwila Date: Mon, 3 Jun 2024 12:35:39 +0200 Subject: [PATCH 04/10] Remove caching for objects --- main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.go b/main.go index b1660b28a2..e99884f739 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,9 @@ package main import ( "flag" + v1 "k8s.io/api/apps/v1" "os" + "sigs.k8s.io/controller-runtime/pkg/client" "time" networkingv1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3" @@ -107,6 +109,16 @@ func main() { HealthProbeBindAddress: flagVar.probeAddr, LeaderElection: flagVar.enableLeaderElection, LeaderElectionID: "76223278.kyma-project.io", + Client: client.Options{ + Cache: &client.CacheOptions{ + DisableFor: []client.Object{ + &v1.DaemonSet{}, + &v1.Deployment{}, + &v1.StatefulSet{}, + &v1.ReplicaSet{}, + }, + }, + }, }) if err != nil { setupLog.Error(err, "unable to start manager") From 4b2445fa0e12c614a0b8ed0bcfa1139aa1595cc5 Mon Sep 17 00:00:00 2001 From: Chwila Date: Mon, 3 Jun 2024 13:24:23 +0200 Subject: [PATCH 05/10] Post review --- main.go | 3 +++ pkg/lib/sidecars/pods/get.go | 1 + 2 files changed, 4 insertions(+) diff --git a/main.go b/main.go index e99884f739..d2009b1046 100644 --- a/main.go +++ b/main.go @@ -111,6 +111,9 @@ func main() { LeaderElectionID: "76223278.kyma-project.io", Client: client.Options{ Cache: &client.CacheOptions{ + // The cache is disabled for these objects to avoid huge memory usage. + // Having the cache enabled had previously caused memory usage + //to have a significant peak when sidecar restart was triggered. DisableFor: []client.Object{ &v1.DaemonSet{}, &v1.Deployment{}, diff --git a/pkg/lib/sidecars/pods/get.go b/pkg/lib/sidecars/pods/get.go index 92447322bf..61257da214 100644 --- a/pkg/lib/sidecars/pods/get.go +++ b/pkg/lib/sidecars/pods/get.go @@ -97,6 +97,7 @@ func containsSidecar(pod v1.Pod) bool { func GetAllInjectedPods(ctx context.Context, k8sclient client.Client) (outputPodList *v1.PodList, err error) { podList := &v1.PodList{} outputPodList = &v1.PodList{} + outputPodList.Items = make([]v1.Pod, len(podList.Items)) err = retry.RetryOnError(retry.DefaultRetry, func() error { return k8sclient.List(ctx, podList, &client.ListOptions{}) From 792d60d554d9972e08ef4fd81c151d33d7c772e7 Mon Sep 17 00:00:00 2001 From: Chwila Date: Mon, 20 May 2024 08:21:01 +0200 Subject: [PATCH 06/10] Use distinct path for Istio telemetries --- config/ui-extensions/telemetries/general | 2 +- tests/ui/support/navigation.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/ui-extensions/telemetries/general b/config/ui-extensions/telemetries/general index bd9d2962b5..e0f021baed 100644 --- a/config/ui-extensions/telemetries/general +++ b/config/ui-extensions/telemetries/general @@ -2,7 +2,7 @@ resource: kind: Telemetry group: telemetry.istio.io version: v1alpha1 -urlPath: telemetries +urlPath: istio-telemetries category: Istio name: Telemetries scope: namespace diff --git a/tests/ui/support/navigation.ts b/tests/ui/support/navigation.ts index dfa8b82d46..fc5fb166b5 100644 --- a/tests/ui/support/navigation.ts +++ b/tests/ui/support/navigation.ts @@ -37,14 +37,14 @@ Cypress.Commands.add('navigateToAuthorizationPolicies', (namespace: string): voi Cypress.Commands.add('navigateToTelemetries', (namespace: string): void => { cy.wrap(getK8sCurrentContext()).then((context) => { - cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/telemetries`) + cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/istio-telemetries`) cy.wait(2000); }); }); Cypress.Commands.add('navigateToTelemetry', (namespace: string, name: string): void => { cy.wrap(getK8sCurrentContext()).then((context) => { - cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/telemetries/${name}`) + cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/istio-telemetries/${name}`) cy.wait(2000); }); }); From e4f4cbf27a847758bfe5eb388212f818dcda7c86 Mon Sep 17 00:00:00 2001 From: Chwila Date: Wed, 29 May 2024 16:08:50 +0200 Subject: [PATCH 07/10] Remove deepcopy from gathering pods for restart --- pkg/lib/sidecars/pods/get.go | 16 +++++++-------- pkg/lib/sidecars/remove/remove.go | 2 +- pkg/lib/sidecars/restart/restart.go | 2 +- pkg/lib/sidecars/restart/restart_test.go | 26 ++++++++++++------------ 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/pkg/lib/sidecars/pods/get.go b/pkg/lib/sidecars/pods/get.go index a5c80f1a7c..92447322bf 100644 --- a/pkg/lib/sidecars/pods/get.go +++ b/pkg/lib/sidecars/pods/get.go @@ -51,32 +51,32 @@ func getAllRunningPods(ctx context.Context, c client.Client) (*v1.PodList, error return podList, nil } -func GetPodsToRestart(ctx context.Context, c client.Client, expectedImage SidecarImage, expectedResources v1.ResourceRequirements, predicates []filter.SidecarProxyPredicate, logger *logr.Logger) (outputPodsList v1.PodList, err error) { +func GetPodsToRestart(ctx context.Context, c client.Client, expectedImage SidecarImage, expectedResources v1.ResourceRequirements, predicates []filter.SidecarProxyPredicate, logger *logr.Logger) (outputPodsList *v1.PodList, err error) { podList, err := getAllRunningPods(ctx, c) if err != nil { - return outputPodsList, err + return nil, err } - podList.DeepCopyInto(&outputPodsList) - outputPodsList.Items = []v1.Pod{} - //Add predicate for image version and resources configuration predicates = append(predicates, NewRestartProxyPredicate(expectedImage, expectedResources)) for _, predicate := range predicates { evaluator, err := predicate.NewProxyRestartEvaluator(ctx) if err != nil { - return v1.PodList{}, err + return &v1.PodList{}, err } + outputPodsList = &v1.PodList{} for _, pod := range podList.Items { if evaluator.RequiresProxyRestart(pod) { - outputPodsList.Items = append(outputPodsList.Items, *pod.DeepCopy()) + outputPodsList.Items = append(outputPodsList.Items, pod) } } } - logger.Info("Pods to restart", "number of pods", len(outputPodsList.Items)) + if outputPodsList != nil { + logger.Info("Pods to restart", "number of pods", len(outputPodsList.Items)) + } return outputPodsList, nil } diff --git a/pkg/lib/sidecars/remove/remove.go b/pkg/lib/sidecars/remove/remove.go index 770f2e3a1c..16aede487f 100644 --- a/pkg/lib/sidecars/remove/remove.go +++ b/pkg/lib/sidecars/remove/remove.go @@ -15,5 +15,5 @@ func RemoveSidecars(ctx context.Context, k8sclient client.Client, logger *logr.L return nil, err } - return restart.Restart(ctx, k8sclient, *toRestart, logger) + return restart.Restart(ctx, k8sclient, toRestart, logger) } diff --git a/pkg/lib/sidecars/restart/restart.go b/pkg/lib/sidecars/restart/restart.go index 0570b1f4a9..fbf2c71916 100644 --- a/pkg/lib/sidecars/restart/restart.go +++ b/pkg/lib/sidecars/restart/restart.go @@ -26,7 +26,7 @@ func newRestartWarning(o actionObject, message string) RestartWarning { } } -func Restart(ctx context.Context, c client.Client, podList v1.PodList, logger *logr.Logger) ([]RestartWarning, error) { +func Restart(ctx context.Context, c client.Client, podList *v1.PodList, logger *logr.Logger) ([]RestartWarning, error) { warnings := make([]RestartWarning, 0) processedActionObjects := make(map[string]bool) diff --git a/pkg/lib/sidecars/restart/restart_test.go b/pkg/lib/sidecars/restart/restart_test.go index fc6b329661..602d17a25d 100644 --- a/pkg/lib/sidecars/restart/restart_test.go +++ b/pkg/lib/sidecars/restart/restart_test.go @@ -46,7 +46,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -67,7 +67,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -88,7 +88,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -109,7 +109,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -134,7 +134,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -158,7 +158,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -181,7 +181,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -204,7 +204,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -230,7 +230,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -256,7 +256,7 @@ var _ = Describe("Restart Pods", func() { c := fakeClient(&pod) // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -291,7 +291,7 @@ var _ = Describe("Restart Pods", func() { }}) // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -316,7 +316,7 @@ var _ = Describe("Restart Pods", func() { } // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) @@ -351,7 +351,7 @@ var _ = Describe("Restart Pods", func() { }}) // when - warnings, err := restart.Restart(ctx, c, podList, &logger) + warnings, err := restart.Restart(ctx, c, &podList, &logger) // then Expect(err).NotTo(HaveOccurred()) From 2ecdfb5a8f86e10be427f51d8d95aebc93f91b85 Mon Sep 17 00:00:00 2001 From: Chwila Date: Wed, 29 May 2024 16:26:47 +0200 Subject: [PATCH 08/10] Revert unneded --- config/ui-extensions/telemetries/general | 2 +- tests/ui/support/navigation.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/ui-extensions/telemetries/general b/config/ui-extensions/telemetries/general index e0f021baed..bd9d2962b5 100644 --- a/config/ui-extensions/telemetries/general +++ b/config/ui-extensions/telemetries/general @@ -2,7 +2,7 @@ resource: kind: Telemetry group: telemetry.istio.io version: v1alpha1 -urlPath: istio-telemetries +urlPath: telemetries category: Istio name: Telemetries scope: namespace diff --git a/tests/ui/support/navigation.ts b/tests/ui/support/navigation.ts index fc5fb166b5..dfa8b82d46 100644 --- a/tests/ui/support/navigation.ts +++ b/tests/ui/support/navigation.ts @@ -37,14 +37,14 @@ Cypress.Commands.add('navigateToAuthorizationPolicies', (namespace: string): voi Cypress.Commands.add('navigateToTelemetries', (namespace: string): void => { cy.wrap(getK8sCurrentContext()).then((context) => { - cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/istio-telemetries`) + cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/telemetries`) cy.wait(2000); }); }); Cypress.Commands.add('navigateToTelemetry', (namespace: string, name: string): void => { cy.wrap(getK8sCurrentContext()).then((context) => { - cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/istio-telemetries/${name}`) + cy.visit(`${config.clusterAddress}/cluster/${context}/namespaces/${namespace}/telemetries/${name}`) cy.wait(2000); }); }); From 5b26c439eef96cb0b37283bc6f44b91776179dca Mon Sep 17 00:00:00 2001 From: Chwila Date: Mon, 3 Jun 2024 12:35:39 +0200 Subject: [PATCH 09/10] Remove caching for objects --- main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.go b/main.go index b1660b28a2..e99884f739 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,9 @@ package main import ( "flag" + v1 "k8s.io/api/apps/v1" "os" + "sigs.k8s.io/controller-runtime/pkg/client" "time" networkingv1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3" @@ -107,6 +109,16 @@ func main() { HealthProbeBindAddress: flagVar.probeAddr, LeaderElection: flagVar.enableLeaderElection, LeaderElectionID: "76223278.kyma-project.io", + Client: client.Options{ + Cache: &client.CacheOptions{ + DisableFor: []client.Object{ + &v1.DaemonSet{}, + &v1.Deployment{}, + &v1.StatefulSet{}, + &v1.ReplicaSet{}, + }, + }, + }, }) if err != nil { setupLog.Error(err, "unable to start manager") From fd65944e3f0293cc5a075662094a57b94f512f5f Mon Sep 17 00:00:00 2001 From: Chwila Date: Mon, 3 Jun 2024 13:24:23 +0200 Subject: [PATCH 10/10] Post review --- main.go | 3 +++ pkg/lib/sidecars/pods/get.go | 1 + 2 files changed, 4 insertions(+) diff --git a/main.go b/main.go index e99884f739..d2009b1046 100644 --- a/main.go +++ b/main.go @@ -111,6 +111,9 @@ func main() { LeaderElectionID: "76223278.kyma-project.io", Client: client.Options{ Cache: &client.CacheOptions{ + // The cache is disabled for these objects to avoid huge memory usage. + // Having the cache enabled had previously caused memory usage + //to have a significant peak when sidecar restart was triggered. DisableFor: []client.Object{ &v1.DaemonSet{}, &v1.Deployment{}, diff --git a/pkg/lib/sidecars/pods/get.go b/pkg/lib/sidecars/pods/get.go index 92447322bf..61257da214 100644 --- a/pkg/lib/sidecars/pods/get.go +++ b/pkg/lib/sidecars/pods/get.go @@ -97,6 +97,7 @@ func containsSidecar(pod v1.Pod) bool { func GetAllInjectedPods(ctx context.Context, k8sclient client.Client) (outputPodList *v1.PodList, err error) { podList := &v1.PodList{} outputPodList = &v1.PodList{} + outputPodList.Items = make([]v1.Pod, len(podList.Items)) err = retry.RetryOnError(retry.DefaultRetry, func() error { return k8sclient.List(ctx, podList, &client.ListOptions{})