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

Replacing the object informer implementation in cache #103

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

slashben
Copy link
Member

@slashben slashben commented Dec 14, 2023

Type

Enhancement


Description

This PR replaces the object informer implementation in the cache with a pure watcher of Kubernetes objects. The main changes include:

  • The informer is replaced with a watcher in the cache implementation.
  • The watcher is implemented using the watcher package.
  • The watcher is started in the StartController function and stopped in the Destroy function.
  • The handleApplicationProfile and handleDeleteApplicationProfile functions are updated to handle unstructured.Unstructured objects.
  • The Makefile is updated to apply the CRDs from the chart/kubecop/crds directory.
  • The kubescape/kapprofiler dependency is updated to version v0.0.36.

PR changes walkthrough

Relevant files                                                                                                                                 
Enhancement
1 files
cache.go                                                                                                       
    pkg/approfilecache/cache.go

    The informer is replaced with a watcher in the cache
    implementation. The watcher is implemented using the
    `watcher` package. The watcher is started in the
    `StartController` function and stopped in the `Destroy`
    function. The `handleApplicationProfile` and
    `handleDeleteApplicationProfile` functions are updated to
    handle `unstructured.Unstructured` objects.
+36/-33
Configuration changes
1 files
Makefile                                                                                                       
    Makefile

    The `Makefile` is updated to apply the CRDs from the
    `chart/kubecop/crds` directory.
+2/-2
Dependencies
2 files
go.mod                                                                                                           
    go.mod

    The `kubescape/kapprofiler` dependency is updated to version
    `v0.0.36`.
+1/-1
go.sum                                                                                                           
    go.sum

    The checksum for the `kubescape/kapprofiler` dependency is
    updated to match the new version.
+2/-2

User description

Replacing object informer implementation in cache to pure watcher of Kubernetes objects.

This will reduce memory usage since it does not cache everything at the object level in RAM.

Signed-off-by: Ben <[email protected]>
@codiumai-pr-agent-free codiumai-pr-agent-free bot added the enhancement New feature or request label Dec 14, 2023
Copy link

PR Description updated to latest commit (975be89)

@slashben slashben added the requires-system-test trigger to run system test on PRs label Dec 14, 2023
@codiumai-pr-agent-free codiumai-pr-agent-free bot removed the requires-system-test trigger to run system test on PRs label Dec 14, 2023
Copy link

PR Analysis

  • 🎯 Main theme: Replacing the object informer implementation in cache with a watcher
  • 📝 PR summary: This PR enhances the cache implementation by replacing the object informer with a watcher. It also updates the Makefile to apply the CRDs from the chart/kubecop/crds directory and updates the kubescape/kapprofiler dependency to version v0.0.36.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 3, because the PR involves changes in the core functionality of the cache and introduces a new watcher. It requires a good understanding of the project and the watcher package to review.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • 💡 General suggestions: The PR is well structured and the changes are clear. However, it would be beneficial to add tests to ensure the new watcher implementation works as expected. Also, consider handling the error returned by the Start function of the watcher in a more user-friendly way, rather than just logging it.

  • 🤖 Code feedback:
    relevant filepkg/approfilecache/cache.go
    suggestion      Consider handling the error returned by the `Start` function of the watcher in a more user-friendly way. Instead of just logging the error, you could return it to the caller or handle it in a way that the caller is aware of the issue. [important]
    relevant line"+ err := c.applicationProfileWatcher.Start("

    relevant filepkg/approfilecache/cache.go
    suggestion      It would be beneficial to add error handling for the `Stop` function of the watcher in the `Destroy` function. This will ensure any issues while stopping the watcher are properly handled. [medium]
    relevant line"+ cache.applicationProfileWatcher.Stop()"

How to use

Instructions

To invoke the PR-Agent, add a comment using one of the following commands:
/review: Request a review of your Pull Request.
/describe: Update the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
/ask <QUESTION>: Ask a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.
/add_docs: Generate docstring for new components introduced in the PR.
/generate_labels: Generate labels for the PR based on the PR's contents.
see the tools guide for more details.

To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

Copy link

✨ Artifacts are available here.

@slashben slashben merged commit b29aeae into main Dec 14, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants