Skip to content

Commit 3fb3240

Browse files
inlinedjoehangoogle-oss-bot
authored
Stop trying to clean up AR cache on function deletion. (#6927)
* Stop trying to clean up AR cache on function deletion. Since release of this feature, GCF has started cleaning up cache images automatically on function deletion. This has led to us getting 404 errors and printing scary messages in the console. Fixes #6882 * Ignore quota project in GCF source uploads (#6917) * Ignore quota project in GCF source uploads * Changelog * Remove superfluous change * format + fix tests --------- Co-authored-by: Joe Hanley <joehanley@google.com> * 13.6.0 * [firebase-release] Removed change log and reset repo after 13.6.0 release * Changelog * Remove dead code unit test --------- Co-authored-by: Joe Hanley <joehanley@google.com> Co-authored-by: Google Open Source Bot <firebase-oss-bot@google.com>
1 parent 1a3b885 commit 3fb3240

File tree

3 files changed

+3
-39
lines changed

3 files changed

+3
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
- Stop trying to delete cache images after functions deletion that GCF already cleans up (#6927)
12
- Add support timelines for functions runtimes (#6866)

src/deploy/functions/containerCleaner.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function cleanupBuildImages(
6363
cleanup.push(
6464
...deletedFunctions.map(async (func) => {
6565
try {
66-
await Promise.all([arCleaner.cleanupFunction(func), arCleaner.cleanupFunctionCache(func)]);
66+
await arCleaner.cleanupFunction(func);
6767
} catch (err: any) {
6868
const path = `${func.project}/${func.region}/gcf-artifacts`;
6969
failedDomains.add(`https://console.cloud.google.com/artifacts/docker/${path}`);
@@ -151,33 +151,13 @@ export class ArtifactRegistryCleaner {
151151
operationResourceName: op.name,
152152
});
153153
}
154-
155-
async cleanupFunctionCache(func: backend.TargetIds): Promise<void> {
156-
// GCF uses "<id>/cache" as their pacakge name, but AR percent-encodes this to
157-
// avoid parsing issues with OP.
158-
const op = await artifactregistry.deletePackage(
159-
`${ArtifactRegistryCleaner.packagePath(func)}%2Fcache`,
160-
);
161-
if (op.done) {
162-
return;
163-
}
164-
await poller.pollOperation<void>({
165-
...ArtifactRegistryCleaner.POLLER_OPTIONS,
166-
pollerName: `cleanup-cache-${func.region}-${func.id}`,
167-
operationResourceName: op.name,
168-
});
169-
}
170154
}
171155

172156
// Temporary class to turn off AR cleaning if AR isn't enabled yet
173157
export class NoopArtifactRegistryCleaner extends ArtifactRegistryCleaner {
174158
cleanupFunction(): Promise<void> {
175159
return Promise.resolve();
176160
}
177-
178-
cleanupFunctionCache(): Promise<void> {
179-
return Promise.resolve();
180-
}
181161
}
182162

183163
export class ContainerRegistryCleaner {

src/test/deploy/functions/containerCleaner.spec.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe("CleanupBuildImages", () => {
3535
});
3636

3737
it("reports failed domains from AR", async () => {
38-
ar.cleanupFunctionCache.rejects(new Error("uh oh"));
38+
ar.cleanupFunction.rejects(new Error("uh oh"));
3939
await containerCleaner.cleanupBuildImages([], [TARGET], { gcr, ar } as any);
4040
expect(logLabeledWarning).to.have.been.calledWithMatch(
4141
"functions",
@@ -207,23 +207,6 @@ describe("ArtifactRegistryCleaner", () => {
207207
expect(poll.pollOperation).to.have.been.called;
208208
});
209209

210-
it("deletes cache dirs", async () => {
211-
const cleaner = new containerCleaner.ArtifactRegistryCleaner();
212-
const func = {
213-
id: "function",
214-
region: "region",
215-
project: "project",
216-
};
217-
218-
ar.deletePackage.returns(Promise.resolve({ name: "op", done: false }));
219-
220-
await cleaner.cleanupFunctionCache(func);
221-
expect(ar.deletePackage).to.have.been.calledWith(
222-
"projects/project/locations/region/repositories/gcf-artifacts/packages/function%2Fcache",
223-
);
224-
expect(poll.pollOperation).to.have.been.called;
225-
});
226-
227210
it("bypasses poller if the operation is completed", async () => {
228211
const cleaner = new containerCleaner.ArtifactRegistryCleaner();
229212
const func = {

0 commit comments

Comments
 (0)