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

Refactor upgrade options and timeouts #24

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Refactor upgrade options and timeouts #24

merged 1 commit into from
Jan 15, 2025

Conversation

kvaps
Copy link
Member

@kvaps kvaps commented Jan 15, 2025

Signed-off-by: Andrei Kvapil [email protected]

Summary by CodeRabbit

  • New Features

    • Enhanced upgrade options with more granular control
    • Added new upgrade modes and force options
    • Expanded upgrade option menu from three to six choices
  • Improvements

    • Increased timeout duration for machine status checks
    • Refined upgrade command parameter handling
    • Improved error handling and control flow during upgrades

Copy link

coderabbitai bot commented Jan 15, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces significant modifications to the talos-bootstrap script, particularly in the upgrade option handling and the overall upgrade process. The upgrade option menu has been expanded from three to six choices, allowing for more specific configurations regarding how upgrades are applied. New parameters such as --reboot-mode and --force have been introduced, and the logic for determining upgrade options has been updated. Additionally, the timeout duration for checking machine status has been increased from 1 second to 3 seconds.

Changes

File Change Summary
talos-bootstrap - Expanded upgrade option menu from 3 to 6 choices
- Added new parameters --reboot-mode and --force
- Increased timeout for machine status checks from 1 to 3 seconds
- Restructured upgrade process logic and scheduling

Poem

🐰 Upgrade dance, six steps so bright,
Talos script leaps with newfound might!
Reboot and force, a bunny's delight,
Timeout stretching, systems take flight
Bootstrap magic, techno-rabbit's glee! 🚀


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a0e9d75 and 7f0c76e.

📒 Files selected for processing (1)
  • talos-bootstrap (4 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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 Refactor upgrade options Refactor upgrade options and timeouts Jan 15, 2025
Copy link

@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 (1)
talos-bootstrap (1)

Line range hint 470-492: Enhance error handling in status monitoring.

While the status monitoring has been improved with better timeouts and stage verification, the error handling could be enhanced.

Consider these improvements:

         status=$(timeout 3 talosctl --talosconfig=talosconfig -e "${node}" -n "${node}" get machinestatus ${OPTS} -o jsonpath={.spec.stage} 2>/dev/null)
         if [ $? = 124 ]; then
+          echo "Warning: Timeout while checking machine status" >&2
           old_is_up=0
         fi
         if [ "$status" = upgrading ] || [ "$status" = rebooting ]; then
+          echo "Info: Machine is in ${status} state" >&2
           continue
         fi
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f533c3c and a0e9d75.

📒 Files selected for processing (1)
  • talos-bootstrap (4 hunks)
🔇 Additional comments (1)
talos-bootstrap (1)

453-453: Verify upgrade command behavior with --wait=false.

The upgrade command is executed with --wait=false, which means it will return immediately. Ensure this is the intended behavior and won't cause issues with the subsequent status monitoring.

Run this script to check the documentation and usage of the --wait flag:

✅ Verification successful

The --wait=false flag usage is correct and properly implemented.

The upgrade command is intentionally non-blocking, as the script implements its own comprehensive status monitoring using machinestatus checks to track the upgrade progress through various stages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check documentation for the upgrade command's --wait flag
talosctl upgrade --help | grep -A 2 "\-\-wait"

Length of output: 147


Script:

#!/bin/bash
# Search for documentation files and examples related to upgrade command
fd -e md -e txt | xargs rg -l "upgrade.*wait" || true

# Search for specific mentions of wait flag in upgrade contexts
rg -i "upgrade.*--wait" -A 2 -B 2 || true

# Search for upgrade command usage patterns
rg "talosctl.*upgrade" -A 2 -B 2 || true

Length of output: 915


Script:

#!/bin/bash
# Look for status monitoring after upgrade
rg -A 10 "Scheduling upgrade" || true

# Check for any health checks or status monitoring patterns
rg "health|status|ready" talos-bootstrap || true

Length of output: 1168

talos-bootstrap Outdated
Comment on lines 427 to 434
upgrade_opt=""
case ${upgrade_option} in
1) preserve_opt="--preserve" ;;
2) preserve_opt="" ;;
3) should_upgrade="0" ;;
1) should_upgrade=0 ;;
3) upgrade_opt="--reboot-mode default" ;;
3) upgrade_opt="--reboot-mode powercycle" ;;
4) upgrade_opt="--force --reboot-mode default" ;;
4) upgrade_opt="--force --reboot-mode powercycle" ;;
6) upgrade_opt="--stage" ;;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix duplicate case numbers and incorrect mode assignments.

