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

🐛 handle empty events #308

Merged
merged 2 commits into from
May 31, 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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

```shell
helm repo add kwatch https://kwatch.dev/charts
helm install [RELEASE_NAME] kwatch/kwatch --namespace kwatch --create-namespace --version 0.9.0
helm install [RELEASE_NAME] kwatch/kwatch --namespace kwatch --create-namespace --version 0.9.1
```

To get more details, please check [chart's configuration](https://github.com/abahmed/kwatch/blob/main/deploy/chart/README.md)
Expand All @@ -46,7 +46,7 @@ To get more details, please check [chart's configuration](https://github.com/aba
You need to get config template to add your configs

```shell
curl -L https://raw.githubusercontent.com/abahmed/kwatch/v0.9.0/deploy/config.yaml -o config.yaml
curl -L https://raw.githubusercontent.com/abahmed/kwatch/v0.9.1/deploy/config.yaml -o config.yaml
```

Then edit `config.yaml` file and apply your configuration
Expand All @@ -58,7 +58,7 @@ kubectl apply -f config.yaml
To deploy **kwatch**, execute following command:

```shell
kubectl apply -f https://raw.githubusercontent.com/abahmed/kwatch/v0.9.0/deploy/deploy.yaml
kubectl apply -f https://raw.githubusercontent.com/abahmed/kwatch/v0.9.1/deploy/deploy.yaml
```

## High Level Architecture
Expand Down Expand Up @@ -326,8 +326,8 @@ basic auth
### Cleanup

```shell
kubectl delete -f https://raw.githubusercontent.com/abahmed/kwatch/v0.9.0/deploy/config.yaml
kubectl delete -f https://raw.githubusercontent.com/abahmed/kwatch/v0.9.0/deploy/deploy.yaml
kubectl delete -f https://raw.githubusercontent.com/abahmed/kwatch/v0.9.1/deploy/config.yaml
kubectl delete -f https://raw.githubusercontent.com/abahmed/kwatch/v0.9.1/deploy/deploy.yaml
```

## 👍 Contribute & Support
Expand Down
4 changes: 2 additions & 2 deletions deploy/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: kwatch
version: "0.9.0"
appVersion: "v0.9.0"
version: "0.9.1"
appVersion: "v0.9.1"
description: monitor all changes in your Kubernetes(K8s) cluster, detects crashes
in your running apps in realtime, and publishes notifications to your channels (Slack,
Discord, etc.) instantly
Expand Down
2 changes: 1 addition & 1 deletion deploy/chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ helm repo update
## Install Chart

```console
helm install [RELEASE_NAME] kwatch/kwatch --version 0.9.0
helm install [RELEASE_NAME] kwatch/kwatch --version 0.9.1
```

## Uninstall Chart
Expand Down
2 changes: 1 addition & 1 deletion deploy/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
serviceAccountName: kwatch
containers:
- name: kwatch
image: ghcr.io/abahmed/kwatch:v0.9.0
image: ghcr.io/abahmed/kwatch:v0.9.1
imagePullPolicy: Always
volumeMounts:
- name: config-volume
Expand Down
5 changes: 5 additions & 0 deletions handler/executeContainersFilters.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ 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
4 changes: 4 additions & 0 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (

// GetPodEventsStr returns formatted events as a string for specified pod
func GetPodEventsStr(events *[]v1.Event) string {
if events == nil {
return ""
}

eventsString := ""

for _, ev := range *events {
Expand Down
8 changes: 8 additions & 0 deletions util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ func TestGetPodEventsStr(t *testing.T) {
assert.Equal(result, expectedOutput)
}

func TestGetPodEventsStrNil(t *testing.T) {
assert := assert.New(t)

result := GetPodEventsStr(nil)
expectedOutput := ""
assert.Equal(result, expectedOutput)
}

func TestContainsKillingStoppingContainerEvents(t *testing.T) {
assert := assert.New(t)

Expand Down
Loading