8000 Enhance versions_map generator logic by kvaps · Pull Request #741 · cozystack/cozystack · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enhance versions_map generator logic #741

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

Merged
merged 2 commits into from
Apr 2, 2025
Merged

Enhance versions_map generator logic #741

merged 2 commits into from
Apr 2, 2025

Conversation

kvaps
Copy link
Member
@kvaps kvaps commented Apr 2, 2025

Summary by CodeRabbit

  • Chores
    • Enhanced version mapping with improved error reporting and clearer version resolution, ensuring more accurate and reliable version displays.
    • Updated version references for multiple packages to maintain consistency and stability across the system.

8000 @kvaps kvaps requested a review from lllamnyp as a code owner April 2, 2025 19:31
Copy link
Contributor
coderabbitai bot commented Apr 2, 2025

Walkthrough

This pull request updates the commit validation logic in the hack/gen_versions_map.sh script by refining the checks for the commit variable and improving error handling. Additionally, it systematically updates commit hashes for various package versions in the packages/apps/versions_map and packages/extra/versions_map files without changing the overall structure of the version maps.

Changes

File(s) Change Summary
hack/gen_versions_map.sh Improved commit validation and error handling. Refined logic to check if commit is HEAD or a specific commit, added validation against Chart.yaml, introduced a search mechanism through tags, and updated array variable names.
packages/apps/versions_map
packages/extra/versions_map
Updated commit hashes for multiple package versions (e.g., clickhouse, ferretdb, kafka, etc., in apps; bootbox, etcd, ingress, monitoring, seaweedfs in extra). The changes systematically replace old commit hashes with new ones.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Script
    participant ChartYAML as Chart.yaml
    participant Tags

    User->>Script: Run `gen_versions_map.sh` with commit value
    alt Commit is not HEAD
        Script->>ChartYAML: Validate commit against expected version
        alt Commit valid
            Script->>User: Output version map
        else Commit invalid
            Script->>User: Print error and exit
        end
    else Commit is HEAD
        Script->>ChartYAML: Check for version presence
        alt Version found in Chart.yaml
            Script->>User: Output version map
        else Version missing
            Script->>Tags: Search for valid commit matching version
            alt Valid commit found
                Script->>User: Output version map
            else No valid commit found
                Script->>User: Print error and exit
            end
        end
    end
Loading

Suggested reviewers

  • lllamnyp

Poem

I'm a bunny hopping through the code, so spry,
Nibbling on errors as they scurry by,
With maps refreshed and commits aligned,
I twitch my nose as each fix is designed,
Leaping joyfully into our updated sky!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kvaps kvaps changed the title fix versions Enhance versions_map generator logic Apr 2, 2025
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
packages/apps/versions_map (1)

2-157: 💡 Verification agent

🧩 Analysis chain

Comprehensive update of commit references for application packages

The changes systematically update commit hashes for numerous application packages including clickhouse, ferretdb, http-cache, kafka, kubernetes, mysql, nats, postgres, rabbitmq, redis, tcp-balancer, tenant, virtual-machine, vm-disk, vm-instance, and vpn.

This is a well-structured update that ensures consistent version tracking across all application packages.


🏁 Script executed:

#!/bin/bash
# Verify a sample of the updated commit hashes to ensure they exist
# and have the correct Chart.yaml version

# Sample verification for kubernetes package
echo "Checking kubernetes 0.15.2 (8267072d)..."
if git show 8267072d:./kubernetes/Chart.yaml 2>/dev/null | grep -q "^version: 0.15.2$"; then
  echo "✓ kubernetes 0.15.2 verified"
else
  echo "✗ kubernetes 0.15.2 not verified"
fi

# Sample verification for virtual-machine package
echo "Checking virtual-machine 0.7.1 (0ab39f20)..."
if git show 0ab39f20:./virtual-machine/Chart.yaml 2>/dev/null | grep -q "^version: 0.7.1$"; then
  echo "✓ virtual-machine 0.7.1 verified"
else
  echo "✗ virtual-machine 0.7.1 not verified"
fi

# Check if there are any duplicate entries that should be consolidated
echo "Checking for duplicate package-version combinations..."
sort packages/apps/versions_map | uniq -d -c

Length of output: 665


Action Required: Resolve Inconsistent Commit References in versions_map

During verification, the following discrepancies were identified:

  • kubernetes (v0.15.2 / commit 8267072): The Chart.yaml file does not reflect the expected version string (version: 0.15.2).
  • virtual-machine (v0.7.1 / commit 0ab39f2): The Chart.yaml file does not contain the expected version (version: 0.7.1).

Please review and update either the commit hashes in packages/apps/versions_map or the corresponding version strings in the Chart.yaml files to ensure consistency in version tracking across packages.

🛑 Comments failed to post (1)
packages/extra/versions_map (1)

1-42: 💡 Verification agent

🧩 Analysis chain

Consistent update of commit hashes for package versions

The systematic update of commit hashes for bootbox, etcd, ingress, monitoring, and seaweedfs packages ensures that each version points to the correct commit. This aligns with the improved validation logic in the gen_versions_map.sh script.

These changes don't alter the version numbers themselves, just the commit references, indicating this is likely a maintenance update to ensure accurate version tracking.


🏁 Script executed:

#!/bin/bash
# Verify that the updated commit hashes actually exist in the repository
# and have the expected Chart.yaml version for a sample of packages

# Check for bootbox 0.1.0
echo "Checking bootbox 0.1.0 (45a7416c)..."
if git show 45a7416c:./bootbox/Chart.yaml 2>/dev/null | grep -q "^version: 0.1.0$"; then
  echo "✓ bootbox 0.1.0 verified"
