Open msa21 opened 2 years ago
We've also run into this as well.
terraform -v
Terraform v1.1.6
on linux_amd64
...
+ provider registry.terraform.io/pagerduty/pagerduty v2.3.0
After the maintenance window has passed it can no longer be updated or destroyed:
Update error:
│ Error: PUT API call to https://api.pagerduty.com/maintenance_windows/ABCDEFG failed 400 Bad Request. Code: 2001, Errors: [Start time cannot be modified for maintenance windows that have already started End time already passed and can not be modified], Message: Invalid Input Provided
Destroy error:
│ Error: DELETE API call to https://api.pagerduty.com/maintenance_windows/ABCDEFG failed 405 Method Not Allowed. Code: 5003, Errors: <nil>, Message: Cannot cancel a maintenance window from the past
I may be running into this as well. I am using Terraform 1.0.11 on CentOS 7 x86_64 with version 2.3.0 of the PagerDuty provider.
I successfully created maintenance windows for a couple of services. I am providing what source code that I can, trying to highlight only the most relevant portions. Timestamps turn out to be important to this report. Names have been changed to protect the innocent. 😇
In main.tf
:
module "pagerduty_critical" {
source = "/path/to/xxx-pagerduty"
/* some settings omitted... */
maint_window_start = var.pagerduty_maint_window_start
maint_window_end = var.pagerduty_maint_window_end
}
In variables.tf
:
variable "pagerduty_maint_window_end" {
/* ... description omitted ... */
type = string
default = "2022-04-10T23:59:59-04:00"
/* ... validation omitted ... */
}
variable "pagerduty_maint_window_start" {
/* ... description omitted ... */
type = string
default = "2022-03-01T00:00:00-05:00"
/* ... validation omitted ... */
}
In xxx-pagerduty/variables.tf
:
variable "maint_window_end" {
/* ... description omitted ... */
type = string
default = ""
/* ... validation omitted ... */
}
variable "maint_window_start" {
/* ... description omitted ... */
type = string
default = ""
/* ... validation omitted ... */
}
In xxx-pagerduty/main.tf
:
resource "pagerduty_service" "this" {
/* redacted */
}
locals {
needs_maint_window = (var.maint_window_end != "") && (var.maint_window_start != "")
}
resource "pagerduty_maintenance_window" "this" {
count = local.needs_maint_window ? 1 : 0
end_time = var.maint_window_end
services = [pagerduty_service.this.id]
start_time = var.maint_window_start
}
Ran it in a pipeline successfully once:
2022-03-02T17:53:00.2534529Z module.pagerduty_critical.pagerduty_maintenance_window.this[0]: Creating...
2022-03-02T17:53:00.9876954Z module.pagerduty_critical.pagerduty_maintenance_window.this[0]: Creation complete after 1s [id=PXXXXXX]
Ran the same pipeline again, a few minutes later, with no changes to the Terraform files, but it failed:
2022-03-02T17:57:58.6478660Z module.pagerduty_critical.pagerduty_maintenance_window.this[0]: Modifying... [id=PXXXXXX]
2022-03-02T17:57:59.5280232Z
2022-03-02T17:57:59.5286122Z Error: PUT API call to https://api.pagerduty.com/maintenance_windows/PXXXXXX failed 400 Bad Request. Code: 2001, Errors: [Start time cannot be modified for maintenance windows that have already started], Message: Invalid Input Provided
2022-03-02T17:57:59.5288907Z
2022-03-02T17:57:59.5290452Z with module.pagerduty_critical.pagerduty_maintenance_window.this[0],
2022-03-02T17:57:59.5292373Z on /path/to/xxx-pagerduty/main.tf line 20, in resource "pagerduty_maintenance_window" "this":
2022-03-02T17:57:59.5294149Z 20: resource "pagerduty_maintenance_window" "this"
2022-03-02T17:57:59.5295548Z
If I had to guess, the provider is not correctly detecting when an update is not needed.
I can't conclusively prove that nobody updated our PagerDuty instance during those approximately 5 minutes between runs. Given the size of our operation and how many people I believe are looking at it, I doubt that there was any interaction with the particular maintenance window on the particular service during that interval.
Another error that makes this problematic is that all windows from the past get an "End time cannot be before now". That causes projects that had maintenance windows in the past to crash.
We are having the same problem as well. This is the definition of the resource:
And this is the error:
until recently, i was able to go in the UI and manually apply the updates that terraform was failing to apply, which was annoying but sufficed to keep our applies successful. however, even that seems to have regressed sometime in the last week or two -- now when i go to edit an in-progress maintenance window in the UI, add a new service, and hit save, nothing happens. the browser console reveals a 400 from https://lightstephq.pagerduty.com/api/v1/maintenance_windows/{ID}
with the error message Maintenance window Only future maintenance windows are allowed
so as far as i know, there is now no workaround for this issue
Terraform version we are using
terraform -v Terraform v0.12.24
Error: DELETE API call to https://api.pagerduty.com/maintenance_windows/P7IXWS5 failed 405 Method Not Allowed. Code: 5003, Errors:, Message: Cannot cancel a maintenance window from the past
We are trying to remove the maintenance window while it is not expired but it is still giving the same error .