Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Slow check-forward-deploy check when there are many tags #9

Closed
domcleal opened this issue May 20, 2020 · 0 comments · Fixed by #10
Closed

Slow check-forward-deploy check when there are many tags #9

domcleal opened this issue May 20, 2020 · 0 comments · Fixed by #10
Labels
bug Something isn't working

Comments

@domcleal
Copy link
Member

domcleal commented May 20, 2020

The check-forward-deploy check (and probably check-recent-deploy) is very slow when operating on a repo with over 16,000 tags, taking about 10 minutes.

It tries to determine the last deployment tag for the environment:

current_tag = @client.last_deploy_tag(
prefix: @tag_prefix, environment: @context.environment)

However this relies on loading all tags from the GitHub API with pagination and filtering them by prefix:

@octokit.auto_paginate = true
@octokit.tags(owner_repo).find_all do |tag|
tag[:name].start_with?("#{prefix}-#{environment}-")
end

We need a more optimised way of finding the latest deployment tag. Possibly:

  1. Check for a better API, see if we can filter by prefix. If octokit can't do it, check the newer GraphQL API.
  2. If we can filter by prefix, we may also need to filter by recent dates as we still have lots of deploy-production prefixed tags.
  3. Check for an API that returns a list guaranteed to be sorted.
  4. Caching.
@domcleal domcleal added the bug Something isn't working label May 20, 2020
domcleal added a commit that referenced this issue May 20, 2020
Retrieving the last deploy tag was a slow operation, taking ~10 mins on
a repo with 16k tags. This was because `Octokit::Client#tags` is a
paginated API call to GitHub, only retrieving 30 at a time. To find the
latest deploy tag, all tags were being pulled back and then filtered and
sorted on the client.

This splits the operation into two parts - first pulling back all tag
names via the `#refs` API operation, and then retrieving the commit SHA
when we know which tag we need.

The refs retrieval supports filtering by prefix - although since most
tags in our repos have the same prefixes, this is only slightly faster.
It however has no pagination, so we can retrieve thousands of ref names
in a single API call fairly quickly, though it doesn't return commit
object information. The `#last_deploy_tag` call now runs in 5.6s against
the same repo with 16k tags, rather than 10 mins.

Fixes #9
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant