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

Pagerduty plugin migration to new API client and support of new Teleport features #220

Closed
wants to merge 1 commit into from

Conversation

marshall-lee
Copy link
Contributor

@marshall-lee marshall-lee commented Apr 22, 2021

  • Render resolve reason in the notification incident.
  • Render access reviews as a comments to notification incident.
  • Configure target services using request annotations.
  • Manage plugin data state safely using compare-and-swap.
  • Migrate tests to testify.

Closes #219.
Part of #209.

@klizhentas
Copy link
Contributor

@marshall-lee does it close it with the new auto behavior as well?

@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch from ee663d3 to 28679a4 Compare May 12, 2021 20:20
@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch 3 times, most recently from 432cd46 to 4f4d9d6 Compare May 20, 2021 12:14
@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch 2 times, most recently from 2e4eb65 to 57c34f6 Compare May 25, 2021 20:09
@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch 4 times, most recently from 739b5f6 to 86b1c09 Compare May 31, 2021 15:29
@marshall-lee marshall-lee changed the title [WIP] Pagerduty plugin migration to new API client Pagerduty plugin migration to new API client May 31, 2021
@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch 14 times, most recently from cb898be to 49c25bd Compare June 3, 2021 16:36
@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch 6 times, most recently from c4eb4c8 to 79e195d Compare June 9, 2021 19:22
@marshall-lee marshall-lee changed the title Pagerduty plugin migration to new API client Pagerduty plugin migration to new API client and support of new Teleport features Jun 9, 2021
@klizhentas
Copy link
Contributor

@r0mant @Joerger @fspmarshall can you team please review?

@klizhentas
Copy link
Contributor

@marshall-lee can you please refresh PR to resolve conflicts?

@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch 2 times, most recently from faf2ad7 to ba7d3cd Compare June 15, 2021 20:47
@klizhentas
Copy link
Contributor

@r0mant @fspmarshall @Joerger please review folks

Copy link
Contributor

@Joerger Joerger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might've missed some things, I don't have any prior experience with this code.

access/pagerduty/app.go Outdated Show resolved Hide resolved
access/pagerduty/config.go Outdated Show resolved Hide resolved
access/pagerduty/app.go Outdated Show resolved Hide resolved
access/pagerduty/config.go Outdated Show resolved Hide resolved
access/pagerduty/README.md Outdated Show resolved Hide resolved
return trace.Wrap(err)
} else {
logger.Get(ctx).Debugf("Failed to determine a notification service info: %s", err.Error())
shouldTryApprove = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why do we fallback to trying to auto-approve if we failed to get the service info? Wouldn't it be safer to default to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out, I rewrote that part and added some comments that clarify my idea.

RequestID: req.GetName(),
Review: types.AccessReview{
ProposedState: types.RequestState_APPROVED,
Reason: fmt.Sprintf("Access requested by on-call user %s (%s)", user.Name, user.Email),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log the active incident in the reason as well for tracking?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be more than one active incident and theoretically there could be many of them.
But I added a logging of service names in which there're some active incidents found.

access/pagerduty/app.go Outdated Show resolved Hide resolved
// modifyPluginData performs a compare-and-swap update of access request's plugin data.
func (a *App) modifyPluginData(ctx context.Context, reqID string, fn func(data *PluginData) (PluginData, bool)) (bool, error) {
var lastErr error
for i := 0; i < maxModifyPluginDataTries; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would convert this to a select statement on a ticker inside the for loop to provide some backoff and be nice to the PD API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how the backoff is useful here. It's a compare-and-swap trial loop, we can just retry immediately.
And in 99.99% cases there will be at most one retry.

access/pagerduty/app.go Outdated Show resolved Hide resolved
access/pagerduty/client.go Show resolved Hide resolved
access/pagerduty/client.go Show resolved Hide resolved
access/pagerduty/plugindata.go Show resolved Hide resolved
access/pagerduty/plugindata.go Show resolved Hide resolved
@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch 2 times, most recently from efce3e4 to 8730ae9 Compare June 29, 2021 23:38
access/pagerduty/README.md Outdated Show resolved Hide resolved
access/pagerduty/README.md Outdated Show resolved Hide resolved
access/pagerduty/app.go Outdated Show resolved Hide resolved
@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch 2 times, most recently from c7b2738 to ce1f795 Compare June 30, 2021 10:23
@berdee berdee added this to 6.2 in Main Board Jun 30, 2021
@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch from ce1f795 to a0e4953 Compare June 30, 2021 17:05
 - Render resolve reason in the notification incident.
 - Render access reviews as a comments to notification incident.
 - Configure target services using request annotations.
 - Manage plugin data state safely using compare-and-swap.
 - Migrate tests to testify.
@marshall-lee marshall-lee force-pushed the marshall-lee/pagerduty/migrate-6.2 branch from a0e4953 to 38335bf Compare June 30, 2021 17:27
@klizhentas
Copy link
Contributor

closed in favor of #266

@klizhentas klizhentas closed this Jun 30, 2021
@marshall-lee marshall-lee deleted the marshall-lee/pagerduty/migrate-6.2 branch September 8, 2021 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

PagerDuty incident auto behavior
5 participants