Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mizu
Commits
ebbe6458
Unverified
Commit
ebbe6458
authored
3 years ago
by
Nimrod Gilboa Markevich
Committed by
GitHub
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Do not tap pods whose names start with "mizu-". (#176)
parent
7f2021c3
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cli/cmd/tapRunner.go
+16
-2
cli/cmd/tapRunner.go
cli/fsUtils/mizuLogsUtils.go
+1
-1
cli/fsUtils/mizuLogsUtils.go
cli/mizu/consts.go
+10
-9
cli/mizu/consts.go
with
27 additions
and
12 deletions
+27
-12
cli/cmd/tapRunner.go
+
16
-
2
View file @
ebbe6458
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
cli/fsUtils/mizuLogsUtils.go
+
1
-
1
View file @
ebbe6458
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
cli/mizu/consts.go
+
10
-
9
View file @
ebbe6458
...
...
@@ -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
=
"m
izu
-
role-binding"
RoleName
=
"m
izu
-
role"
ServiceAccountName
=
"m
izu
-
service-account"
TapperDaemonSetName
=
"m
izu
-
tapper-daemon-set"
TapperPodName
=
"m
izu
-
tapper"
ConfigMapName
=
"m
izu
-
policy"
RoleBindingName
=
M
izu
ResourcesPrefix
+
"
role-binding"
RoleName
=
M
izu
ResourcesPrefix
+
"
role"
ServiceAccountName
=
M
izu
ResourcesPrefix
+
"
service-account"
TapperDaemonSetName
=
M
izu
ResourcesPrefix
+
"
tapper-daemon-set"
TapperPodName
=
M
izu
ResourcesPrefix
+
"
tapper"
ConfigMapName
=
M
izu
ResourcesPrefix
+
"
policy"
)
func
GetMizuFolderPath
()
string
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help