Skip to content

Commit

Permalink
Do not try to clean up AR images if AR is not enabled (#3943)
Browse files Browse the repository at this point in the history
* 🤬 This was supposed to go in the last release

* Set changelist number in changelog

* Formatter & use opts in functions-delete
  • Loading branch information
inlined committed Dec 13, 2021
1 parent 0bf69df commit 6ddc5ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,3 +1,4 @@
- Fixes issue when installing a Firebase Extension where secrets would be created before validation.
- Fixes issue with filtering on a specific storage bucket using functions in the emulator (#3893)
- Fixes check in Cloud Functions for Firebase initialization to check for API enablement before trying to enable them. (#2574)
- No longer tries to clean up function build images from Artifact Registry when Artifact Registry is not enabled (#3943)
13 changes: 12 additions & 1 deletion src/commands/functions-delete.ts
Expand Up @@ -9,6 +9,7 @@ import { promptOnce } from "../prompt";
import { reduceFlat } from "../functional";
import { requirePermissions } from "../requirePermissions";
import * as args from "../deploy/functions/args";
import * as ensure from "../ensureApiEnabled";
import * as helper from "../deploy/functions/functionsDeployHelper";
import * as utils from "../utils";
import * as backend from "../deploy/functions/backend";
Expand Down Expand Up @@ -104,5 +105,15 @@ export default new Command("functions:delete [filters...]")
}

// Clean up image caches too
await containerCleaner.cleanupBuildImages([], allEpToDelete);
const opts: { ar?: containerCleaner.ArtifactRegistryCleaner } = {};
const arEnabled = await ensure.check(
needProjectId(options),
"artifactregistry.googleapis.com",
"functions",
/* silent= */ true
);
if (!arEnabled) {
opts.ar = new containerCleaner.NoopArtifactRegistryCleaner();
}
await containerCleaner.cleanupBuildImages([], allEpToDelete, opts);
});
6 changes: 5 additions & 1 deletion src/deploy/functions/release/index.ts
Expand Up @@ -75,7 +75,11 @@ export async function release(
const deletedEndpoints = Object.values(plan)
.map((r) => r.endpointsToDelete)
.reduce(reduceFlat, []);
await containerCleaner.cleanupBuildImages(haveEndpoints, deletedEndpoints);
const opts: { ar?: containerCleaner.ArtifactRegistryCleaner } = {};
if (!context.artifactRegistryEnabled) {
opts.ar = new containerCleaner.NoopArtifactRegistryCleaner();
}
await containerCleaner.cleanupBuildImages(haveEndpoints, deletedEndpoints, opts);

const allErrors = summary.results.filter((r) => r.error).map((r) => r.error) as Error[];
if (allErrors.length) {
Expand Down

0 comments on commit 6ddc5ab

Please sign in to comment.