diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a6ca1697a5..b897142ec3b 100644 --- a/CHANGELOG.md +++ b/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) diff --git a/src/commands/functions-delete.ts b/src/commands/functions-delete.ts index af2154b3e39..a02d20b6127 100644 --- a/src/commands/functions-delete.ts +++ b/src/commands/functions-delete.ts @@ -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"; @@ -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); }); diff --git a/src/deploy/functions/release/index.ts b/src/deploy/functions/release/index.ts index 3fa0a12d85c..1e2882eb646 100644 --- a/src/deploy/functions/release/index.ts +++ b/src/deploy/functions/release/index.ts @@ -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) {