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

Downgrade issue from 2.12.1 to 2.11.0 #21470

Open
swasthibp opened this issue Jan 29, 2025 · 6 comments
Open

Downgrade issue from 2.12.1 to 2.11.0 #21470

swasthibp opened this issue Jan 29, 2025 · 6 comments

Comments

@swasthibp
Copy link

Hi Team,

I am trying to rollback my system after a successful upgrade to 2.12.1 back to 2.11.0. But this seems to be not possible as i see core is failing with below logs:
2025-01-29T13:46:05.221154712+02:00 stdout F 2025-01-29T11:46:05Z [INFO] [/lib/config/config.go:92]: init secret store
2025-01-29T13:46:05.221154712+02:00 stdout F 2025-01-29T11:46:05Z [INFO] [/core/main.go:166]: configurations initialization completed
2025-01-29T13:46:05.221154712+02:00 stdout F 2025-01-29T11:46:05Z [INFO] [/common/dao/base.go:67]: Registering database: type-PostgreSQL host-postgresql port-5432 database-registry sslmode-"disable"
2025-01-29T13:46:05.225712516+02:00 stdout F 2025-01-29T11:46:05Z [INFO] [/common/dao/base.go:72]: Register database completed
2025-01-29T13:46:05.234596053+02:00 stdout F 2025-01-29T11:46:05Z [INFO] [/common/dao/pgsql.go:135]: Upgrading schema for pgsql ...
2025-01-29T13:46:05.234968323+02:00 stdout F 2025-01-29T11:46:05Z [INFO] [/go/pkg/mod/github.com/golang-migrate/migrate/[email protected]/migrate.go:810]: error: no migration found for version 150: read down for version 150 .: file does not exist
2025-01-29T13:46:05.235036196+02:00 stdout F 2025-01-29T11:46:05Z [ERROR] [/common/dao/pgsql.go:140]: Failed to upgrade schema, error: "no migration found for version 150: read down for version 150 .: file does not exist"
2025-01-29T13:46:05.235200032+02:00 stdout F 2025-01-29T11:46:05Z [FATAL] [/core/main.go:201]: failed to migrate the database, error: no migration found for version 150: read down for version 150 .: file does not exist

Steps to reproduce issue:

  1. Rollback harbor version from 2.12.1 to 2.11.0
@swasthibp
Copy link
Author

Hi Team,

Can you please help here? do we need to update any parameter to allow us this rollback?

@Vad1mo
Copy link
Member

Vad1mo commented Jan 30, 2025

Downgrade isn't always possible if table changes are involved.
Suggest you change in your DB the schema_migrations back to version 140 and see if that works already.

if not, this are the table changes in 2.12, so you could remove those columns and it should be ok.

ALTER TABLE robot ADD COLUMN IF NOT EXISTS creator_ref integer default 0;
ALTER TABLE robot ADD COLUMN IF NOT EXISTS creator_type varchar(255);

ALTER TABLE p2p_preheat_policy ADD COLUMN IF NOT EXISTS scope varchar(255);

The safest way, however, is to roll back the DB

@swasthibp
Copy link
Author

swasthibp commented Jan 30, 2025

Hi @Vad1mo,

The downgrade to lower versions like 2.10.2 and 2.10.0 has worked perfectly fine, how is that possible? we didnt expect it to fail when coming back to 2.11.0 since PG version is 15 between 2.11.0 and 2.12.1, while 2.10.0 and 2.10.2 had PG14 versions

@Vad1mo
Copy link
Member

Vad1mo commented Jan 30, 2025

You message does not provide enough context to be able to provide you with an answer

@swasthibp
Copy link
Author

swasthibp commented Feb 4, 2025

Hi @Vad1mo,

We have a scenario where we are trying to upgrade deployments with version 2.10.0, 2.10.2, 2.11.0 to the latest harbor version 2.12.1(critical vulnerability is fixed here).
One of the upgrade scenarios is: 2.10.0>2.12.1>2.11.0. Here we see the failure of harbor with the DB errors i attached. My question is between 2.12.1 and 2.11.0, there are no PG changes (both PG versions are PG15) but still harbor fails. While there are DB version migrations between 2.10.0 and 2.12.1(PG14 and PG15 respectively) but there are no failures.

@stonezdj
Copy link
Contributor

stonezdj commented Feb 7, 2025

You should update the schema_migrations after rollback the db schema

docker exec -it harbor-db bash
psql -U postgres -d registry
update schema_migrations set version = '140';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants