gitpod-io / gitpod

The developer platform for on-demand cloud development environments to create software faster and more securely.
https://www.gitpod.io
GNU Affero General Public License v3.0
12.95k stars 1.24k forks source link

db-sync fails to sync SSHPublicKeys #11265

Closed geropl closed 2 years ago

geropl commented 2 years ago

(internal discussion)

For unknown reasons db-sync refuses to insert public SSH keys. We have to find the offending query (e.g. by using staging) and understand what MySQL does not like about it.)

loujaybee commented 2 years ago

Thanks, Gero. I previously observed that I needed to restart workspace after uploading an SSH key for the connection to establish, I was guessing at the time that it could be a DB sync issue. Might be related.

geropl commented 2 years ago

I previously observed that I needed to restart workspace after uploading an SSH key for the connection to establish, I was guessing at the time that it could be a DB sync issue.

That sounds unrelated. Here the effect would be: If I connect to US cluster and store a secret, I cannot use it in the EU cluster.

akosyakov commented 2 years ago

@mustard-mh I don't see https://github.com/gitpod-io/gitpod/blob/cf7d6de5b03e39dadb4f1c5bd18d3fb1b9237585/components/gitpod-db/src/typeorm/entity/db-code-sync-resource.ts#L47 on DBUserSshPublicKey

@geropl Is it not necessary anymore?

geropl commented 2 years ago

@geropl Is it not necessary anymore?

It's not technical necessary, but good practice to try to keep TS and SQL in sync.

akosyakov commented 2 years ago

@geropl @mustard-mh Can we verify somehow that all necessary db sync indexes are in place in production database?

andrew-farries commented 2 years ago

The error lies in the sql generated here:

https://github.com/gitpod-io/gitpod/blob/a75d1685054b57019d155b16f979c638ae351cac/components/ee/db-sync/src/export.ts#L143-L145

Where we are not properly escaping the column names, which causes an error for the key column as it's a SQL keyword.