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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not try to clean up AR images if AR is not enabled #3943

Merged
merged 3 commits into from Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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