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

fix: labels from first invocation were being applied to future calls #251

Merged
merged 2 commits into from
Jan 29, 2020

Conversation

bcoe
Copy link
Contributor

@bcoe bcoe commented Jan 29, 2020

caching was interfering with our ability to return labels based on the context of the repo firing a webhook, this lead to the label for the first repo invoking the cloud function to be applied to subsequent calls.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 29, 2020
if (!labelsCache) {
await refreshLabels(github, repoPath);
}
return labelsCache;
const labels = {
labels: labelsCache.labels.slice(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of a labels.slice(0)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this creates a copy of the labels so that we don't end up populating additional labels in the cache each time we access labels.

creating a cache means that the labels are cached between invocations of cloud functions.

const labels = {
labels: labelsCache.labels.slice(0),
} as Labels;
const apiLabelsRes = await handler.getApiLabels(repoPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Little worried here. Isn't this essentially completely bypassing the cache? Will this end up calling out to GCS constantly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only called once per function invocation, which only occurs rarely, e.g., when a new repo is created, or a label is deleted.

I think we're going to need to get rid of the push functionality any ways, because it takes like an hour to backfill all labels, and the maximum execution time of a cloud function is 9 minutes.

@bcoe bcoe merged commit 84ec6e7 into master Jan 29, 2020
@bcoe bcoe deleted the fix-caching-bug branch January 29, 2020 01:54
yoshi-automation added a commit that referenced this pull request Apr 1, 2020
…251)

84ec6e7
commit 84ec6e7
Author: Benjamin E. Coe <[email protected]>
Date:   Tue Jan 28 17:54:16 2020 -0800

    fix: labels from first invocation were being applied to future calls (#251)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants