Skip to content

Commit

Permalink
feat: implements daemonset
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampouille committed Sep 20, 2023
1 parent fb89329 commit 71fa0cb
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ def __init__(self, deploy):
def __str__(self):
return "Deployment not Found: %s" % self.deploy

class DaemonSetNotfound(Exception):

def __init__(self, ds):
self.ds = ds

def __str__(self):
return "DaemonSet not Found: %s" % self.deploy

class NotImplemented(Exception):

def __init__(self, msg):
Expand Down Expand Up @@ -124,6 +132,10 @@ def getWorkload(self, pod):
rs_owner = self.getRSOwner(owner[1])
self.pod_to_workload[pod] = rs_owner
return rs_owner
elif owner[0] == 'DaemonSet':
self.pod_to_workload[pod] = owner
self.wl_selector["%s-%s" % (owner[0], owner[1])] = self.getDaemonSetSelector(owner[1])
return owner
else:
raise NotImplemented("getWorkload(%s)" % owner[0])

Expand Down Expand Up @@ -161,13 +173,26 @@ def getDeploymentSelector(self, deploy):
if e.reason == 'Not Found':
raise DeploymentNotfound(deploy)

def process(self, event):
#print("Searching workload for %s/%s" % (self.ns, event[1]))
wl = self.getWorkload(event[1])
#print("Workload for %s/%s is %s" % (self.ns, event[1], wl))
def getDaemonSetSelector(self, ds):
try:
api_response = self.appsv1.read_namespaced_daemon_set(ds, self.ns, pretty=True)
#pprint(api_response)
selector = api_response.spec.selector.match_labels
return selector
except ApiException as e:
if e.reason == 'Not Found':
raise DaemonSetNotfound(ds)

with self.lock:
self.binaries.add("%s-%s" % (wl[0], wl[1]), event[2])
def process(self, event):
try:
#print("Searching workload for %s/%s" % (self.ns, event[1]))
wl = self.getWorkload(event[1])
#print("Workload for %s/%s is %s" % (self.ns, event[1], wl))

with self.lock:
self.binaries.add("%s-%s" % (wl[0], wl[1]), event[2])
except PodNotfound as e:
print(e)

def forgot(self, wl, binary):
if wl in self.binaries.written and binary in self.binaries.written[wl]:
Expand Down

0 comments on commit 71fa0cb

Please sign in to comment.