Skip to content

Improve robustness on terraform log regex matching#1098

Merged
liyu-ma merged 3 commits intomainfrom
maliyu/terraform-metatada-fix
Mar 18, 2026
Merged

Improve robustness on terraform log regex matching#1098
liyu-ma merged 3 commits intomainfrom
maliyu/terraform-metatada-fix

Conversation

@liyu-ma
Copy link
Contributor

@liyu-ma liyu-ma commented Mar 16, 2026

Changes

  1. Fixed the elapsed-time parsing regex pattern
    ELAPSED_PATTERN used in terraform log extraction does not accommodate the log line pattern where resource id was included. Fixed this so terraform destroy command failure can be collected successfully.
  2. Provide a record with 0 second elapsed time
    This fixes the case where the terraform command failed before it logs any time elaspsed
  3. Improve flakiness in resource group deletion
    It is observed that resource group deletion could encounter a timeout of 10 mins from ARM side (not adjustable from client side) which can fail the pipeline run, despite the RG could be deleted successfully later. Change the deletion call to be async with --no-wait flag, and poll the resource group with specified wait time (20 mins). If RG was not deleted after 20 mins, fail the pipeline run.

Copilot AI review requested due to automatic review settings March 16, 2026 12:59
@liyu-ma liyu-ma requested a review from wonderyl as a code owner March 16, 2026 12:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves Terraform log parsing robustness in extract_terraform_operation_metadata.py, expanding elapsed-time regex matching (notably for terraform destroy) and emitting a default 0s duration for failures where no elapsed time was captured.

Changes:

  • Relax ELAPSED_PATTERN to match elapsed durations even when an id=... prefix is present in “Still creating/destroying” lines.
  • Emit failure records with time_taken_seconds=0 when a run ends (or is superseded) without any captured elapsed duration.
  • Extend unit tests to cover destroy logs with id= prefixes and failures/timeouts without elapsed lines.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
modules/python/terraform/extract_terraform_operation_metadata.py Updates elapsed regex and changes incomplete-run flushing behavior to default missing durations to 0s.
modules/python/tests/test_extract_terraform_operation_metadata.py Fixes malformed test log lines and adds new tests for destroy id= prefixes and no-elapsed failure/timeout scenarios.

@liyu-ma liyu-ma force-pushed the maliyu/terraform-metatada-fix branch from 22c9f2e to 895a980 Compare March 16, 2026 13:19
@liyu-ma liyu-ma merged commit f8fb283 into main Mar 18, 2026
3 checks passed
@liyu-ma liyu-ma deleted the maliyu/terraform-metatada-fix branch March 18, 2026 01:22

echo "Delete resource group $RUN_ID"
az group delete --name $RUN_ID --yes
az group delete --name $RUN_ID --yes --no-wait
Copy link
Collaborator

Choose a reason for hiding this comment

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

would this make our pipeline more flaky?

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.

5 participants