Decrease runtime #18

Merged
kleb merged 2 commits from performance into main 2025-12-29 08:37:16 +01:00
Owner

User description

Improving performance


PR Type

Enhancement


Description

  • Removed redundant apt update call in software installer.

  • Added debug logging for package processing in utils.sh.

  • Integrated finalizeDebugLog into the cleanup process.

  • Updated checksums for modified utility scripts.


Diagram Walkthrough

flowchart LR
  A["software.sh"] -- "Remove redundant apt update" --> B["Faster Installation"]
  C["utils.sh"] -- "Add logDebug" --> D["Better Traceability"]
  E["kInit.sh"] -- "Call finalizeDebugLog" --> F["Log Finalization"]

File Walkthrough

Relevant files
Enhancement
software.sh
Remove redundant apt update command                                           

installer/software/software.sh

  • Removed the noOut apt update command before installing the Zabbix
    agent package to reduce execution time.
+3/-5     
utils.sh
Add debug logging to package installation                               

installer/utils.sh

  • Added a logDebug statement to track which package is currently being
    processed in the installPackage function.
+211/-15
kInit.sh
Finalize debug logs during cleanup                                             

kInit.sh

  • Added a call to finalizeDebugLog within the clean function to ensure
    logs are properly closed upon completion.
+5/-1     
Configuration changes
checksums.sha256
Update file checksums                                                                       

checksums.sha256

  • Updated the SHA256 hash for installer/utils.sh to reflect the recent
    code changes.
+2/-2     

### **User description** Improving performance ___ ### **PR Type** Enhancement ___ ### **Description** - Removed redundant `apt update` call in software installer. - Added debug logging for package processing in `utils.sh`. - Integrated `finalizeDebugLog` into the cleanup process. - Updated checksums for modified utility scripts. ___ ### Diagram Walkthrough ```mermaid flowchart LR A["software.sh"] -- "Remove redundant apt update" --> B["Faster Installation"] C["utils.sh"] -- "Add logDebug" --> D["Better Traceability"] E["kInit.sh"] -- "Call finalizeDebugLog" --> F["Log Finalization"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>software.sh</strong><dd><code>Remove redundant apt update command</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> installer/software/software.sh <ul><li>Removed the <code>noOut apt update</code> command before installing the Zabbix <br>agent package to reduce execution time.</ul> </details> </td> <td><a href="https://git.kleb.sh/kleb/kInit/src/branch/performance/installer/software/software.sh">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>utils.sh</strong><dd><code>Add debug logging to package installation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> installer/utils.sh <ul><li>Added a <code>logDebug</code> statement to track which package is currently being <br>processed in the <code>installPackage</code> function.</ul> </details> </td> <td><a href="https://git.kleb.sh/kleb/kInit/src/branch/performance/installer/utils.sh">+211/-15</a></td> </tr> <tr> <td> <details> <summary><strong>kInit.sh</strong><dd><code>Finalize debug logs during cleanup</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> kInit.sh <ul><li>Added a call to <code>finalizeDebugLog</code> within the <code>clean</code> function to ensure <br>logs are properly closed upon completion.</ul> </details> </td> <td><a href="https://git.kleb.sh/kleb/kInit/src/branch/performance/kInit.sh">+5/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Configuration changes</strong></td><td><table> <tr> <td> <details> <summary><strong>checksums.sha256</strong><dd><code>Update file checksums</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> checksums.sha256 <ul><li>Updated the SHA256 hash for <code>installer/utils.sh</code> to reflect the recent <br>code changes.</ul> </details> </td> <td><a href="https://git.kleb.sh/kleb/kInit/src/branch/performance/checksums.sha256">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> </details> ___
Collaborator

PR Reviewer Guide 🔍

(Review updated until commit f4d9ef702d)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵
🧪 No relevant tests
🔒 No security concerns identified
 Recommended focus areas for review

Missing Changes

The PR description mentions removing a redundant apt update call, but the diff for software.sh only shows version and date metadata updates. Please verify if the performance-related code changes were omitted from the commit.

# Last modified: 2025/12/29
#
# Version: 1.4
#

set -euo pipefail

currentName="Software Installer"
currentVersion="1.4"
Execution Order

The finalizeDebugLog function is called before remove "utils.sh". If finalizeDebugLog is defined within utils.sh, ensure that the script is still sourced or available in the environment at this point in the cleanup process.

finalizeDebugLog
remove "utils.sh"
## PR Reviewer Guide 🔍 #### (Review updated until commit https://git.kleb.sh/kleb/kInit/commit/f4d9ef702d5a3d7bbfcd0042afb28ea7f398aa0b) Here are some key observations to aid the review process: <table> <tr><td>⏱️&nbsp;<strong>Estimated effort to review</strong>: 1 🔵⚪⚪⚪⚪</td></tr> <tr><td>🧪&nbsp;<strong>No relevant tests</strong></td></tr> <tr><td>🔒&nbsp;<strong>No security concerns identified</strong></td></tr> <tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br> <details><summary><a href='https://git.kleb.sh/kleb/kInit/src/branch/performance/installer/software/software.sh#L6-L14'><strong>Missing Changes</strong></a> The PR description mentions removing a redundant `apt update` call, but the diff for `software.sh` only shows version and date metadata updates. Please verify if the performance-related code changes were omitted from the commit. </summary> ```shell # Last modified: 2025/12/29 # # Version: 1.4 # set -euo pipefail currentName="Software Installer" currentVersion="1.4" ``` </details> <details><summary><a href='https://git.kleb.sh/kleb/kInit/src/branch/performance/kInit.sh#L240-L241'><strong>Execution Order</strong></a> The `finalizeDebugLog` function is called before `remove "utils.sh"`. If `finalizeDebugLog` is defined within `utils.sh`, ensure that the script is still sourced or available in the environment at this point in the cleanup process. </summary> ```shell finalizeDebugLog remove "utils.sh" ``` </details> </td></tr> </table>
Collaborator

