Skip to content

Deploying a function does not respect the cleanup policy and deletes old containers #8421

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

Closed
canbal opened this issue Apr 10, 2025 · 4 comments

Comments

@canbal
Copy link

canbal commented Apr 10, 2025

[REQUIRED] Environment info

firebase-tools: 14.1.0

Platform: macOS

[REQUIRED] Test case

This has been supported in the past as an experimental configuration since #6861, but #8324 has removed it with the assumption that cleanup policy should be respected instead. In my case the clean-up policy is not respected and the new function deploys always destroy previous containers.

For reference, here's the policy I have set in my project:

Image

[REQUIRED] Steps to reproduce

  1. Deploy a new function: firebase deploy --only functions:myFunction
  2. Go to Cloud Run console > myFunction > Revisions to see the revisions
  3. Click on a previous revision that was created sooner than the clean-up period
  4. Go to Container > Image and click on it
  5. See the page shows "Unable to find the resource you requested"

[REQUIRED] Expected behavior

Any revision that was created before the clean-up period comes along should be available

[REQUIRED] Actual behavior

The previous revisions are all removed immediately followed by a successful new deployment

@google-oss-bot
Copy link
Contributor

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

@canbal canbal changed the title Deploying a new version of a function deletes old containers despite having set a cleanup policy Deploying a function does not respect the cleanup policy and deletes old containers Apr 10, 2025
@aalej
Copy link
Contributor

aalej commented Apr 10, 2025

Hey @canbal, I'm trying to reproduce this, but so far previous revisions are not being deleted on successful function deployments.

Here's the clean up policy I have set up:

Image

And here's the revisions for the function. The container images from each revision is still available when opening the link

Image

Based on the clean up policy you have set, only artifacts older than 10 days should be deleted. Just to verify, in your case, after running firebase deploy --only functions:myFunction are the images from old revisions immediately deleted even if they're less than 10 days old?

By any chance, do you have any other clean up policy set up?

@canbal
Copy link
Author

canbal commented Apr 10, 2025

Thanks for checking @aalej. I don't have another clean up policy set up, the one I shared is the only one. However I have a couple of new observations:

  1. I tried to deploy a completely brand new function under the name myFunction and I can confirm the previous image is still intact. For a brand new function things seems to be working.
  2. I tried to deploy an existing function (not sure if relevant but it was created prior to when the policy was created) with firebase deploy --only functions:existingFunction and for that one the previous image is erased immediately.

Is there a local cache I have to clear, or is it possible that the policy somehow isn't properly covering specific functions?

If there is a way to run a gcloud command or run a script to fetch the policy that the cli tool is relying on, I'd be happy to run it and report back.

@canbal
Copy link
Author

canbal commented Apr 16, 2025

@aalej not sure what changed, but it seems like the older images are now retained even for the existing functions. We can close this issue.

@canbal canbal closed this as completed Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants