-
Notifications
You must be signed in to change notification settings - Fork 15
Add explicit context checking for belt-and-suspenders safety in tenant isolation policy polling #801
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>
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 improves the tenant isolation policy polling function by adding an explicit context check before entering the sleep period to ensure immediate cancellation response. Key changes include:
- Inserting a select block to check for context cancellation before invoking SleepWithContext.
- Updating the function documentation to mention that context cancellation is explicitly handled during sleep.
- Preserving existing functionality while enhancing safety.
internal/services/tenant_isolation_policy/api_tenant_isolation_policy.go
Show resolved
Hide resolved
@copilot you need to create a changelog using changie |
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
internal/services/tenant_isolation_policy/api_tenant_isolation_policy.go
Outdated
Show resolved
Hide resolved
Co-authored-by: mattdot <266258+mattdot@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
internal/services/tenant_isolation_policy/api_tenant_isolation_policy.go
Show resolved
Hide resolved
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
This PR addresses a potential issue with context-insensitive sleep logic in the tenant isolation policy polling function by adding explicit context checking for belt-and-suspenders safety.
Problem
While the underlying
SleepWithContext
implementation already correctly honors context cancellation, the polling logic indoWaitForLifecycleOperationStatus
could benefit from explicit context checking before entering the sleep period to ensure immediate exit on context cancellation and prevent potential resource usage or delayed termination under heavy load or shutdown scenarios.Changes
select
statement with<-ctx.Done()
case before callingSleepWithContext
in the polling loop for additional safetyCode Changes
Validation
SleepWithContext
tests continue to passThis fix provides belt-and-suspenders safety by adding an explicit context check while maintaining all existing behavior and leveraging the already-correct context handling in
SleepWithContext
.Fixes #800.
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:
checkpoint-api.hashicorp.com
/tmp/go-build952270432/b001/tenant_isolation_policy.test -test.testlogfile=/tmp/go-build952270432/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -test.run=TestUnit
(dns 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.