Skip to content

refactor/agent spinup scripts#1533

Merged
pranalidhanavade merged 4 commits intomainfrom
refactor/agent-spinup-scripts
Dec 5, 2025
Merged

refactor/agent spinup scripts#1533
pranalidhanavade merged 4 commits intomainfrom
refactor/agent-spinup-scripts

Conversation

@KambleSahil3
Copy link
Copy Markdown
Contributor

@KambleSahil3 KambleSahil3 commented Dec 5, 2025

What ?

  • refactor: agent-spinup-scripts create endpoints directory

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved agent provisioning reliability by ensuring required directories are created before writing endpoint configurations.
    • Enhanced deployment robustness by extending retry thresholds during service initialization.
  • Improvements

    • Streamlined agent configuration generation for more efficient provisioning workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: sahil.kamble@ayanworks.com <sahil.kamble@ayanworks.com>
Signed-off-by: sahil.kamble@ayanworks.com <sahil.kamble@ayanworks.com>
Signed-off-by: sahil.kamble@ayanworks.com <sahil.kamble@ayanworks.com>
Signed-off-by: sahil.kamble@ayanworks.com <sahil.kamble@ayanworks.com>
@KambleSahil3 KambleSahil3 self-assigned this Dec 5, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 5, 2025

Walkthrough

Four AFJ deployment scripts are updated to create the endpoints directory before writing files, increasing timeout thresholds from 6 to 20 iterations, and removing task ID extraction logic in favor of simplified endpoint JSON generation.

Changes

Cohort / File(s) Summary
Directory creation guard
apps/agent-provisioning/AFJ/scripts/docker_start_agent.sh, start_agent.sh, fargate.sh, start_agent_ecs.sh
Add mkdir -p to create endpoints directory before writing ENDPOINT/agent config JSON files, preventing write failures when directory is missing
Timeout and task ID logic
apps/agent-provisioning/AFJ/scripts/fargate.sh, start_agent_ecs.sh
Increase retry/wait loop threshold from 6 to 20 iterations; remove task ID extraction from service description events; simplify agent config generation to write minimal endpoint JSON instead of full configuration

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Consistent pattern of improvements across multiple files reduces cognitive load
  • Directory creation changes are straightforward safeguards
  • Timeout adjustments and task ID removal logic changes are minor compared to overall script complexity
  • Consider reviewing timeout implications and ensuring simplified JSON structure contains all necessary fields for downstream processes

Poem

🐰 Four scripts now stand guard with care,
Creating paths both safe and fair,
Timeouts stretch from six to twenty,
Endpoints flow with logic plenty,
Endpoints directory blooms with ease! 🌱

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'refactor/agent spinup scripts' is partially related to the changeset. It describes the general refactoring activity but lacks specificity about the main change (adding directory creation guards for endpoints). Consider a more specific title like 'Add endpoints directory creation guards to agent spinup scripts' to clearly convey the primary change and improve clarity.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/agent-spinup-scripts

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

@pranalidhanavade pranalidhanavade left a comment

Choose a reason for hiding this comment

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

LG

Copy link
Copy Markdown

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
apps/agent-provisioning/AFJ/scripts/docker_start_agent.sh (2)

229-241: Critical: Path mismatch between mkdir and file write location.

Line 229 sets ENDPOINT="${PWD}/endpoints/..." but line 236 creates the directory at ${PWD}/agent-provisioning/AFJ/endpoints. The file write on line 237 will fail because the parent directory doesn't exist at the location where ENDPOINT points.

Fix the path inconsistency:

- ENDPOINT="${PWD}/endpoints/${AGENCY}_${CONTAINER_NAME}.json"
+ ENDPOINT="${PWD}/agent-provisioning/AFJ/endpoints/${AGENCY}_${CONTAINER_NAME}.json"

Alternatively, update line 236 to match the ENDPOINT variable (though the longer path is consistent with other scripts in the PR).


92-104: Misleading log messages for directory creation.

The error messages are identical for both the endpoints and agent-config directory checks (lines 92-104). Additionally, line 100 refers to "Endpoints directory" when checking the agent-config directory. This creates confusion during debugging.