else
  echo "✗ bootbox 0.1.0 not verified"
fi

# Check for etcd 2.6.0
echo "Checking etcd 2.6.0 (8c460528)..."
if git show 8c460528:./etcd/Chart.yaml 2>/dev/null | grep -q "^version: 2.6.0$"; then
  echo "✓ etcd 2.6.0 verified"
else
  echo "✗ etcd 2.6.0 not verified"
fi

# Check for monitoring 1.9.0
echo "Checking monitoring 1.9.0 (45a7416c)..."
if git show 45a7416c:./monitoring/Chart.yaml 2>/dev/null | grep -q "^version: 1.9.0$"; then
  echo "✓ monitoring 1.9.0 verified"
else
  echo "✗ monitoring 1.9.0 not verified"
fi

Length of output: 659


Action Required: Correct Commit Hash Mappings for Package Versions

The verification script indicates that the commit hashes for several packages do not match the expected version strings in their respective Chart.yaml files:

  • bootbox 0.1.0 (45a7416): Expected version: 0.1.0 was not found.
  • etcd 2.6.0 (8c46052): Expected version: 2.6.0 was not verified.
  • monitoring 1.9.0 (45a7416): Expected version: 1.9.0 is missing in the commit.
  • 8000

Please revisit these commit references to ensure they point to commits with the correct Chart.yaml version definitions, and update the versions map accordingly if necessary.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
hack/gen_versions_map.sh (4)

10-10: AWK Extraction Logic for Chart Data

The AWK command extracting the chart name and version (defaulting the commit to "HEAD") is concise and works for simple YAML files. However, note that it assumes a very specific format for Chart.yaml (with keys starting at the beginning of the line and exactly one token following).


19-19: Missing Mapping Calculation

The use of AWK here to build an associative array (nm) and then compare the new mappings against the existing file is clever and succinct. It correctly identifies mappings that differ.
Consider adding an inline comment to explain the logic for future maintainability, and ensure that the format of both inputs remains consistent.


21-24: Tag Retrieval and Commit Search Enhancement

The new block that retrieves tags (via git ls-remote) and appends the latest main commit is a solid enhancement. Please verify that your filtering pattern (refs/tags/v) and sorting (sort -k2,2 -rV) meet all expected tag-naming conventions in your repository. If tags might deviate from the expected format, consider whether additional filtering or error handling is needed.


35-36: Shell Variable Quoting in Conditional Check

In the condition checking if commit is not "HEAD", the variable is unquoted. This can lead to word splitting or globbing issues if the variable ever contains spaces or special characters.
Please change it to:

-if [ $commit != "HEAD" ]; then
+if [ "$commit" != "HEAD" ]; then
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8fef79a and 84cd85e.

📒 Files selected for processing (3)
  • hack/gen_versions_map.sh (2 hunks)
  • packages/apps/versions_map (1 hunks)
  • packages/extra/versions_map (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/extra/versions_map
  • packages/apps/versions_map
🔇 Additional comments (1)
hack/gen_versions_map.sh (1)

64-64: Final Map Output

The final output construction using printf piped into sort and awk is neat and clearly sorts mappings by chart and version. The use of awk '$1' effectively filters out any blank lines. This segment looks good assuming consistent formatting of inputs.

fi
echo "$miss_map" | while read -r chart version commit; do
# if version is found in HEAD, it's HEAD
if grep -q "^version: $version$" ./${chart}/Chart.yaml; then
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

Grep Pattern Robustness

The grep usage to match the version in Chart.yaml (e.g.,

grep -q "^version: $version$" ./${chart}/Chart.yaml

) works under the assumption that the version string contains no regex metacharacters. To avoid potential issues, consider using fixed-st 8000 ring matching with grep -F or properly quoting/escaping the variable.


Grep Pattern Robustness: Ensure Fixed-String Matching
At hack/gen_versions_map.sh:29, the current grep command:

if grep -q "^version: $version$" ./${chart}/Chart.yaml; then

assumes that the $version variable contains no regex metacharacters. This can lead to potential mismatches (for instance, dots in version numbers being interpreted as any character). To mitigate this risk, please refactor the code to either:

  • Use fixed-string matching by adding the -F flag (e.g., grep -F -q), or
  • Escape the $version variable appropriately before incorporating it into the regex.

# if commit is HEAD, but version is not found in HEAD, check all tags
found_tag=""
for tag in $search_commits; do
if git show "${tag}:./${chart}/Chart.yaml" 2>/dev/null | grep -q "^version: $version$"; then
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

Consistent Grep Usage for Tag-based Lookup

Similarly, the grep command used when iterating over tags (line 49) should be reviewed for the same potential regex pitfalls. Changing it to a fixed-string search might increase robustness.


Update grep Invocation for Fixed-String Matching

  • File: hack/gen_versions_map.sh (line 49)
  • Issue: The current command
    if git show "${tag}:./${chart}/Chart.yaml" 2>/dev/null | grep -q "^version: $version$"; then
    uses a regex to match the version string. If the variable $version ever contains any regex metacharacters, this could lead to unintended behavior.
  • Suggestion: Replace the regex search with a fixed-string match. For instance, updating the line to:
    if git show "${tag}:./${chart}/Chart.yaml" 2>/dev/null | grep -F -x -q "version: $version"; then
    ensures that the content is compared exactly as a literal string, which increases robustness when matching tag-based version lookups.

@kvaps kvaps merged commit d971f2f into main Apr 2, 2025
3 of 4 checks passed
@kvaps kvaps deleted the fix-versions branch April 2, 2025 19:43
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.

1 participant
0