diff --git a/cli/cmd/tapRunner.go b/cli/cmd/tapRunner.go index 030740fce..7faeac86b 100644 --- a/cli/cmd/tapRunner.go +++ b/cli/cmd/tapRunner.go @@ -419,7 +419,8 @@ func updateCurrentlyTappedPods(kubernetesProvider *kubernetes.Provider, ctx cont if matchingPods, err := kubernetesProvider.ListAllRunningPodsMatchingRegex(ctx, mizu.Config.Tap.PodRegex(), targetNamespaces); err != nil { return err, false } else { - addedPods, removedPods := getPodArrayDiff(state.currentlyTappedPods, matchingPods) + podsToTap := excludeMizuPods(matchingPods) + addedPods, removedPods := getPodArrayDiff(state.currentlyTappedPods, podsToTap) for _, addedPod := range addedPods { changeFound = true mizu.Log.Infof(uiUtils.Green, fmt.Sprintf("+%s", addedPod.Name)) @@ -428,12 +429,25 @@ func updateCurrentlyTappedPods(kubernetesProvider *kubernetes.Provider, ctx cont changeFound = true mizu.Log.Infof(uiUtils.Red, fmt.Sprintf("-%s", removedPod.Name)) } - state.currentlyTappedPods = matchingPods + state.currentlyTappedPods = podsToTap } return nil, changeFound } +func excludeMizuPods(pods []core.Pod) []core.Pod { + mizuPrefixRegex := regexp.MustCompile("^" + mizu.MizuResourcesPrefix) + + nonMizuPods := make([]core.Pod, 0) + for _, pod := range pods { + if !mizuPrefixRegex.MatchString(pod.Name) { + nonMizuPods = append(nonMizuPods, pod) + } + } + + return nonMizuPods +} + func getPodArrayDiff(oldPods []core.Pod, newPods []core.Pod) (added []core.Pod, removed []core.Pod) { added = getMissingPods(newPods, oldPods) removed = getMissingPods(oldPods, newPods) diff --git a/cli/fsUtils/mizuLogsUtils.go b/cli/fsUtils/mizuLogsUtils.go index 701c8b25f..b48cc2aa6 100644 --- a/cli/fsUtils/mizuLogsUtils.go +++ b/cli/fsUtils/mizuLogsUtils.go @@ -11,7 +11,7 @@ import ( ) func DumpLogs(provider *kubernetes.Provider, ctx context.Context, filePath string) error { - podExactRegex := regexp.MustCompile(fmt.Sprintf("^mizu-")) + podExactRegex := regexp.MustCompile("^" + mizu.MizuResourcesPrefix) pods, err := provider.ListAllPodsMatchingRegex(ctx, podExactRegex, []string{mizu.Config.MizuResourcesNamespace}) if err != nil { return err diff --git a/cli/mizu/consts.go b/cli/mizu/consts.go index 576010709..c90c78179 100644 --- a/cli/mizu/consts.go +++ b/cli/mizu/consts.go @@ -14,16 +14,17 @@ var ( ) const ( - ApiServerPodName = "mizu-api-server" - ClusterRoleBindingName = "mizu-cluster-role-binding" - ClusterRoleName = "mizu-cluster-role" + MizuResourcesPrefix = "mizu-" + ApiServerPodName = MizuResourcesPrefix + "api-server" + ClusterRoleBindingName = MizuResourcesPrefix + "cluster-role-binding" + ClusterRoleName = MizuResourcesPrefix + "cluster-role" K8sAllNamespaces = "" - RoleBindingName = "mizu-role-binding" - RoleName = "mizu-role" - ServiceAccountName = "mizu-service-account" - TapperDaemonSetName = "mizu-tapper-daemon-set" - TapperPodName = "mizu-tapper" - ConfigMapName = "mizu-policy" + RoleBindingName = MizuResourcesPrefix + "role-binding" + RoleName = MizuResourcesPrefix + "role" + ServiceAccountName = MizuResourcesPrefix + "service-account" + TapperDaemonSetName = MizuResourcesPrefix + "tapper-daemon-set" + TapperPodName = MizuResourcesPrefix + "tapper" + ConfigMapName = MizuResourcesPrefix + "policy" ) func GetMizuFolderPath() string {