chore: update AMI pipeline instead of reusing older pipeline#1211
chore: update AMI pipeline instead of reusing older pipeline#1211
Conversation
Time Submission Status
|
WalkthroughThe AMI build workflow now always destroys the existing AMI pipeline stack and redeploys it, deriving PIPELINE_ARN from post-deploy outputs. The AMI pipeline stack’s embedded node configuration/update scripts were streamlined: argument parsing simplified, reconfiguration logic consolidated, service control tightened, and status messaging shortened. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant GH as GitHub Actions
participant CDK as AWS CDK
participant CFN as CloudFormation
participant Pipe as AMI Pipeline
Dev->>GH: Push / Dispatch AMI build
GH->>CDK: cdk destroy AMI-Pipeline-<stage>-Stack (ignore errors)
GH->>CDK: cdk bootstrap
GH->>CDK: cdk deploy AMI-Pipeline-<stage>-Stack
CDK->>CFN: Create/Update stack
CFN-->>CDK: Stack outputs (PIPELINE_ARN)
CDK-->>GH: PIPELINE_ARN
GH->>Pipe: Trigger AMI build using PIPELINE_ARN
Pipe-->>GH: Build started
sequenceDiagram
autonumber
actor User as AMI User
participant Cfg as tn-node-configure
participant Env as /opt/tn/.env
participant Svc as systemd (tn-node)
User->>Cfg: Run with args (--private-key, --network, --enable-mcp)
Cfg->>Env: Check if file exists
alt Reconfigure (Env exists)
Cfg->>Env: Read TN_PRIVATE_KEY, CHAIN_ID, NETWORK_TYPE
Cfg->>Cfg: Validate immutable changes (error if changed)
end
Cfg->>Svc: systemctl stop tn-node
Cfg->>Env: Write updated .env (preserve existing where needed)
Cfg->>Svc: daemon-reload, enable, start tn-node
Svc-->>User: Concise status output
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
deployments/infra/stacks/ami_pipeline_stack.go (2)
302-302: Improve IMDS compatibility (support IMDSv2, graceful fallback)Try IMDSv2 token first, then fall back; avoid failing under set -e.
- [ "$ENABLE_MCP" = true ] && echo "MCP: http://$(curl -s --max-time 2 http://169.254.169.254/latest/meta-data/public-ipv4 || echo localhost):8000/sse" + if [ "$ENABLE_MCP" = true ]; then + TOKEN=$(curl -s --max-time 2 -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 60" || true) + PUBIP=$(curl -s --max-time 2 -H "X-aws-ec2-metadata-token: $TOKEN" "http://169.254.169.254/latest/meta-data/public-ipv4" || true) + echo "MCP: http://${PUBIP:-localhost}:8000/sse" + fi
253-256: Add basic help flag for operator ergonomicsProvide a quick usage message and recognize -h/--help.
- --private-key) PRIVATE_KEY="$2"; shift 2;; - --enable-mcp) ENABLE_MCP=true; shift;; - --network) NETWORK="$2"; shift 2;; - *) echo "Unknown option"; exit 1;; + --private-key) PRIVATE_KEY="$2"; shift 2;; + --enable-mcp) ENABLE_MCP=true; shift;; + --network) NETWORK="$2"; shift 2;; + -h|--help) echo "Usage: tn-node-configure [--private-key <hex>] [--enable-mcp] [--network <id>]"; exit 0;; + *) echo "Unknown option: $1"; exit 1;;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/ami-build.yml(1 hunks)deployments/infra/stacks/ami_pipeline_stack.go(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: outerlook
PR: trufnetwork/node#1170
File: .github/workflows/ami-build.yml:75-75
Timestamp: 2025-09-22T18:35:49.536Z
Learning: In the trufnetwork/node repository, the CDK stack naming convention uses `WithStackSuffix()` which generates names in the format `<stackName>-<stackSuffix>-Stack`. The AMI pipeline stack uses `AMI-Pipeline-default-Stack` because no `stackSuffix` is set in the CDK context, so it defaults to "default".
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: acceptance-test
🔇 Additional comments (1)
.github/workflows/ami-build.yml (1)
83-108: Misidentified stack naming: pipeline stack uses explicit fmt.Sprintf with “stage” context
ami-cdk.go builds the stack name asAMI-Pipeline-${stage}-Stackvia--context stage, matching the workflow’s destroy/deploy/describe commands.Likely an incorrect or invalid review comment.
|
@outerlook if it not destroyed first. Then alternatively we need to update the version, but it is a chore to do |
Had to make this PR, since after I build again with the GH action, it didn't updated
resolves: https://github.com/trufnetwork/truf-network/issues/1251
Summary by CodeRabbit
Refactor
Chores