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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot deploy Angular SSR application using firebase deploy #7054

Open
craeft-io opened this issue Apr 26, 2024 · 31 comments
Open

Cannot deploy Angular SSR application using firebase deploy #7054

craeft-io opened this issue Apr 26, 2024 · 31 comments

Comments

@craeft-io
Copy link

[REQUIRED] Environment info

13.7.5

firebase-tools:

macOS / Ubuntu in GitHub Actions

Platform:

[REQUIRED] Test case

Deployment of Angular using Firebase Webframeworks fails due to runtimeClassName error

[REQUIRED] Steps to reproduce

  1. Create firebase project and upgrade it to blaze plan
  2. Create a new Angular Project using ng new. Select Y on the question to enable SSR
  3. Add Angularfire using ng add @angular/fire
  4. Enable ng deploy for hosting
  5. Without changes deploy hosting using ng deploy

[REQUIRED] Expected behavior

Deployment of hosting and SSR Function should work without problems.

[REQUIRED] Actual behavior

Deployment fails with result:
Error: Failed to replace Run service projects/123456789/locations/us-east1/services/ssrtestdeployxxxxxx

Google Cloud logging tells the following error
spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update

@craeft-io craeft-io changed the title Deployment of Angular using Firebase Webframeworks fails due to runtimeClassName error Cannot deploy Angular SSR application using firebase deploy Apr 26, 2024
@serialito74
Copy link

serialito74 commented Apr 26, 2024

[REQUIRED] Environment info

firebase-tools:

❯ npm firebase-tool --version
10.6.0

Platform:
Fedora / Ubuntu

[REQUIRED] Test case

Deployment of Next app using Firebase Webframeworks fails due to runtimeClassName HTTP Error: 400

[REQUIRED] Steps to reproduce

  1. Create a Next.js project
  2. Execute firebase experiments:enable webframeworks
  3. Execute firebase deploy --project xxxx --debug

[REQUIRED] Expected behavior

Update a new version next.js app

[REQUIRED] Actual behavior

Error:

code":400,"message":"spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":
[2024-04-26T16:25:42.191Z] <<< [apiv2][body] PUT https://run.googleapis.com/v1/projects/770880274560/locations/us-east1/services/ssrclickmenudevfirebase {"error":{"code":400,"message":"spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"spec.template.spec.runtimeClassName","description":"When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update"}]}]}}
[2024-04-26T16:25:42.194Z] FirebaseError: HTTP Error: 400, spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update
    at responseToError (/usr/local/lib/node_modules/firebase-tools/lib/responseToError.js:49:12)
    at RetryOperation._fn (/usr/local/lib/node_modules/firebase-tools/lib/apiv2.js:297:77)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

@krismkt2013
Copy link

Same issue

spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update

Fail to finalize version

@DuanTranHuy
Copy link

Same issue with Nextjs .Failed to replace Run service projects

@Mikkel84
Copy link

Have the same issue when deploying Cloud Functions 2nd generation.

@Lzak
Copy link

Lzak commented Apr 27, 2024

Also running into this issue when trying to deploy my React + Next project.
Error: Failed to replace Run service projects/XXXXXX/locations/us-east1/services/ssrXXXXXX

[REQUIRED] Environment info

Platform: macOS Ventura 13.5

package.json

{
    "firebase": "10.11.1",
    "firebase-admin": "^11.8.0",
    "firebase-tools": "^13.7.5",
    ...
}

[REQUIRED] Test case

Deployment of React+Next app using Firebase Webframeworks fails due to runtimeClassName HTTP Error: 400

[REQUIRED] Steps to reproduce

Create a Next.js project
Execute firebase experiments:enable webframeworks
Execute firebase deploy --debug

[REQUIRED] Expected behavior

Deploy the project along with the SSR function.

[REQUIRED] Actual behavior

[2024-04-27T16:58:33.786Z] <<< [apiv2][status] PUT https://run.googleapis.com/v1/projects/XXXXXXXXX/locations/us-east1/services/ssrXXXXXXXX 400
[2024-04-27T16:58:33.786Z] <<< [apiv2][body] PUT https://run.googleapis.com/v1/projects/XXXXXXXXX/locations/us-east1/services/ssrXXXXXXXX {"error":{"code":400,"message":"spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"spec.template.spec.runtimeClassName","description":"When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update"}]}]}}
[2024-04-27T16:58:33.846Z] FirebaseError: HTTP Error: 400, spec.template.spec.runtimeClassName: When annotation [run.googleapis.com/base-images] set, runtimeClassName must be set to run.googleapis.com/linux-base-image-update
    at responseToError (/Users/Lzak/.nvm/versions/node/v16.16.0/lib/node_modules/firebase-tools/lib/responseToError.js:49:12)
    at RetryOperation._fn (/Users/Lzak/.nvm/versions/node/v16.16.0/lib/node_modules/firebase-tools/lib/apiv2.js:299:77)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Error: Failed to replace Run service projects/XXXXXXXXX/locations/us-east1/services/ssrXXXXXXXX

