Skip to content

Commit

Permalink
fix: istio proxy exiting early when Pod has restart policy (#914)
Browse files Browse the repository at this point in the history
## Description

This changes the proxy cleanup logic to be:

All containers terminated AND either:
- restartPolicy of Never
- restartPolicy of OnFailure w/0 exit code

A restartPolicy of Always should keep restarting the containers inside
the pod and should not need proxy cleanup.

## Related Issue

Fixes #913 

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging

- [ ] Test, docs, adr added or updated as needed
- [x] [Contributor
Guide](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md)
followed
  • Loading branch information
Racer159 authored and docandrew committed Oct 17, 2024
1 parent f756c1f commit ef5e2d8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pepr/istio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ When(a.Pod)
const shouldTerminate = pod.status.containerStatuses
// Ignore the istio-proxy container
.filter(c => c.name != "istio-proxy")
// and if ALL are terminated then shouldTerminate is true
.every(c => c.state?.terminated);
// and if ALL are terminated AND restartPolicy is Never or is OnFailure with a 0 exit code then shouldTerminate is true
.every(
c =>
c.state?.terminated &&
(pod.spec?.restartPolicy == "Never" ||
(pod.spec?.restartPolicy == "OnFailure" && c.state.terminated.exitCode == 0)),
);

if (shouldTerminate) {
// Mark the pod as seen
Expand Down

0 comments on commit ef5e2d8

Please sign in to comment.