Skip to content

Ability for Github Service to trigger hooks #195

@ahal

Description

@ahal

Motivation

If the Github service can trigger arbitrary hooks, then we can define decision tasks in a central place (like fxci-config). This eliminates the need to copy/paste Decision task definitions around from project to project. It also hides the complexity from end users who may not be familiar with JSON-e or task schemas.

This proposal would also subsume the need for https://github.com/taskcluster/taskcluster-rfcs/blob/main/rfcs/0182-taskcluster-yml-remote-references.md

Prototype

I created a working prototype over at:
https://github.com/ahal/taskcluster/tree/github-custom-pulse-messages

See .taskcluster.yml there for an example format. This prototype causes the Github service to emit a pulse event for each item defined in the messages array. The event payload contains additional context defined in .taskcluster.yml, and can be used to render any hooks that get fired in response to the event.

Possible Solutions

There are many different ways this could be implemented, and even more ways we could structure the .taskcluster.yml. Here are a few high level possibilities:

  1. Context is defined in .taskcluster.yml and gets added to the existing pulse events that the Github service emits. This feels the cleanest to me, but I ran into some implementation problems while prototyping. The existing events get emitted very early on, before we read .taskcluster.yml. They also get emitted regardless of whether tasks were created or not. So this approach might require some heavier refactoring than the others.

  2. Context is defined in .taskcluster.yml and gets added to a pulse event over a new exchange that gets triggered in the appropriate place. This is simpler, but requires creation of a new exchange for the Github service.

  3. Context is defined in .taskcluster.yml and the Github service triggers the hooks directly using the triggerHook API. This is nearly identical to 2, except we cut out pulse from the equation. This could be even simpler, but could also be a bit less flexible in what's possible.

Problems

Versioning

The biggest gotcha here is that when a project needs to specify some new context, we may need to adjust the decision task definition at the same time. And it may not always be possible to do so in a backwards compatible manner.

Updating all Taskcluster consumers at once is not feasible, so we'd want some kind of versioning for the Decision task hooks so we can roll things out gradually. This would be possible by having each version of the hook subscribe to a topic that includes that same version. Then repos could update by adjusting the version in their .taskcluster.yml files.

This adds some maintenance complexity, and will require some logic in fxci-config to generate multiple versions of hooks.

Chain of Trust

It's unclear if there will be chain of trust implications to this. CoT ignores anything that happens before the Decision task, so in theory it should be fine. Though if we have multiple versions of the Decision task definition, we would need to make sure CoT can work across all of them. This doesn't feel like a new problem though, as we already have many variations on a Decision task definition today.. each project uses slightly different ones already!

Security

I haven't thought very hard about the security impacts of this yet. We'd need to make sure we aren't regressing the security model in some way by doing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions