Skip to content

CDS database engine does not account for schema parameter #7197

@gsalingu

Description

@gsalingu

While running on new versions of postgresql the automatic schema selection at connection time does not seem to work


user=cds-cdn password='PASSWORD' dbname=cds host=db port=5000 sslmode=disable connect_timeout=10 options='-csearch_path=cdn'
Error: pq: permission denied for schema public
github.com/ovh/cds/sdk.WithStack
	/home/gsalingu/github/ovh/cds/sdk/error.go:638
github.com/ovh/cds/engine/database/dbmigrate.lockMigrate
	/home/gsalingu/github/ovh/cds/engine/database/dbmigrate/migrate.go:68
github.com/ovh/cds/engine/database/dbmigrate.Do
	/home/gsalingu/github/ovh/cds/engine/database/dbmigrate/migrate.go:36
main.ApplyMigrations
	/home/gsalingu/github/ovh/cds/engine/cmd_database.go:315
main.databaseUpgradeCmdFunc
	/home/gsalingu/github/ovh/cds/engine/cmd_database.go:133
github.com/spf13/cobra.(*Command).execute
	/home/gsalingu/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:987
github.com/spf13/cobra.(*Command).ExecuteC
	/home/gsalingu/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115
github.com/spf13/cobra.(*Command).Execute
	/home/gsalingu/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
main.main
	/home/gsalingu/github/ovh/cds/engine/main.go:26
runtime.main
	/home/gsalingu/.go/src/runtime/proc.go:272
runtime.goexit
	/home/gsalingu/.go/src/runtime/asm_amd64.s:1700

the "cds-cdn" user has only permissions on the "cdn" schema, that showcases the fact that in spite of selecting the cdn schema in the command line the binary tried to connect to the public schema

I tried to update the code generating the connection string itself in several ways but postgresql does not seem to play nice with this.

What works well is an exec statement right after the connection
I will relay a pull request to propose a fix shortly after submission of this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions