When you initiate the VMware Harbor upgrade from Ops Manager in PKS environment, it fails with below error:
Failed to update database, error: pq: must be owner of relation schema_migrations
In the Harbor instance, you see Notary container is not running.
In the /var/vcap/sys/log/harbor-app-logs/notary-server.log file, you see the entries similar to:
Apr 11 09:12:25 172.30.1.1 notary-server[5973]: 2019/04/11 09:12:25 Failed to update database, error: pq: must be owner of relation schema_migrations
Apr 11 09:13:25 172.30.1.1 notary-server[5973]: 2019/04/11 09:13:25 Updating database.
Apr 11 09:13:25 172.30.1.1 notary-server[5973]: 2019/04/11 09:13:25 Failed to update database, error: pq: must be owner of relation schema_migrations
Apr 11 09:14:26 172.30.1.1 notary-server[5973]: 2019/04/11 09:14:26 Updating database.
This issue occurs if the db owner for the notary-server and notary-signer does not match with the expected values, server & signer respectively.
This is a known issue when you followed the Harbor upgrade path 1.5.x > 1.6.x> 1.7.x.
This issue will be resolved in VMware Harbor 1.7.5.
To work around this issue, updated the db owner info to default expected values:
Set Docker alias : alias docker='/var/vcap/packages/docker/bin/docker -H unix:///var/vcap/sys/run/docker/dockerd.sock'
Run docker ps to see if notary-server and notary-signer containers are running or not.
Login to harbor-db container and connect to postgres by running:
docker exec -it harbor-db /bin/bash
psql -U postgres
Connect to notaryserver db and check the current owner:
\c notaryserver
\dt schema_migrations
Update the notaryserver db owner details as per below:
ALTER TABLE tuf_files OWNER TO server;
ALTER SEQUENCE tuf_files_id_seq OWNER TO server;
ALTER TABLE change_category OWNER TO server;
ALTER TABLE changefeed OWNER TO server;
ALTER SEQUENCE changefeed_id_seq OWNER TO server;
ALTER TABLE schema_migrations OWNER TO server;
SELECT setval('changefeed_id_seq', max(id)) FROM changefeed;
ALTER TABLE "changefeed" ALTER COLUMN "id" SET default nextval('changefeed_id_seq');
Now, connect to notarysigner db and check the current owner:
\c notarysigner
\dt schema_migrations
Update the notarysigner db owner details as per below:
ALTER TABLE private_keys OWNER TO signer;
ALTER SEQUENCE private_keys_id_seq OWNER TO signer;
ALTER TABLE schema_migrations OWNER TO signer;
exit from the database and apply the changes from Ops Manager.
\q