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 #340

Merged
merged 1 commit into from
Feb 4, 2025
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Feb 4, 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

Enhancements:

  • Refactor the node instance creation and update logic to improve code clarity and maintainability by separating concerns into distinct functions.

* Store localhost information immediately

* Fix return code on failure
Use sqlite3_step_monitored

* Remove get_node_list

* Schedule node_state_update after 1 second
Code cleanup

* Code dedup
aclk_create_node_instance_job to create a new node
aclk_update_node_instance_job tp update node status
aclk_send_node_instances uses in-memory hosts
@pull pull bot added the ⤵️ pull label Feb 4, 2025
@pull pull bot merged commit dd7861a into webfutureiorepo:master Feb 4, 2025
Copy link

sourcery-ai bot commented Feb 4, 2025

Reviewer's Guide by Sourcery

This pull request refactors the ACLK module to separate node instance creation and update logic into distinct functions, simplifying the process and improving code readability. It also removes unused code related to node instance management in the SQLite metadata module, consolidating metadata storage functions for efficiency. Additionally, it updates RRDHOST creation to store host info and metadata immediately if the host is local, and simplifies ACLK query handling by removing unnecessary parameters.

Sequence diagram for updated node instance management flow

sequenceDiagram
    participant Host as RRDHOST
    participant ACLK as ACLK Module
    participant DB as SQLite DB

    Host->>ACLK: aclk_host_state_update(host, live, queryable)
    alt host is online
        alt node_id is null
            ACLK->>ACLK: aclk_create_node_instance_job(host)
            Note over ACLK: Creates new node instance
        else node_id exists
            ACLK->>ACLK: aclk_update_node_instance_job(host, live, queryable)
            Note over ACLK: Updates existing node instance
        end
    end
Loading

Class diagram for refactored node instance management

classDiagram
    class ACLK {
        +aclk_host_state_update(host, live, queryable)
        +aclk_create_node_instance_job(host)
        +aclk_update_node_instance_job(host, live, queryable)
        +aclk_send_node_instances()
    }

    class node_instance_creation_t {
        +claim_id: string
        +hops: int32
        +hostname: string
        +machine_guid: string
    }

    class node_instance_connection_t {
        +claim_id: string
        +hops: int32
        +live: int
        +queryable: int
        +session_id: string
        +node_id: string
        +capabilities: string
    }

    ACLK ..> node_instance_creation_t
    ACLK ..> node_instance_connection_t
Loading

Flow diagram for host metadata storage process

flowchart TD
    A[Start] --> B{Check Host Flags}
    B -->|METADATA_LABELS| C[Store Host Labels]
    B -->|METADATA_CLAIMID| D[Store Claim ID]
    B -->|METADATA_INFO| E[Store Host and System Info]
    C --> F[Clear METADATA_LABELS flag]
    D --> G[Clear METADATA_CLAIMID flag]
    E --> H[Clear METADATA_INFO flag]
    F & G & H --> I[End]
Loading

File-Level Changes

Change Details Files
Refactor and simplify node instance creation and update logic in ACLK module.
  • Replaced aclk_host_state_update function with aclk_create_node_instance_job and aclk_update_node_instance_job for better separation of concerns.
  • Simplified the logic for creating and updating node instances by removing redundant checks and streamlining the process.
  • Updated logging to reflect the new function names and parameters.
src/aclk/aclk.c
src/aclk/aclk.h
Remove unused and redundant code related to node instance management in SQLite metadata module.
  • Deleted the get_node_list function and associated SQL query as they are no longer needed.
  • Removed redundant checks and flags in metadata functions to streamline the code.
  • Consolidated metadata storage functions into store_host_info_and_metadata for efficiency.
src/database/sqlite/sqlite_metadata.c
src/database/sqlite/sqlite_metadata.h
Update RRDHOST creation to immediately store host info and metadata if the host is local.
  • Added logic to store host info and metadata during RRDHOST creation if the host is identified as localhost.
  • Utilized the new store_host_info_and_metadata function for this purpose.
src/database/rrdhost.c
Simplify ACLK query handling by removing client parameter where unnecessary.
  • Removed the client parameter from create_node_instance_result_job and aclk_send_node_instances functions as it was not used.
  • Updated function calls and definitions to reflect this change.
src/database/sqlite/sqlite_aclk.c

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.

1 participant