The case statement contains several critical issues:

  1. Duplicate case numbers (3 and 4) will cause unexpected behavior
  2. Incorrect reboot mode assignments

Apply this diff to fix the case statement:

   upgrade_opt=""
   case ${upgrade_option} in
      1) should_upgrade=0 ;;
-     3) upgrade_opt="--reboot-mode default" ;;
-     3) upgrade_opt="--reboot-mode powercycle" ;;
-     4) upgrade_opt="--force --reboot-mode default" ;;
-     4) upgrade_opt="--force --reboot-mode powercycle" ;;
+     2) upgrade_opt="--reboot-mode default" ;;
+     3) upgrade_opt="--reboot-mode powercycle" ;;
+     4) upgrade_opt="--force --reboot-mode default" ;;
+     5) upgrade_opt="--force --reboot-mode powercycle" ;;
      6) upgrade_opt="--stage" ;;
   esac
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
upgrade_opt=""
case ${upgrade_option} in
1) preserve_opt="--preserve" ;;
2) preserve_opt="" ;;
3) should_upgrade="0" ;;
1) should_upgrade=0 ;;
3) upgrade_opt="--reboot-mode default" ;;
3) upgrade_opt="--reboot-mode powercycle" ;;
4) upgrade_opt="--force --reboot-mode default" ;;
4) upgrade_opt="--force --reboot-mode powercycle" ;;
6) upgrade_opt="--stage" ;;
upgrade_opt=""
case ${upgrade_option} in
1) should_upgrade=0 ;;
2) upgrade_opt="--reboot-mode default" ;;
3) upgrade_opt="--reboot-mode powercycle" ;;
4) upgrade_opt="--force --reboot-mode default" ;;
5) upgrade_opt="--force --reboot-mode powercycle" ;;
6) upgrade_opt="--stage" ;;
esac

Comment on lines +419 to +424
1 "apply config on live and skip upgrade" \
2 "apply config and perform upgrade (mode: default)" \
3 "apply config and perform upgrade (mode: powercycle)" \
4 "apply config and perform upgrade with force (mode: default)" \
5 "apply config and perform upgrade with force (mode: powercycle)" \
6 "apply config and schedule upgrade to perform it after a reboot" 3>&1 1>&2 2>&3) || exit 0
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix misalignment between menu options and case handling.

The menu options (1-6) don't align with their corresponding case statements, which could lead to incorrect option handling.

Apply this diff to align the descriptions with their handling:

-    1 "apply config on live and skip upgrade" \
-    2 "apply config and perform upgrade (mode: default)" \
-    3 "apply config and perform upgrade (mode: powercycle)" \
-    4 "apply config and perform upgrade with force (mode: default)" \
-    5 "apply config and perform upgrade with force (mode: powercycle)" \
-    6 "apply config and schedule upgrade to perform it after a reboot" 3>&1 1>&2 2>&3) || exit 0
+    1 "Apply config on live and skip upgrade" \
+    2 "Apply config and perform upgrade" \
+    3 "Apply config and perform upgrade (powercycle mode)" \
+    4 "Apply config and perform forced upgrade" \
+    5 "Apply config and perform forced upgrade (powercycle mode)" \
+    6 "Apply config and schedule upgrade for next reboot" 3>&1 1>&2 2>&3) || exit 0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
1 "apply config on live and skip upgrade" \
2 "apply config and perform upgrade (mode: default)" \
3 "apply config and perform upgrade (mode: powercycle)" \
4 "apply config and perform upgrade with force (mode: default)" \
5 "apply config and perform upgrade with force (mode: powercycle)" \
6 "apply config and schedule upgrade to perform it after a reboot" 3>&1 1>&2 2>&3) || exit 0
1 "Apply config on live and skip upgrade" \
2 "Apply config and perform upgrade" \
3 "Apply config and perform upgrade (powercycle mode)" \
4 "Apply config and perform forced upgrade" \
5 "Apply config and perform forced upgrade (powercycle mode)" \
6 "Apply config and schedule upgrade for next reboot" 3>&1 1>&2 2>&3) || exit 0

Signed-off-by: Andrei Kvapil <[email protected]>
@kvaps kvaps merged commit 11778ca into master Jan 15, 2025
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