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

[POA-2928] Changed the event watcher to watch pod changes not event changes #82

Merged
merged 26 commits into from
Feb 19, 2025

Conversation

mudit-postman
Copy link
Contributor

@mudit-postman mudit-postman commented Feb 18, 2025

  • Change from event watcher to pod watcher in k8s
  • Changes in k8s event worker, also added modified state handler
  • Remove state change to traffic stopped from traffic ended and errored
  • Change inspectPodForEnvVars func, it will now except podArgs object
  • Change the state management of pod traffic monitoring, state diagram
  • Changes in dump log formatting

- Add logs before each process start
- Move default interval time to daemonset module:
- Handle case if any state change is allowed in changePodTrafficMonitorState()
- if condition in addPodArgsToMap() is opposite also not this func will
  return error
- telemetry api erroring our due to nil resp var
- already deleted pod is not getting removed during pod health check
- telemetry api erroring our due to nil resp var
- already deleted pod is not getting removed during pod health check
…bs/postman-insights-agent into mudit/poa-2609-testing-changes
- Change from event watcher to pod watcher in k8s
- Changes in k8s event worker, also added modified state handler
- Remove state change to traffic stopped from traffic ended and errored
- Change inspectPodForEnvVars func, it will now except podArgs object
- Added sync.WaitGroup for apidump processes
- Refactored states to make them same as k8s pods states
@mudit-postman mudit-postman marked this pull request as ready for review February 18, 2025 14:03
@mudit-postman mudit-postman changed the title Changed the event watcher to watch pod changes not event changes [POA-2928] Changed the event watcher to watch pod changes not event changes Feb 18, 2025
liujed and others added 6 commits February 18, 2025 22:52
Before:
```
[INFO] Running learn mode on interfaces lo, wlan0
[INFO] Send SIGINT (Ctrl-C) to stop...
^C[INFO] Received interrupt, stopping trace collection...
panic: close of closed channel
```
After:
```
[INFO] Running learn mode on interfaces lo, wlan0
[INFO] Send SIGINT (Ctrl-C) to stop...
^C[INFO] Received interrupt, stopping trace collection...
[INFO] Trace collection stopped
[INFO] Did not capture any TCP packets matching the filter. This may mean your filter is incorrect, such as the wrong TCP port.
[ERROR] No HTTP calls captured! 🛑

[ERROR] Error during initiaization: API trace is empty
[INFO] This process will not exit, to avoid boot loops. Please correct the command line flags or environment and retry.
```
Copy link
Contributor

@mgritter mgritter left a comment

Choose a reason for hiding this comment

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

Looks OK, let's clean up the use of a bool for the double-close fix.

It would be nicer to identify what the underlying cause is to make sure there's not some other logic change -- it should be unambiguous whose job it is to stop the background process.

Comment on lines 33 to 38
// Empty podArgs object for PodPending state
args := &PodArgs{
PodName: pod.Name,
// though 1 buffer size is enough, keeping 2 for safety
StopChan: make(chan error, 2),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This creation of a PodArgs in a particular state should be encapsulated in a function? It appears at least twice.

}
printer.Debugf("Pod in pending state added to map, pod name: %s\n", pod.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

The log message makes it sound like it has already occurred, but we could fail -- maybe move this below the error check, or adjust its wording?

Comment on lines +38 to +41

// Whether this redactor is still running. False if and only if exitChannel is
// closed.
running *atomic.Bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, any use of an atomic.Bool is a code smell, particularly if you're trying to signal the state of some other object. Is there a higher-level construct that will do the job?

It looks like what you want is for StopPeriodicUpdates() to call close() exactly once. Maybe a sync.Once is the appropriate thing then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This commit is from another PR for POA-2904 which is already merged to master.
I had raised the initial PR #81, and then Jed raised his own PR #83, which we merged.

We can discuss this in the ticket if there should be a change in implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why those changes were merged into this branch, then?

Fixes from other PRs should go into the main branch or a feature branch, then merged from there back into the development branch, so they don't have to be reviewed twice.

Base automatically changed from mudit/poa-2609-testing-changes to mudit/poa-2609 February 19, 2025 20:23
@mudit-postman mudit-postman merged commit de58c5e into mudit/poa-2609 Feb 19, 2025
2 checks passed
@mudit-postman mudit-postman deleted the mudit/event-watcher-changes branch February 19, 2025 20:47
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.

4 participants