PR Code Suggestions

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix potential command not found error

The finalizeDebugLog function is called after remove "utils.sh". If finalizeDebugLog
is defined within utils.sh, this will result in a "command not found" error because
the source file has already been deleted from the file system. Move the cleanup of
the utility script to the very end of the function to ensure all helper functions
remain available.

kInit.sh [233-242]

 clean() {
+    updateProgress "Installation complete" 100
+    finalizeDebugLog
+
     remove "kInit.vars"
-    remove "utils.sh"
     remove "checksums.sha256"
     remove "$currentMe"
-
-    updateProgress "Installation complete" 100
-
-    finalizeDebugLog
+    remove "utils.sh"
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion addresses a likely execution error. If finalizeDebugLog is defined in utils.sh, calling it after remove "utils.sh" will fail. Even if the script is already loaded in memory, deleting the file before the process finishes is risky and bad practice. Moving the removal of dependencies to the end is a safer approach.

Medium
General
Ensure package cache is updated

The removal of noOut apt update before installing $ZABBIX_AGENT2_PACKAGE may cause
the installation to fail if the package repository metadata is stale or if the
package was recently added to the repository. While removing it decreases runtime,
it is safer to ensure the package cache is current when installing named packages
from a repository. Consider keeping the update or ensuring it was run recently in
the execution flow.

installer/software/software.sh [146]

+noOut apt update
 if ! installPackage "$ZABBIX_AGENT2_PACKAGE"; then
Suggestion importance[1-10]: 5

__

Why: Removing apt update can lead to installation failures if the local package index is outdated. While it saves time, it reduces the robustness of the installer when fetching packages from remote repositories.

Low
## PR Code Suggestions ✨ <!-- f4d9ef7 --> Explore these optional code suggestions: <table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>Possible issue</td> <td> <details><summary>Fix potential command not found error</summary> ___ **The <code>finalizeDebugLog</code> function is called after <code>remove "utils.sh"</code>. If <code>finalizeDebugLog</code> <br>is defined within <code>utils.sh</code>, this will result in a "command not found" error because <br>the source file has already been deleted from the file system. Move the cleanup of <br>the utility script to the very end of the function to ensure all helper functions <br>remain available.** [kInit.sh [233-242]](https://git.kleb.sh/kleb/kInit/src/branch/performance/kInit.sh#L233-L242) ```diff clean() { + updateProgress "Installation complete" 100 + finalizeDebugLog + remove "kInit.vars" - remove "utils.sh" remove "checksums.sha256" remove "$currentMe" - - updateProgress "Installation complete" 100 - - finalizeDebugLog + remove "utils.sh" } ``` <details><summary>Suggestion importance[1-10]: 8</summary> __ Why: The suggestion addresses a likely execution error. If `finalizeDebugLog` is defined in `utils.sh`, calling it after `remove "utils.sh"` will fail. Even if the script is already loaded in memory, deleting the file before the process finishes is risky and bad practice. Moving the removal of dependencies to the end is a safer approach. </details></details></td><td align=center>Medium </td></tr><tr><td rowspan=1>General</td> <td> <details><summary>Ensure package cache is updated</summary> ___ **The removal of <code>noOut apt update</code> before installing <code>$ZABBIX_AGENT2_PACKAGE</code> may cause <br>the installation to fail if the package repository metadata is stale or if the <br>package was recently added to the repository. While removing it decreases runtime, <br>it is safer to ensure the package cache is current when installing named packages <br>from a repository. Consider keeping the update or ensuring it was run recently in <br>the execution flow.** [installer/software/software.sh [146]](https://git.kleb.sh/kleb/kInit/src/branch/performance/installer/software/software.sh#L146-L146) ```diff +noOut apt update if ! installPackage "$ZABBIX_AGENT2_PACKAGE"; then ``` <details><summary>Suggestion importance[1-10]: 5</summary> __ Why: Removing `apt update` can lead to installation failures if the local package index is outdated. While it saves time, it reduces the robustness of the installer when fetching packages from remote repositories. </details></details></td><td align=center>Low </td></tr></tr></tbody></table>
Author
Owner

/review

/review
Collaborator

Persistent review updated to latest commit f4d9ef702d

**[Persistent review](https://git.kleb.sh/kleb/kInit/pulls/18#issuecomment-165)** updated to latest commit https://git.kleb.sh/kleb/kInit/commit/f4d9ef702d5a3d7bbfcd0042afb28ea7f398aa0b
kleb merged commit 943012313e into main 2025-12-29 08:37:16 +01:00
kleb deleted branch performance 2025-12-29 08:37:17 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kleb/kInit!18
No description provided.