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

Logs of completed prebuilds are not loaded due to CORS issues #5084

Closed
AlexTugarev opened this issue Aug 6, 2021 · 16 comments · Fixed by #5480
Closed

Logs of completed prebuilds are not loaded due to CORS issues #5084

AlexTugarev opened this issue Aug 6, 2021 · 16 comments · Fixed by #5480
Assignees
Labels
feature: prebuilds team: webapp Issue belongs to the WebApp team type: bug Something isn't working

Comments

@AlexTugarev
Copy link
Member

Bug description

Browser agents won't load prebuild logs from pre-signed URL like

https://storage.googleapis.com/gitpod-prod-user-000000000000000000000000000/workspaces/teal-sadf-asdf/instances/000000-11111-22222-33333/logs/0?Expires=1628177023&GoogleAccessId=prod-meta-eu01-storage%40gitpod-191109.iam.gserviceaccount.com&Signature=

CORS error from the network tab is MissingAllowOriginHeader

blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

cc. @geropl, @csweichel

Steps to reproduce

Try to access logs of a prebuild after it's done.

Expected behavior

CORS settings are applied to the bucket and GCS will response with the missing headers.

Example repository

No response

Anything else?

No response

@AlexTugarev AlexTugarev added the type: bug Something isn't working label Aug 6, 2021
@ajhalili2006
Copy link

Does Google Cloud allows the access of files in a storage bucket as part of CORS request or do we need to do some NGINX/Caddy proxy tricks?

@csweichel
Copy link
Contributor

We could set CORS config when creating a new bucket, something like here:

CORS: []gcpstorage.CORS{
	{
		Origins: []string{"*"},
		Methods: []string{"GET"},
		MaxAge:  6 * time.Hour,
	},
},

However, this comes with a set of drawbacks:

  • in this naive form it would only work for new buckets
  • it only works in GCP - for minio no such option exists. Does minio need this?

The other solution, route it all through the proxy is something we're already doing for workspace content download. We have a custom caddy plugin that implements the mechanism. We could do something similar here.

The main question we'd need to answer is if in this case we'd be paying for egress twice: once from the bucket to our proxy, and then from the proxy to the client (not so much of a concern for workspace content download - this doesn't happen so often). Frankly, I would not expect this to be a problem, we should check.

@AlexTugarev
Copy link
Member Author

@csweichel, first I was not sure if applying these bucket attributes in general would make sense, because it all contents of /gitpod-prod-user-000000000000000000000000000/**/*. But there isn't any additional risk to that either, because once the URL is served it can be used with HTTP clients other than browsers to ignore CORS.

@csweichel
Copy link
Contributor

We'd need to apply the CORS attributes to all buckets. The one you refer to only holds the image builds, but not prebuild logs.
In the future the image build logs will carry user association as well, hence be in the user buckets, too.

@AlexTugarev
Copy link
Member Author

The one you refer to only holds the image builds, but not prebuild logs.

Nope, that's the log output of the workspace instance for the prebuild I'm interested in. These URLs are returned by the server now.

WDYT of patching this when we call ensureExists?

@csweichel
Copy link
Contributor

The one you refer to only holds the image builds, but not prebuild logs.

Nope, that's the log output of the workspace instance for the prebuild I'm interested in. These URLs are returned by the server now.

I meant that gitpod-prod-user-000000000000000000000000000 only holds the image-build logs.

WDYT of patching this when we call ensureExists?

Do we have the same CORS issue with minio?

@AlexTugarev
Copy link
Member Author

🤦🏻 oh this does exist indeed. I used that as a template. replace with gitpod-prod-user-ID then, please

@JanKoehnlein
Copy link
Contributor

Sorry, but due to high load and little resources in groundwork, we cannot schedule this issue ATM.
Please try to solve it with the crew or bring it in again in a few days.

@svenefftinge
Copy link
Member

The other solution, route it all through the proxy is something we're already doing for workspace content download. We have a custom caddy plugin that implements the mechanism. We could do something similar here.

I'm much in favor of this, as it provides us a central control and solves this for other storage providers (minio). We are talking about log files of prebuilds so I assume egress isn't a problem here?

@svenefftinge
Copy link
Member

FWIW here's the caddy plugin for the workspace content download : https://github.com/gitpod-io/gitpod/blob/main/components/proxy/plugins/workspacedownload/workspace_download.go

@svenefftinge
Copy link
Member

svenefftinge commented Aug 23, 2021

Would be good if someone (@geropl, @corneliusludmann, @aledbf maybe?) with more knowledge of caddy can take this. I assume it would be relatively easy based on the existing plugin.

@corneliusludmann
Copy link
Contributor

I can have a look but I don't know much about Teams & Projects yet. Can someone give me an intro to what I need to do to be able to download prebuild logs?

@csweichel
Copy link
Contributor

/team meta

@roboquat roboquat added the team: webapp Issue belongs to the WebApp team label Aug 25, 2021
@csweichel
Copy link
Contributor

/schedule

@roboquat
Copy link
Contributor

@csweichel: Issue scheduled in the meta team (WIP: 0)

In response to this:

/schedule

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@geropl
Copy link
Member

geropl commented Sep 2, 2021

The code is #5480, but needs to be tested. Was blocked by some problems with nodeAffinity of imagebuild workspaces (issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: prebuilds team: webapp Issue belongs to the WebApp team type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants