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

Migrate-AdminDB Fails With User Not admindbuser #137

Closed
2 tasks done
estein9825 opened this issue Feb 4, 2023 · 1 comment · Fixed by #200
Closed
2 tasks done

Migrate-AdminDB Fails With User Not admindbuser #137

estein9825 opened this issue Feb 4, 2023 · 1 comment · Fixed by #200
Assignees
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Milestone

Comments

@estein9825
Copy link

estein9825 commented Feb 4, 2023

Expected vs actual behavior

Despite allowing one to change the default user for postgres, if one does not use admindbuser, then migrate-admindb step will fail with:

error: Dirty database version 1. Fix and force version.

Attempting the same up command when locally connected to the database using the steps here results in the following error:

error: migration failed: function uuid_generate_v4() does not exist (column 30) in line 2: CREATE TABLE IF NOT EXISTS authsrv_project (
    id uuid NOT NULL default uuid_generate_v4(),
    name character varying(256) NOT NULL,
    description character varying(512) NOT NULL,
    created_at timestamp with time zone NOT NULL,
    modified_at timestamp with time zone NOT NULL,
    trash boolean NOT NULL,
    organization_id uuid,
    partner_id uuid,
    "default" boolean NOT NULL
);

ALTER TABLE authsrv_project OWNER TO admindbuser;

ALTER TABLE ONLY authsrv_project ADD CONSTRAINT authsrv_project_pkey PRIMARY KEY (id);

-- update when we have more than one org
CREATE UNIQUE index authsrv_project_unique_name ON authsrv_project (name) WHERE trash IS false;

CREATE INDEX authsrv_project_name_1b8dd279 ON authsrv_project USING btree (name);

CREATE INDEX authsrv_project_name_1b8dd279_like ON authsrv_project USING btree (name varchar_pattern_ops);

CREATE INDEX authsrv_project_organization_id_77437387 ON authsrv_project USING btree (organization_id);

CREATE INDEX authsrv_project_partner_id_3d505b76 ON authsrv_project USING btree (partner_id);

ALTER TABLE ONLY authsrv_project
    ADD CONSTRAINT authsrv_project_organization_id_77437387_fk_authsrv_o FOREIGN KEY (organization_id)
    REFERENCES authsrv_organization(id) DEFERRABLE INITIALLY DEFERRED;

ALTER TABLE ONLY authsrv_project
    ADD CONSTRAINT authsrv_project_partner_id_3d505b76_fk_authsrv_partner_id FOREIGN KEY (partner_id)
    REFERENCES authsrv_partner(id) DEFERRABLE INITIALLY DEFERRED;
 (details: pq: function uuid_generate_v4() does not exist)

The reason for this is because of this command:

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
GRANT EXECUTE ON FUNCTION uuid_generate_v4() TO admindbuser;

Which is found here

Steps to reproduce the bug

  1. Create a user other than admindbuser in postgres
  2. Update DSN and other database configurations with that user and password.
  3. Leave automigrate as true
  4. Let postgres startup normally

Are you using the latest version of the project?

You can check your version by running helm ls|grep '^<deployment-name>' or using pctl, pctl version, and provide the output.

VERSION: 0.1.0
BUILD: 0.1.0
BUILD-TIME: 1656329967
ARCH: darwin/amd64

What is your environment setup? Please tell us your cloud provider, operating system, and include the output of kubectl version --output=yaml and helm version. Any other information that you have, eg. logs and custom values, is highly appreciated!

Kubectl

clientVersion:
  buildDate: "2022-08-23T17:44:59Z"
  compiler: gc
  gitCommit: a866cbe2e5bbaa01cfd5e969aa3e033f3282a8a2
  gitTreeState: clean
  gitVersion: v1.25.0
  goVersion: go1.19
  major: "1"
  minor: "25"
  platform: darwin/amd64
kustomizeVersion: v4.5.7
serverVersion:
  buildDate: "2022-11-29T18:41:42Z"
  compiler: gc
  gitCommit: 52e500d139bdef42fbc4540c357f0565c7867a81
  gitTreeState: clean
  gitVersion: v1.22.16-eks-ffeb93d
  goVersion: go1.16.15
  major: "1"
  minor: 22+
  platform: linux/amd64

helm version

version.BuildInfo{Version:"v3.10.3", GitCommit:"835b7334cfe2e5e27870ab3ed4135f136eecc704", GitTreeState:"clean", GoVersion:"go1.19.4"}

(optional) If you have ideas on why the bug happens or how it can be solved, please provide it here

The user that is specified in DSN should be the same one that is granted those rights. An additional command should be added to the migrate-admindb container that replaces admindbuser with the appropriate value prior to running the up command. A simple sed command should be sufficient given $DB_USER is an accessible environment variable.

  • I've described the bug, included steps to reproduce it, and included my environment setup with all customizations.
  • I'm using the latest version of the project.
@estein9825 estein9825 added the bug Something isn't working label Feb 4, 2023
@estein9825 estein9825 changed the title Add Support for Postres 13+ Add Support for Postres 13+ --> Migrate-AdminDB Fails Otherwise Feb 4, 2023
@estein9825 estein9825 changed the title Add Support for Postres 13+ --> Migrate-AdminDB Fails Otherwise Migrate-AdminDB Fails With User Not admindbuser Feb 4, 2023
@nirav-rafay nirav-rafay added this to the Needs Prioritization milestone Feb 7, 2023
@akshay196 akshay196 added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Mar 26, 2023
@akshay196 akshay196 added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 5, 2023
@akshay196
Copy link
Member

This is critical one. I think there should not be any db user reference in migration files.

@niravparikh05 niravparikh05 linked a pull request Apr 13, 2023 that will close this issue
5 tasks
@niravparikh05 niravparikh05 self-assigned this Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants