Skip to content

Commit

Permalink
feat: ignore ephemeral volumes startswith the same name of pod
Browse files Browse the repository at this point in the history
Signed-off-by: djerfy <[email protected]>
  • Loading branch information
djerfy committed Jan 3, 2024
1 parent 662dc81 commit 897a4ea
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/modules/kubernetes/get.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from kubernetes import client
from datetime import datetime
from modules.common.functions import *
import json, urllib3
import json, urllib3, re

urllib3.disable_warnings()

Expand Down Expand Up @@ -117,9 +117,12 @@ def getVolume(name=None, exclude_name=None, exclude_namespace=None, match_label=

if not "pvcRef" in volume:
continue
else:
volume['namespace'] = volume['pvcRef']['namespace']
volume['name'] = volume['pvcRef']['name']

if volume['pvcRef']['name'].startswith(pod['podRef']['name']) and re.match(r"(.*)-[a-z0-9]{8,10}-[a-z0-9]{5}$", pod['podRef']['name']):
continue

volume['namespace'] = volume['pvcRef']['namespace']
volume['name'] = volume['pvcRef']['name']

if ifObjectMatch(exclude_name, volume['name']):
continue
Expand Down

0 comments on commit 897a4ea

Please sign in to comment.