-
Notifications
You must be signed in to change notification settings - Fork 15
Fix infinite polling loop in environment wave feature installation #833
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
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.
Pull Request Overview
This PR prevents the infinite polling loop in UpdateFeature
by respecting the Terraform context deadline, improves error handling, and adds a unit test with fixtures to validate timeout behavior.
- Added context deadline check and descriptive timeout error in the polling loop
- Introduced
TestUnitEnvironmentWaveResource_Timeout
with new JSON fixtures - Updated changelog under
.changes/unreleased
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/services/environment_wave/api_environment_wave.go | Inserted select { case <-ctx.Done() } before each poll to enforce timeouts |
internal/services/environment_wave/resource_environment_wave_test.go | Added timeout unit test with HTTP mocks and expectations |
internal/services/environment_wave/test/resource/EnvironmentWaveResource_Timeout/get_organizations.json | New test fixture for organization list |
internal/services/environment_wave/test/resource/EnvironmentWaveResource_Timeout/get_features_upgrading.json | New test fixture for "Upgrading" feature state |
internal/services/environment_wave/test/resource/EnvironmentWaveResource_Timeout/get_features_enabled.json | New test fixture for "ON" feature state |
internal/services/environment_wave/test/resource/EnvironmentWaveResource_Timeout/get_environment_00000000-0000-0000-0000-000000000001.json | New test fixture for environment details |
.changes/unreleased/fixed-20250605-092958.yaml | Changelog entry for the fix |
Comments suppressed due to low confidence (2)
internal/services/environment_wave/resource_environment_wave_test.go:266
- The POST mock regex anchors on
$
but the client may append query parameters (e.g.,?api-version=...
). Update the pattern to allow an optional query string, e.g.enable(\\?.+)?$
.
httpmock.RegisterResponder("POST", `=~^https://api\\.admin\\.powerplatform\\.microsoft\\.com/api/environments/00000000-0000-0000-0000-000000000001/features/October2024Update/enable$`,
internal/services/environment_wave/resource_environment_wave_test.go:272
- The GET mock regex ends with
$
but the real request may include query parameters. Modify the pattern to accept optional query strings, e.g.features(\\?.+)?$
.
httpmock.RegisterResponder("GET", `=~^https://api\\.admin\\.powerplatform\\.microsoft\\.com/api/environments/00000000-0000-0000-0000-000000000001/features$`,
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
@copilot fix linter issues |
@copilot fix linter issues |
@copilot fix linter issues |
@copilot fix linter issues |
@copilot fix linter issues |
@copilot fix linter issues |
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
Issue
The polling loop in the
UpdateFeature
method of the environment wave service could run indefinitely without any timeout protection, creating a significant operational risk. If a wave feature installation never completed or got stuck in an "Upgrading" state, the Terraform provider would continue polling forever.Solution
Added context deadline checking to the existing polling loop to respect the timeout configuration already established by the Terraform framework. The fix leverages the existing timeout infrastructure rather than introducing new retry counters or hardcoded timeouts.
Changes Made
select
statement withctx.Done()
check in the polling loop to detect when the context deadline is exceededTestUnitEnvironmentWaveResource_Timeout
validates timeout behavior with a 1-second timeoutCode Example
Before (infinite loop risk):
After (timeout-protected):
Test Results
Impact
This change eliminates the risk of infinite loops while maintaining full compatibility with existing configurations. Users can control timeout behavior through the standard Terraform
timeouts
block (default: 20 minutes).Fixes #818.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
http://168.63.129.16:80/machine/
/usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs
(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.