-
Notifications
You must be signed in to change notification settings - Fork 39
t1524: Fix aidevops update to detect and deploy stale agents #4001
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -721,7 +721,6 @@ cmd_update() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local new_version new_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| new_version=$(get_version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| new_hash=$(git rev-parse HEAD) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_success "Updated to version $new_version" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Print bounded summary of meaningful changes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$old_hash" != "$new_hash" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -741,12 +740,32 @@ cmd_update() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_info "Running setup to apply changes..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bash "$INSTALL_DIR/setup.sh" --non-interactive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local setup_exit=0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bash "$INSTALL_DIR/setup.sh" --non-interactive || setup_exit=$? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Safety net: discard any working tree changes setup.sh may have introduced | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # (e.g. chmod on tracked scripts, scan results written to repo) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # See: https://github.com/marcusquinn/aidevops/issues/2286 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git checkout -- . 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Verify deployment: compare repo VERSION with deployed agents VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This catches silent setup.sh failures (e.g., non-interactive mode in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # environments where setup.sh exits early without deploying agents) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # See: https://github.com/marcusquinn/aidevops/issues/3980 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local repo_version deployed_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repo_version=$(cat "$INSTALL_DIR/VERSION" 2>/dev/null || echo "unknown") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deployed_version=$(cat "$HOME/.aidevops/agents/VERSION" 2>/dev/null || echo "none") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$setup_exit" -ne 0 ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_warning "Setup exited with code $setup_exit" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$repo_version" != "$deployed_version" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_warning "Agent deployment incomplete: repo=$repo_version, deployed=$deployed_version" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_info "Run 'bash $INSTALL_DIR/setup.sh' manually to deploy agents" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_success "Updated to version $new_version (agents deployed)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+755
to
+768
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block has a logic flaw and a redundant variable.
I suggest refactoring this block to fix the logic and remove the redundancy.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_warning "Repository not found, performing fresh install..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command to get the deployed version,
cat "$HOME/.aidevops/agents/VERSION" 2>/dev/null || echo "none", is used three times within thecmd_checkfunction (here, on line 916, and on line 975). To improve maintainability and reduce duplication, consider defining a local helper function at the beginning ofcmd_checkand using it in all three places.References
sourcedependencies are avoided.