Improve clarity:

  if [ -d "${PWD}/agent-provisioning/AFJ/endpoints" ]; then
    echo "Endpoints directory exists."
  else
    echo "Error: Endpoints directory does not exist. Creating..."
-   mkdir -p ${PWD}/agent-provisioning/AFJ/endpoints
+   mkdir -p "${PWD}/agent-provisioning/AFJ/endpoints"
  fi
  
  if [ -d "${PWD}/agent-provisioning/AFJ/agent-config" ]; then
-   echo "Endpoints directory exists."
+   echo "Agent config directory exists."
  else
-   echo "Error: Endpoints directory does not exists."
-   mkdir -p ${PWD}/agent-provisioning/AFJ/agent-config
+   echo "Error: Agent config directory does not exist. Creating..."
+   mkdir -p "${PWD}/agent-provisioning/AFJ/agent-config"
  fi

Also note: using mkdir -p means the error case never actually errors—consider whether this is the intended behavior.

apps/agent-provisioning/AFJ/scripts/start_agent.sh (1)

230-244: Critical: Path mismatch between mkdir and file write location.

Line 232 sets ENDPOINT="${PWD}/endpoints/..." but line 239 creates the directory at ${PWD}/agent-provisioning/AFJ/endpoints. The file write on line 240 will fail because the parent directory doesn't exist at the location where ENDPOINT points.

Fix the path inconsistency:

- ENDPOINT="${PWD}/endpoints/${AGENCY}_${CONTAINER_NAME}.json"
+ ENDPOINT="${PWD}/agent-provisioning/AFJ/endpoints/${AGENCY}_${CONTAINER_NAME}.json"

This aligns with the directory created on line 239 and matches the pattern in fargate.sh and start_agent_ecs.sh.

apps/agent-provisioning/AFJ/scripts/fargate.sh (1)

9-9: Syntax error in parameter assignment.

Line 9 contains an invalid assignment: RANDOM_SEED=$5a should be RANDOM_SEED=$5. The trailing "a" breaks the variable binding.

- RANDOM_SEED=$5a
+ RANDOM_SEED=$5
🧹 Nitpick comments (1)
apps/agent-provisioning/AFJ/scripts/start_agent.sh (1)

231-231: Consider removing unused endpoint file logic.

The inline comment on line 231 acknowledges that the endpoint file "is not actually being read." If true, the entire endpoint generation block (lines 231–244) could be removed to reduce maintenance burden.

Would you like me to help identify and remove unused endpoint file generation logic across all scripts in this PR?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d4c782 and bcb2e13.

📒 Files selected for processing (4)
  • apps/agent-provisioning/AFJ/scripts/docker_start_agent.sh (1 hunks)
  • apps/agent-provisioning/AFJ/scripts/fargate.sh (2 hunks)
  • apps/agent-provisioning/AFJ/scripts/start_agent.sh (1 hunks)
  • apps/agent-provisioning/AFJ/scripts/start_agent_ecs.sh (2 hunks)
🔇 Additional comments (3)
apps/agent-provisioning/AFJ/scripts/fargate.sh (2)

315-336: Verify intent of timeout threshold increase.

Line 318 increases the agent readiness check loop from 6 to 20 iterations (60s → 200s maximum wait). This change appears consistent across ECS deployment scripts but extends startup duration significantly.

Please confirm:

  • Was this change driven by observed agent startup delays in testing?
  • Is a 3.3x increase in timeout acceptable for deployment SLAs?
  • Should this be configurable as a parameter?

342-348: Endpoint directory creation is correctly implemented.

The path handling is consistent: directory creation (line 343) and file write (line 344) both reference ${PWD}/agent-provisioning/AFJ/endpoints. This pattern should be matched in the other scripts.

apps/agent-provisioning/AFJ/scripts/start_agent_ecs.sh (1)

328-334: Endpoint directory and file handling is correctly implemented.

The path handling is consistent: directory creation (line 329) and file write (line 330) both reference ${PWD}/agent-provisioning/AFJ/endpoints. The pattern matches fargate.sh.

@pranalidhanavade pranalidhanavade merged commit 86f1e7a into main Dec 5, 2025
8 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Apr 15, 2026
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.

2 participants