PagerDuty / backstage-plugin-backend

PagerDuty plugin for Backstage - Backend
https://pagerduty.github.io/backstage-plugin-docs/index.html
Apache License 2.0
3 stars 5 forks source link

On-call shows individual that is N levels down from the first level of the escalation policy #34

Closed brianphillips closed 4 months ago

brianphillips commented 4 months ago

Describe the bug When migrating from the old version of the plugin (from @backstage/plugin-pagerduty to @pagerduty/backstage-plugin and friends), the list of "On Call" individuals is incorrect. Only a single entry is shown and that individual is not the first level of on call in the relevant escalation policy (at least in the applications I've spot checked after the upgrade in my local environment).

To Reproduce Steps to reproduce the behavior:

  1. Go to Backstage entity screen with a pagerduty.com/integration-key annotation
  2. Select tab with PagerDuty card
  3. Note the names listed in the "ON CALL" section
  4. Click the "ESCALATION POLICY" button
  5. Compare list of names shown on the pagerduty side (they're different)

Expected behavior List of individuals that are on call should match

Screenshots

Here you can see that the individual on the fifth level of the escalation policy is the only entry shown: image

With the old version of the plugin, we correctly see all levels of the escalation policy: image

Desktop (please complete the following information):

Additional context

I have tried using the API token-based auth (which we were using with the old version of the plugin) as well as the OAuth version and am observing identical results

brianphillips commented 4 months ago

This actually appears to be intentionally coded this way over in the backend plugin: https://github.com/PagerDuty/backstage-plugin-backend/blob/main/src/apis/pagerduty.ts#L392-L394

Apologies for not posting in the correct repo. Can you help me understand the intent behind filtering the list of oncalls based on the first one in the original (unsorted) response? Perhaps the intent is to grab all users at the first escalation level of the sorted list of oncall users?

t1agob commented 4 months ago

Hello @brianphillips! Thanks for opening this issue.

The old version of the plugin owned by Backstage was showing all users from all escalation levels under the on-call section. After collecting feedback from several plugin users this didn't seem to align with their expectation as all levels after level 1 are not necessarily on-call. They are escalation paths.

Still, the result on your first screenshot would only be correct according to our logic if Doug was the engineer currently on-call for Ops OCC on-call schedule and it is not.

t1agob commented 4 months ago

By the way, one thing I'm considering to do to support both behaviours our users are requesting is to have a plugin flag that allows admins to define wether you just show the engineers on-call for escalation level 1 (default) or all escalation levels. Would that be a possible solution for your use case?

alecjacobs5401 commented 4 months ago

Adding some color here, I'm experiencing the same behavior that Brian is.

We have an escalation policy that is in this order:

  1. Primary On Call
  2. Secondary On Call
  3. Team Manager
  4. Director

We're finding that the "Team Manager" is currently being shown as the only person in the list, not the person currently scheduled as "Primary On Call"

t1agob commented 4 months ago

Thanks for sharing @alecjacobs5401. I'll look into it and fix it ASAP.

brianphillips commented 4 months ago

By the way, one thing I'm considering to do to support both behaviours our users are requesting is to have a plugin flag that allows admins to define wether you just show the engineers on-call for escalation level 1 (default) or all escalation levels. Would that be a possible solution for your use case?

I think that would be potentially useful but I think in our org, we'd be fine with just showing the first person that's on-call (as long as its actually the first person that's on-call :slightly_smiling_face: )

t1agob commented 4 months ago

@brianphillips, @alecjacobs5401 which version of the frontend, backend and common plugin packages are you using?

I'm unable to replicate this locally in my environment. It's only returning the user/users on escalation level 1.

brianphillips commented 4 months ago

@t1agob I was using the following versions before my PR was merged:

@pagerduty/backstage-plugin-common@0.1.1
@pagerduty/backstage-plugin@0.9.2
@pagerduty/backstage-plugin-backend@0.4.3

The issue is when the array of oncalls returned from the PagerDuty API are not returned in order, the list of of on-call individuals would be filter to only those at the same escalation_level as the first on-call individual that happened to be returned in the original response.

Upgrading to @pagerduty/backstage-plugin-backend@0.4.4 fixes the issue for me. I'm going to close this issue.