@BugMakerJarvis
Copy link

Same issue, any solutions?

@trichomes
Copy link

Same situation as @Lzak deploying React + Next project.

@nylser
Copy link

nylser commented Apr 28, 2024

Have the same issue when deploying Cloud Functions 2nd generation.

I get this issue when trying to add a Cloud SQL connection to Cloud Runs - this was working last week, seems like there was a change that impacts Cloud Run (Annotation logic)? This also seems to affect firebase then

@leach-mrt
Copy link

Same issue as @Lzak from 14 hours ago.

@m3tasploit
Copy link

Same issue in sveltekit deployment as well

@benediktarnold
Copy link

No solution, but I found out what's going on under the hood:

firebase-tools makes a GET request for the cloud run resource

return run.getService(

The result of that call contains the annotation run.googleapis.com/base-images but not the runtimeClassName attribute. Afterwards the function ensureLatestRevisionTagged

export async function ensureLatestRevisionTagged(
modifies the resource and adds a tag.

Instead of patching the cloud run service using a PATCH call, it uses a PUT call to replace the whole service resource. This PUT call fails with the mentioned error message, since the original result from the GET call above did include the annotation but not the runtimeClassName attribute.

Not sure who to blame here, but I think two parties have bugs:

  1. The cloud run http api should return the attribute runtimeClassName in the service template spec. The attribute is visible in the YAML view in the cloud console, but it's not mentioned in the API docs https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services#Service

  2. firebase-tools shouldn't do a GET and a PUT. Instead it should use a PATCH request to to add the tag https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services/patch

@leach-mrt
Copy link

@benediktarnold
Copy link

Not sure who to blame here, but I think two parties have bugs:

  1. The cloud run http api should return the attribute runtimeClassName in the service template spec. The attribute is visible in the YAML view in the cloud console, but it's not mentioned in the API docs https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services#Service
  2. firebase-tools shouldn't do a GET and a PUT. Instead it should use a PATCH request to to add the tag https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services/patch

Oh. I got the documentation links wrong. firebase-tools is using v1 endpoints. Not sure if v1 even had a patch endpoint, but it also lacks documentation for get and put ;-) https://cloud.google.com/run/docs/reference/rest/v1/projects.locations.services
Anyway, the problem remains the same.

@phminella
Copy link

Same error here... for those in need to deploy immediately, disabling pintags firebase experiments:disable pintags before deploying should make it go through.

@benediktarnold
Copy link

Another workaround:
Use us-central1 or europe-west1 as the region for frameworksBackend. I tested both and didn't have the problem. Initially I used europe-west3 and had the error.

Explanation: The cloud run admin api behaves different depending on the region. Some regions return the annotation run.googleapis.com/base-images for the GET request and some don't. So far I tested:

  • europe-west3 (error)
  • europe-west1 (works)
  • us-central1 (works)

@drgarbage
Copy link

Same error here... for those in need to deploy immediately, disabling pintags firebase experiments:disable pintags before deploying should make it go through.

This works for me, thank you.

Another workaround: Use us-central1 or europe-west1 as the region for frameworksBackend. I tested both and didn't have the problem. Initially I used europe-west3 and had the error.

Explanation: The cloud run admin api behaves different depending on the region. Some regions return the annotation run.googleapis.com/base-images for the GET request and some don't. So far I tested:

  • europe-west3 (error)
  • europe-west1 (works)
  • us-central1 (works)

report:

  • asia-east1 (error)

@aalej
Copy link
Contributor

aalej commented Apr 29, 2024

Hey folks, thanks for all the information you shared, and apologies for the delay. Thanks @benediktarnold and @phminella for sharing your workarounds. I was able to reproduce the issue when setting the region to europe-west3 with pintags enabled. Let me try to bring someone from our team to look into this and provide more context.

@service-paradis
Copy link

Another workaround: Use us-central1 or europe-west1 as the region for frameworksBackend. I tested both and didn't have the problem. Initially I used europe-west3 and had the error.

Explanation: The cloud run admin api behaves different depending on the region. Some regions return the annotation run.googleapis.com/base-images for the GET request and some don't. So far I tested:

  • europe-west3 (error)
  • europe-west1 (works)
  • us-central1 (works)

Good catch! I have the error with northamerica-northeast1 and us-east1.

@c00ley
Copy link

c00ley commented Apr 29, 2024

Likewise seeing this issue with updating cloud run labels via gcloud..

@c00ley
Copy link

c00ley commented Apr 29, 2024

Have the same issue when deploying Cloud Functions 2nd generation.

Same boat as you w respect to CF gen2

@Camille-D
Copy link

Hello,

I am encountering the same issue as others when trying to deploy my Cloud Function for an Angular SSR application in the europe-west3 region. Initially, I tried disabling firebase experiments:disable pintags, but this did not resolve the problem.

Since re-enabling pintags, I have been facing a new error: "Invalid Request. Violations: {runtime_update_policy=Base image update feature is not applicable to 2nd Gen functions.}"

Is this issue related to the use of pintags? Are there any ongoing updates regarding this bug?

Thank you for your assistance.

@craeft-io
Copy link
Author

@Camille-D
I got the same "Invalid Request. Violations: {runtime_update_policy=Base image update feature is not applicable to 2nd Gen functions.}" error while deploying 2nd Gen functions since a few minutes.

This not only applies to functions related to the Webframeworks but to all 2nd Gen Cloud Functions.

Does anyone have a fix yet?

choipd added a commit to dasomx/mind-center that referenced this issue Apr 30, 2024
@Camille-D
Copy link

Hello,

I wanted to provide an update on my previous issue regarding the deployment of my Angular SSR Cloud Function in the europe-west3 region. Today, I retried firebase experiments:disable pintags, and unlike yesterday, it worked successfully. I was able to deploy my function without encountering the error from before.

Thank you for the support, and I hope this information might be helpful to others experiencing similar issues.

@ChTiSh
Copy link

ChTiSh commented Apr 30, 2024

Same problem here, us-west1 giving the same error. and firebase experiments:disable pintags worked, thank you! @phminella

@alejandroquadri
Copy link

Same here when using us-east1
firebase experiments:disable pintags is working

@siraisisatoru
Copy link

siraisisatoru commented May 1, 2024

Folks, I just tried to deploy my Nextjs project to Firebase without using firebase experiments:disable pintags and it works now.

[2024-05-01T08:03:11.225Z] >>> [apiv2][query] PATCH https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/<My project>/versions/<My Version> updateMask=status%2Cconfig
[2024-05-01T08:03:11.225Z] >>> [apiv2][body] PATCH https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/<My project>/versions/<My Version>  {"status":"FINALIZED","config":{"rewrites":[{"glob":"**","run":{"serviceId":"<My project>","region":"asia-east1","tag":"fh-<My Version> "}}],"redirects":[],"headers":[{"glob":"/_not-found","headers":{"x-next-cache-tags":"_N_T_/layout,_N_T_/_not-found/layout,_N_T_/_not-found/page,_N_T_/_not-found"}}],"cleanUrls":true,"trailingSlashBehavior":"REMOVE"}}
[2024-05-01T08:03:12.867Z] <<< [apiv2][status] PATCH https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/<My project>/versions/<My Version>  200
[2024-05-01T08:03:12.867Z] <<< [apiv2][body] PATCH https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/<My project>/versions/<My Version>  {"name":"projects/<My Project ID>/sites/<My project>/versions/<My Version> ","status":"FINALIZED","config":{"headers":[{"headers":{"x-next-cache-tags":"_N_T_/layout,_N_T_/_not-found/layout,_N_T_/_not-found/page,_N_T_/_not-found"},"glob":"/_not-found"}],"rewrites":[{"glob":"**","run":{"serviceId":"<My project>","region":"asia-east1","tag":"fh-<My Version> "}}],"cleanUrls":true,"trailingSlashBehavior":"REMOVE"},"labels":{"deployment-tool":"cli-firebase","firebase-web-framework":"next_ssr"},"createTime":"2024-05-01T07:41:47.528736Z","createUser":{"email":"<My Email>"},"finalizeTime":"2024-05-01T08:03:13.222627Z","finalizeUser":{"email":"<My Email>"}}
[2024-05-01T08:03:12.868Z] [hosting] finalized version for <My project>:[object Object]
✔  hosting[<My project>]: version finalized 
i  hosting[<My project>]: releasing new version... 
[2024-05-01T08:03:12.869Z] >>> [apiv2][query] POST https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/<My project>/channels/live/releases versionName=projects%2F<My Project ID>%2Fsites%2F<My project>%2Fversions%2F<My Version> 
[2024-05-01T08:03:12.869Z] >>> [apiv2][body] POST https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/<My project>/channels/live/releases {}
[2024-05-01T08:03:13.418Z] <<< [apiv2][status] POST https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/<My project>/channels/live/releases 200
[2024-05-01T08:03:13.418Z] <<< [apiv2][body] POST https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/<My project>/channels/live/releases {"name":"projects/<My Project ID>/sites/<My project>/channels/live/releases/<My release>","version":{"name":"projects/<My Project ID>/sites/<My project>/versions/<My Version> ","status":"FINALIZED","config":{"headers":[{"headers":{"x-next-cache-tags":"_N_T_/layout,_N_T_/_not-found/layout,_N_T_/_not-found/page,_N_T_/_not-found"},"glob":"/_not-found"}],"rewrites":[{"glob":"**","run":{"serviceId":"<My project>","region":"asia-east1","tag":"fh-<My Version> "}}],"cleanUrls":true,"trailingSlashBehavior":"REMOVE"},"labels":{"firebase-web-framework":"next_ssr","deployment-tool":"cli-firebase"},"createTime":"2024-05-01T07:41:47.528736Z","createUser":{"email":"<My Email>","imageUrl":"<My img>"},"finalizeTime":"2024-05-01T08:03:13.222627Z","finalizeUser":{"email":"<My Email>","imageUrl":"<My img>"}},"type":"DEPLOY","releaseTime":"2024-05-01T08:03:13.222Z","releaseUser":{"email":"<My Email>","imageUrl":"<My img>"}}
[2024-05-01T08:03:13.419Z] [hosting] release: {"name":"projects/<My Project ID>/sites/<My project>/channels/live/releases/<My release>","version":{"name":"projects/<My Project ID>/sites/<My project>/versions/<My Version> ","status":"FINALIZED","config":{"headers":[{"headers":{"x-next-cache-tags":"_N_T_/layout,_N_T_/_not-found/layout,_N_T_/_not-found/page,_N_T_/_not-found"},"glob":"/_not-found"}],"rewrites":[{"glob":"**","run":{"serviceId":"<My project>","region":"asia-east1","tag":"fh-<My Version> "}}],"cleanUrls":true,"trailingSlashBehavior":"REMOVE"},"labels":{"firebase-web-framework":"next_ssr","deployment-tool":"cli-firebase"},"createTime":"2024-05-01T07:41:47.528736Z","createUser":{"email":"<My Email>","imageUrl":"<My img>"},"finalizeTime":"2024-05-01T08:03:13.222627Z","finalizeUser":{"email":"<My Email>","imageUrl":"<My img>"}},"type":"DEPLOY","releaseTime":"2024-05-01T08:03:13.222Z","releaseUser":{"email":"<My Email>","imageUrl":"<My img>"}}
✔  hosting[<My project>]: release complete 

✔  Deploy complete! 

Additional info

"region":"asia-east1"
npm -v: 10.5.0
npm list -g: firebase-tools@13.7.5
next: ^14.2.3

Update 2 hr later:
It seems Google is running an AB test of something. I tried to upload it again and it fell into the older version again...

@mlawd
Copy link

mlawd commented May 1, 2024

Any update on this? I'm deploying with the region set to europe-west1 in the frameworksBackend config and getting the above issue. Disabling the pintags experiment works locally, but not sure I can do this in CI without reworking them to not use w9jds/firebase-action

@garrettlove8
Copy link

Not sure if this was luck or if it's officially fixed, but I just had a successful deploy in us-east1 using w9jds/firebase-action@v13.6.1

@chrisryanouellette
Copy link

I use FirebaseExtended/action-hosting-deploy@v0 and was able to deploy today without disabling pintags to us-east1.

@colerogers
Copy link
Contributor

Hey folks, apologies for the headache. It seems there was a backend issue on the Cloud Run API that caused issues deploying/re-deploying 2nd gen functions. This applies to the Web Frameworks code path since we use the Run API directly. The fix has been rolling out to different regions starting a few days ago, so most of you should be unblocked now (or very soon)

@c00ley
Copy link

c00ley commented May 3, 2024

Thanks @colerogers I noticed cloud run --update labels was working and no longer asking about, presumably, something to do with cloud run's (knative/k8s'runtimeClass)

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