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 bug where pod monitoring stops working after a while for Kubernetes agent #836

Merged
merged 4 commits into from
Mar 14, 2024

Conversation

flin-8
Copy link
Contributor

@flin-8 flin-8 commented Mar 14, 2024

[sc-73237]

Background

#824 starting using a Watcher to get updates for Pods. Unfortunately the Kubernetes API Server will close the connection after some time (we can't have the watch open forever).

Results

This PR adds a short timeout of 10min and reloads the status after that.

We also add a try/catch around the entire status loading so we don't silently lose track of Pod statuses.

Screenshot of Pod status loading at startup:
CleanShot 2024-03-14 at 13 26 44@2x

Status is reloaded after 10min:
CleanShot 2024-03-14 at 13 27 35@2x

How to review this PR

Quality ✔️

Pre-requisites

  • I have read How we use GitHub Issues for help deciding when and where it's appropriate to make an issue.
  • I have considered informing or consulting the right people, according to the ownership map.
  • I have considered appropriate testing for my change.

Copy link

This pull request has been linked to Shortcut Story #71688: Refactor job monitoring code to be long running.

@flin-8 flin-8 self-assigned this Mar 14, 2024
Copy link

@flin-8 flin-8 marked this pull request as ready for review March 14, 2024 02:30
@flin-8 flin-8 requested a review from a team as a code owner March 14, 2024 02:30
Copy link
Contributor

@scme0 scme0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM

@@ -33,6 +35,21 @@ public KubernetesPodMonitor(IKubernetesPodService podService, ISystemLog log)
}

async Task IKubernetesPodMonitor.StartAsync(CancellationToken cancellationToken)
{
var maxDurationSeconds = 70;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should this be a const?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

[TestFixture]
public class ExponentialBackoffFixture
{
readonly Foo foo = new Foo();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't touch that, its a load bearing Foo 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha... I extracted that to a different class ...

Copy link
Contributor

@LukeButters LukeButters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you need a SaST approval LGTM

Although I only looked at things outside of the k8s folder

@flin-8 flin-8 merged commit a4c2c33 into main Mar 14, 2024
49 checks passed
@flin-8 flin-8 deleted the frank/podmonitor branch March 14, 2024 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants