Lessons learned tying repo ownership to teams

Over the last few years, I've been part of efforts at Elastic and Deliveroo Engineering to tie a "team" as an owner of a given (GitHub) repository.

As noted in GitHub's recent-ish blog, this isn't a super straightforward thing to do, and as I'd learned a few things working on this, I thought it's worth writing it up as a form of blogumentation.

What even is a "team"?#

Before we get any further, it's worth talking about what we consider as a "team" in this context.

At Elastic, we used GitHub teams for our repositories to manage access, as well as to manage our CODEOWNERS. These GitHub teams (at least at the time) were mostly manually created and would generally be a 1-1 mapping to an actual team in the organisation, so when a new member of the team joined, they'd be added to the GitHub team, and then get their relevant access everywhere in the org.

At Mend, our teams are managed through our HR system, so a GitHub team is maintained in sync with who's in the company, and so if they move teams, they'll automagically gain and lose relevant access at that point.

We had some similar functionality at Deliveroo, but there were a few times where the early version of the tooling that synced with our HR system would break, and so some folks would be ejected from the teams they needed to be part of, leading to a lot of frustration.

In all of these cases, we generally had a team that was 1-1 with the team within the organisation, but this isn't always the case for shared libraries and infrastructure. One of the initiatives I was part of at Deliveroo was the "Go team", which was a virtual team that maintained Go tooling and libraries and didn't directly map to a business team, as it was a cross-cutting effort. In this case, the "team" was something like @deliveroo/go-team, not a real business team.

If your organisation has specific logic around how teams are considered, this may change where you're going with this.

Why are you adding team ownership?#

It's also important to know what you (or your organisation) want out of this exercise. k In my time in Elastic working on Engineering Productivity, we were often working towards some of the cross-cutting goals of enabling the wider engineering organisation to be more productive (sometimes by getting out of their way as quickly as possible), as well as working with partners in the business to help be better managed.

For instance, we needed to support our friends in Product Security to know that when there is a high-severity security vulnerability, or a key supply chain security attack, they know who to page to help remediate it. Relatedly, I was also working on similar sorts of questions with dependency-management-data, where I wanted to know where different teams were using key internal libraries or hadn't updated specific versions of software, so would also need that information available.

Alternatively, if someone forgot to turn off an expensive AWS EC2 instance, we needed to know who that bill came to, so the relevant Director was able to understand how that impacted their overall budget for Cloud+CI spending, and that our friends in Finance are confident that we won't overspend in the future.

Adding team ownership was one of these avenues to solving this, alongside adding information about the division and org that a company was part of, providing additional visibility into where different repos were used.

At Capital One, we had similar sort of metadata on our Cloud infrastructure, where you couldn't even push a service into a development environment without some indication of what business unit would be paying for the infrastructure. Although it could add a little friction, it also made it much easier to track where everything was used.

You may have a different reason for why you want ownership - it's worth considering actually what you want out of this exercise:

  • Do you need every repo to have an owner by the end of this? What happens at the edge cases, where it's not straightforward?
  • What about repos that don't have an owner? Should they be archived?
    • Can you look at repos that haven't been pushed_at and/or updated_at in some time, and archive them?
  • What happens if you get the ownership decision wrong?
  • Is the ownership decision reversible?
  • Do you need a single point of contact? How big a "team" are you willing to allow?
    • For instance, the CODEOWNERS may allow 50 people to review a PR, but you probably don't have 50 repo admins and/or 50 people who you want to reach out to when something's wrong
  • Do you need to tie this down to an email address or a Slack channel you can contact for issues?
  • Do you want this to be a centralised piece of work (some central team(s) are going to determine owners, and raise PRs/add them to the Service Catalog?) or is this decentralised (teams need to prioritise the work and do it when they're ready)?
    • Depending on your organisation, a decentralised approach may be nicer, but then it impacts what timelines you're working to
  • How much calendar time are you willing to spend on this work, and when do you want it "done"?
    • While knowing that there's likely going to be a "long tail"

Shrink your owning teams#

As part of this work, we also found cases where either the number of people with admin permissions on a repo was higher than we'd really want, or that there was too many people in the group of "owners".

By going through this process, you may end up being able to break this down further, and make sure that you've got the best possible contacts when something is needed. That doesn't necessarily mean they're all the people with admin permissions, nor does it mean people who aren't in that owners group can't necessarily have admin permission, but it can help you work out where there may be smaller groups needed, to avoid the bystander effect.

We've found that creating an -admin team that is a subset of folks to contact can work well.

You can probably guess who owns it#

For some things, it was fairly straightforward - we could look at:

  • which team(s) have admin or maintain permissions on the repo?
  • which team(s) are referenced in CODEOWNERS?
  • which team(s) are regularly contributing to the repo?

You may also have some organisation-specific signals you can take into account like "what cost-centre is this AWS EC2 tagged as".

While we had some internal tooling at Elastic that could do this guess for us, and it was a good starting point.

Once you've looked at that, you could also look at throwing an LLM at it, if you're willing to spend a bit more.

Make sure your automation is safe#

A reminder that if you are making automated changes across your repositories - whether that is to set ownership, or to archive repos - watch out for unexpected side effects like marking your public projects private πŸ˜…

Make it part of the "golden path"#

As Platform Engineers, we should make sure that we're building compelling solutions that people want to use, so if we have to resort to forcing people to use the Service Catalog, we've alreayd lost. But it may be possible to make it something that they need to start using to get their job done.

At Elastic, one thing we found was that as part of our migration work from Jenkins to Buildkite CI, we would lean more heavily on infrastructure-as-code and require the registering of new pipelines as a catalog-info.yaml file in a user's repository. This catalog-info.yaml would need the user to register their repository in elastic/catalog-info, as part of which, they would need to specify their team's owner as an intentional byproduct of this migration work.

As we built more into our service bootstrapping functionality, we had a Backstage template that would simplify this whole process for new repos, where the whole flow would require an owner, and prepare the relevant changes across the different repos, using that owner as needed, which made it so much easier for folks following our "golden path" to have all the correct metadata.

It's a fine balance to be sure, and depending on your perspective, it sounds like I am saying that you shouldn't force people to use your Service Catalog, while also forcing people to use the Service Catalog as part of the "golden path" πŸ˜…

Make ownership changes self-serve (by people who aren't repo admins)#

One common avenue I see folks use for tracking team ownership is using GitHub's Custom Properties functionality, which while it's what GitHub themselves use, I don't recommend it.

Updating a repo's Custom Properties requires you have admin access on the repo (or are an Owner on the GitHub organisation), which if you're practicing good hygiene, means there's a small group of folks who can update them.

While it does make sense that you would not want a large group of users in a given repo to be able to modify the ownership, having wider ability to change settings would at least democratise the process a little.

If I remember correctly, Elastic at one point had ~800 repositories with no defined owner. If we were to require that it was repository admins who needed to perform that update, it would have been much more painful overall.

Our approach was to use Custom Properties, but made them non-editable-by-humans. As mentioned above, we would require repositories to be managed by a config changes in elastic/catalog-info, which then meant that we could run validation on the change, making sure that the relevant team existed, and that they were under the correct division and org in the business, as well as requiring code review.

This meant it was much easier for someone outside of a repo to come in and help register or correct ownership, rather than requiring it be a few folks with elevated access.

I don't have any stats around it, but I feel I had one of the highest number of commits for registering repos' owners, as I would be looking at repositories' usage of dependencies with dependency-management-data and want to correct our ownership, or would notice when there were repositories that declared different owners to their Buildkite pipeline, or a production service defined in the repo's catalog-info.yaml.

Also a reminder that Custom Properties are public!

Make it harder to represent invalid state#

At Elastic, we didn't allow for a single user to own a repository. This meant that there was never a single point of failure, that someone leaving the business wouldn't mean that we lost all access to it, and that we would generally make it so a team lead knew what repositories were in scope for them to handle security vulnerabilities and other required internal work.

If you went a step further, how would the process look if you made it so couldn't be unowned?

Would this be helpful, as then there's always someone on the hook, even if they're unhappy with it? Would that become a forcing function, where the current owning team is then more engaged in migrating it to a new owner?

Ownership as "a stick"#

In (Platform) Engineering we sometimes talk about "the carrot and the stick", and that we can either provide a positive reward for using our tooling, or something less positive.

If a team is (incorrectly) identified as an owner of a repository - for instance because their engineers had recently contributed to it, but it was part of some work on behalf of another workstrea, or because the official "handover" config changes hadn't happened - then being in that state can be useful to help drive towards correct ownership if the owners start to e.g. receive daily emails about out-of-date software or non-compliant production infrastructure.

That doesn't meant that we should make it purposefully annoying to be an owner of a repository, but if a team lead starts seeing that their team is suddenly scoring the lowest on production readiness, or are receiving 5 emails a day about a production application that's got the wrong Google Cloud tags on it, I've found they're very keen to correct!

Be careful to make sure that that there's some level of consent - when changing a team's owner, be careful that the new owners are aware of it!

Enforce validation externally, not with a CI check#

Something we particularly saw at with our catalog-info.yaml, where we were adding new functionality into the schema to allow describing new types of entities in use at Elastic was that our catalog-info.yaml's schema was validated client-side (using a JSON schema) but also using a custom-written Python tool that did some additional Elastic-specific checks that weren't possible in the JSON Schema.

Repos would add that validation tool into their CI pipeline, and so each time a change was made to the catalog-info.yaml, there'd be a check to make sure it was valid and fail the PR if not.

The trouble is that this validation tool wouldn't always be updated by repo owners - even though we had Renovate set up across the org, some of the less active repositories wouldn't have updated their validation tooling, and so they'd see CI failures when adding new config, which isn't the best experience.

Although using strongly version pinned validation tooling was useful, it also needed to stay in lock-step with what the system that synced the catalog-info.yaml with Backstage, Buildkite and our other services, meaning that we were giving repo owners a bit too much flexibility with what they could set themselves.

We also saw this with how we recommended users to validate their Renovate configuration, where we had renovate-config-validator running in CI through the same validation library. The trouble was that the central Renovate deployment updated before the users' validation library, so there could be a lag between an updated Renovate version and what config was in a repository, leading to a window of potentially broken config.

I'd instead recommend making sure that these sorts of validation checks are separated out into a GitHub App (or similar on your platform) where the check is externalised from the repo's CI configuration, so you can roll out a change to the validation logic centrally, rather than requiring repo owners to take on a version update for some tooling before they get the new logic.

This does have the risk of you now needing to have stronger confidence before making changes, but it's better than having a lot of repos lagging behind or not even running the validation.

70% is better than 7%#

As with many initiatives, there will be a long tail of work to complete, and you're very unlikely to hit 100% coverage within the timelines you'd hoped for.

If you're able to get a good percentage into a good place, that's better than nothing, and gives you a strong foundation to go further.

And as mentioned previously, maybe make it so new repositories can't be created without the correct ownership in place, so at least you only have to worry about the older repos.

Written by Jamie Tanna's profile image Jamie Tanna on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

This blog post is 100% human-written, and has nothing derived from LLMs (be it code, editorial support or prose).

Also on:

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.