Skip to content

Commit

Permalink
🐛 fix ignore failed graceful shutdown (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
abahmed authored Jul 23, 2024
1 parent 9cb1b4c commit 312ce3e
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 8 deletions.
150 changes: 150 additions & 0 deletions deploy/chart/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema",
"required": [
"config"
],
"properties": {
"image": {
"type": "object",
"required": [],
"properties": {
"repository": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
],
"default": "ghcr.io/abahmed/kwatch"
},
"pullPolicy": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
],
"default": "Always"
}
}
},
"securityContext": {
"type": "object",
"required": [],
"properties": {
"runAsUser": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
],
"default": "101"
},
"runAsGroup": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
],
"default": "101"
},
"runAsNonRoot": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
],
"default": "true"
},
"readOnlyRootFilesystem": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
],
"default": "true"
}
}
},
"resources": {
"type": "object",
"required": [],
"properties": {
"limits": {
"type": "object",
"required": [],
"properties": {
"memory": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
],
"default": "128Mi"
},
"cpu": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
],
"default": "100m"
}
}
}
}
},
"nodeSelector": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
]
},
"tolerations": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
]
},
"affinity": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
]
},
"config": {
"type": [
"string",
"boolean",
"number",
"object",
"array"
],
"description": "kwatch configuration"
}
}
}
3 changes: 0 additions & 3 deletions filter/podEventsFilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package filter
import (
"strings"

"github.com/abahmed/kwatch/util"
corev1 "k8s.io/api/core/v1"
)

Expand All @@ -13,8 +12,6 @@ func (f PodEventsFilter) Execute(ctx *Context) bool {
if !ctx.PodHasIssues {
return false
}
events, _ := util.GetPodEvents(ctx.Client, ctx.Pod.Name, ctx.Pod.Namespace)
ctx.Events = &events.Items

if ctx.Events == nil {
return false
Expand Down
5 changes: 0 additions & 5 deletions handler/executeContainersFilters.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ func (h *handler) executeContainersFilters(ctx *filter.Context) {
ownerName = ctx.Owner.Name
}

if ctx.Events == nil {
events, _ := util.GetPodEvents(ctx.Client, ctx.Pod.Name, ctx.Pod.Namespace)
ctx.Events = &events.Items
}

logrus.Printf(
"container only issue %s %s %s %s %s %d",
ctx.Container.Container.Name,
Expand Down
15 changes: 15 additions & 0 deletions handler/processPod.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package handler

import (
"github.com/abahmed/kwatch/filter"
"github.com/abahmed/kwatch/util"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
)

Expand All @@ -23,6 +25,19 @@ func (h *handler) ProcessPod(eventType string, pod *corev1.Pod) {
EvType: eventType,
}

podEvents, err := util.GetPodEvents(ctx.Client, ctx.Pod.Name, ctx.Pod.Namespace)
if err != nil {
logrus.Errorf(
"failed to get events for pod %s(%s): %s",
ctx.Pod.Name,
ctx.Pod.Namespace,
err.Error())
}

if podEvents != nil {
ctx.Events = &podEvents.Items
}

h.executePodFilters(&ctx)
h.executeContainersFilters(&ctx)
}

0 comments on commit 312ce3e

Please sign in to comment.