Skip to content
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

Return remediation measures for team membership deletion with EP dependencies #863

Merged

Conversation

imjaroiswebdev
Copy link
Contributor

@imjaroiswebdev imjaroiswebdev commented Apr 29, 2024

This update aims to address the error:

   "User cannot be removed as they belong to an escalation policy on this team"

which occurs when attempting to destroy a pagerduty_team_membership with Escalation Policy dependencies.

An automated workaround for addressing this API error was firstly introduced by #558 back in August 2022, and and improvement on how to collect the conflictive EPs was added by #918 just a couple of weeks ago.

However, this automated approach has started to cause issues on our backend, and the Engineering Team responsible for these APIs has requested that we revert this workaround.

As a result, we are retaining the logic to collect the conflicting Escalation Policies. However, you, as a Terraform Practitioner, will now need to manually apply the remediation measures before proceeding with the removal of the targeted pagerduty_team_membership.

Previously, the error related to Escalation Policies belonging to the Team was suppressed. Now, you will see an error message similar to the following:

  | Error: User "PEE179L" can't be removed from Team "P9UG8B6" as they belong to an Escalation Policy on this team.
  | Please take only one of the following remediation measures in order to unblock the Team Membership removal:
  |   1. Remove the user from the following Escalation Policies:
  |   * https://pdt-sandbox-foo.pagerduty.com/escalation_policies/PGNKF0K
  |   2. Remove the Escalation Policies from the Team https://pdt-sandbox-foo.pagerduty.com/teams/P9UG8B6
  | 
  | After completing one of the above given remediation options come back to continue with the destruction of Team Membership.

After completing one of the above remediation options, you can proceed with the destruction of the Team Membership.

We understand that this may represent a suboptimal solution as it removes automation in favor of adding manual tasks. However, we have maintained the automated approach as long as possible. For the sake of your PagerDuty configuration and our object relation consistency, we must take this step backward.

Nonetheless, this update improves upon the original state of the API error by providing more helpful information than just "User cannot be removed as they belong to an escalation policy on this team".

Side Note: This does not represent any changes to current pagerduty_team_membership API.

Acceptance tests results

TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -count=1 -run TestAccPagerDutyTeamMembership -timeout 120m
?       github.com/PagerDuty/terraform-provider-pagerduty       [no test files]
?       github.com/PagerDuty/terraform-provider-pagerduty/util/apiutil  [no test files]
=== RUN   TestAccPagerDutyTeamMembership_import
--- PASS: TestAccPagerDutyTeamMembership_import (13.48s)
=== RUN   TestAccPagerDutyTeamMembership_importWithRole
--- PASS: TestAccPagerDutyTeamMembership_importWithRole (13.82s)
=== RUN   TestAccPagerDutyTeamMembership_Basic
--- PASS: TestAccPagerDutyTeamMembership_Basic (12.02s)
=== RUN   TestAccPagerDutyTeamMembership_WithRole
--- PASS: TestAccPagerDutyTeamMembership_WithRole (11.99s)
=== RUN   TestAccPagerDutyTeamMembership_WithRoleConsistentlyAssigned
--- PASS: TestAccPagerDutyTeamMembership_WithRoleConsistentlyAssigned (19.47s)
=== RUN   TestAccPagerDutyTeamMembership_DestroyWithEscalationPolicyDependant # 👈 Updated to cover new implementation and protect from regressions.
--- PASS: TestAccPagerDutyTeamMembership_DestroyWithEscalationPolicyDependant (35.74s)
=== RUN   TestAccPagerDutyTeamMembership_DestroyWithEscalationPolicyDependantAndMultipleTeams # 👈 Updated to cover new implementation and protect from regressions.
--- PASS: TestAccPagerDutyTeamMembership_DestroyWithEscalationPolicyDependantAndMultipleTeams (38.77s)
PASS
ok      github.com/PagerDuty/terraform-provider-pagerduty/pagerduty     145.792s
testing: warning: no tests to run
PASS
ok      github.com/PagerDuty/terraform-provider-pagerduty/pagerdutyplugin       1.120s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/PagerDuty/terraform-provider-pagerduty/util  0.719s [no tests to run]

@imjaroiswebdev imjaroiswebdev force-pushed the issue-709-err-removing-user branch from 147daa9 to 93f2cde Compare August 23, 2024 14:42
@atlantisduty
Copy link

atlantisduty bot commented Aug 23, 2024

Atlantis commands can't be run on fork pull requests. To enable, set --allow-fork-prs or, to disable this message, set --silence-fork-pr-errors

@atlantisduty
Copy link

atlantisduty bot commented Aug 23, 2024

Error parsing command: EOF found when expecting closing quote

@imjaroiswebdev imjaroiswebdev marked this pull request as ready for review August 23, 2024 15:43
@atlantisduty
Copy link

atlantisduty bot commented Aug 23, 2024

Atlantis commands can't be run on fork pull requests. To enable, set --allow-fork-prs or, to disable this message, set --silence-fork-pr-errors

@atlantisduty
Copy link

atlantisduty bot commented Aug 23, 2024

Error parsing command: EOF found when expecting closing quote

@imjaroiswebdev imjaroiswebdev merged commit 95bc6c1 into PagerDuty:master Aug 23, 2024
1 check passed
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.

1 participant