Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix ignore failed graceful shutdown #332

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading