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

[pull] master from netdata:master #370

Merged
merged 4 commits into from
Feb 17, 2025
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Feb 17, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

This pull request introduces Kubernetes Deployment metrics collection, including replicas and age, and fixes a bug in the ARAL memory management library related to freeing the last page of items. It also includes some performance improvements to the database engine event loop.

New Features:

  • Adds collection and charting of Kubernetes Deployment metrics, including desired, current, and ready replicas, as well as deployment age.

Bug Fixes:

  • Fixes a bug in ARAL where the last page with free items was incorrectly deleted, leading to potential memory corruption. Now, the last page is kept and reset.

Enhancements:

  • Improves the ARAL (Adaptive Resizable Allocation Library) by using the slot ID of the item to be freed to determine the partition number, which should improve performance.
  • The database engine event loop now calls worker_is_idle() and runs the loop in UV_RUN_NOWAIT mode every 100 iterations to improve responsiveness.

CI:

  • Updates the pull request bot to version v2.0.0-alpha.1.

Documentation:

  • Adds documentation for the new Deployment metrics in the Kubernetes State collector.

Tests:

  • Adds a test case to verify the collection of Deployment metrics.

@pull pull bot added the ⤵️ pull label Feb 17, 2025
@pull pull bot merged commit 12930b2 into webfutureiorepo:master Feb 17, 2025
Copy link

sourcery-ai bot commented Feb 17, 2025

Reviewer's Guide by Sourcery

This pull request introduces deployment metrics collection to the k8s_state collector, improves ARAL free slot management, and adjusts the storage engine command dequeueing logic. The k8s_state collector now collects and exposes metrics related to Kubernetes deployments, such as replicas and age. The ARAL allocator's free slot management has been improved to use the slot ID for partition selection and to handle the last page with free items more efficiently. The storage engine's command dequeueing logic has been adjusted to better manage command priorities and worker thread idling.

Sequence diagram for collecting deployment state

sequenceDiagram
  participant Collector
  participant kubeState
  participant deploymentState
  participant Charts

  Collector->>Collector: collectDeploymentState(mx)
  loop for each deployment in c.state.deployments
    alt ds.deleted
      Collector->>Collector: removeDeploymentCharts(ds)
      Collector->>kubeState: Delete deployment from c.state.deployments
    else ds.new
      Collector->>Collector: addDeploymentCharts(ds)
      Collector->>deploymentState: ds.new = false
    end
    Collector->>mx: Update metrics in mx
  end
Loading

Updated class diagram for kubeState

classDiagram
  class kubeState {
    *sync.Mutex Mutex
    map[string]*nodeState nodes
    map[string]*podState pods
    map[string]*deploymentState deployments
  }
Loading

New class diagram for deploymentState

classDiagram
  class deploymentState {
    bool new
    bool deleted
    string uid
    string name
    string namespace
    time.Time creationTime
    int64 replicas
    int64 availableReplicas
    int64 readyReplicas
    string id()
  }
Loading

File-Level Changes

Change Details Files
Added deployment metrics collection to the k8s_state collector.
  • Added deploymentState struct to represent the state of a deployment.
  • Added newDeploymentDiscoverer to discover deployments.
  • Added updateDeploymentState to update the state of a deployment.
  • Added collectDeploymentState to collect metrics for deployments.
  • Added deployment charts for replicas and age.
  • Added deployment metrics to the metadata.yaml file.
  • Added deployment metrics to the kubernetes_cluster_state.md file.
src/go/plugin/go.d/collector/k8s_state/charts.go
src/go/plugin/go.d/collector/k8s_state/state.go
src/go/plugin/go.d/collector/k8s_state/collector_test.go
src/go/plugin/go.d/collector/k8s_state/collect.go
src/go/plugin/go.d/collector/k8s_state/metadata.yaml
src/go/plugin/go.d/collector/k8s_state/integrations/kubernetes_cluster_state.md
src/go/plugin/go.d/collector/k8s_state/resource.go
src/go/plugin/go.d/collector/k8s_state/discover_kubernetes.go
src/go/plugin/go.d/collector/k8s_state/discover_deployment.go
src/go/plugin/go.d/collector/k8s_state/update_deployment_state.go
Improved ARAL (Allocator with Retention Awareness Logic) free slot management.
  • Used the slot ID of the item to be freed to determine the partition number in aral_add_free_slot___no_lock_required.
  • Modified aral_freez_internal to handle the case where the page being freed is the last page with free items, keeping it instead of deleting it.
src/libnetdata/aral/aral.c
Adjusted the storage engine command dequeueing logic.
  • Modified rrdeng_deq_cmd to correctly set min and max priorities based on whether the call is from a worker thread.
  • Added logic to dbengine_event_loop to call worker_is_idle and run the event loop periodically while waiting for commands.
src/database/engine/rrdengine.c
src/database/storage-engine.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants