PagerDuty / terraform-provider-pagerduty

Terraform PagerDuty provider
https://www.terraform.io/docs/providers/pagerduty/
Mozilla Public License 2.0
206 stars 210 forks source link

rotation_virtual_start in pagerduty_schedule works differently than the UI #560

Open vide opened 2 years ago

vide commented 2 years ago

Hello!

It looks like that future changes in pagerduty_schedule resources are treated completely different in the web UI of PD respect to how they behave in the Terraform provider, when it comes to modify the users in the rotation.

Terraform Version

$ terraform -v
Terraform v1.2.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/external v2.2.2
+ provider registry.terraform.io/hashicorp/vault v3.6.0
+ provider registry.terraform.io/pagerduty/pagerduty v2.4.1

Affected Resource(s)

Terraform Configuration Files

resource "pagerduty_schedule" "test-vide" {
  name        = "test-vide"
  description = "Test by vide. if you find this after Aug 24 2022, please delete it"
  time_zone   = "Europe/Paris"

  layer {
    name                         = "Layer 1"
    rotation_virtual_start       = "2022-08-23T08:00:00+02:00"
    start                        = "2022-08-23T08:00:00+02:00"
    rotation_turn_length_seconds = 86400
    users                        = ["ID1","ID2","ID3","ID4"]

  }
  teams = []
}

Let's start with the above very simple schedule example. My goal is to remove user ID3 from the rotation starting next September 1st (which is 9 days in the future), while keeping them in the daily rotation for the following 9 days.

If I modify a similar schedule via the UI, it's pretty straightforward: I will modify the "Step 3 : Changes should take effect at" and set it to September 1st, remove ID3 from the list of users on the left and voilà, it is done.

Now, we want to be good automators and do this with a code change and its associated PR. So I would modify the line rotation_virtual_start to point to 2022-09-01T08:00:00+02:00, remove ID3 from the list of users and run terraform apply to apply the changes.

Then, go to the UI and discover in horror that ID3 had been removed from the whole schedule, and even worse, the schedule from rotation_virtual_start (in the future) to today, got completely changed! It even changed the person on duty TODAY! That's because the change in the rotation is applied retroactively from the rotation_virtual_start point back to today.

All of this is probably better explained in this DAZN blog post, totally unrelated to me, they just had the same problem and discovered how it really worked.

Thanks!

jcardali commented 1 year ago

I'm facing the same issue, trying to get two separate schedules aligned. I even stumbled upon the same post you linked, but have had no success following it. It would be helpful if the Terraform output illustrated what the new rotation will look like, as it stands one can only make a change and cross their fingers.