When you try to delete or disable the rule via UI, you see an Internal Server Error.
In the core.log, you see the following entries:
Nov 23 10:25:07 172.20.36.1 core[4535]: 2020-11-23T10:25:07Z [ERROR] /lib/http/error.go:54: {"errors":[{"code":"INTERNAL_SERVER_ERROR","message":"failed to update the policy 9: failed to unschedule the policy 9: job not found"}]}
This is a known issue with Harbor 2.x and it will be fixed in future versions of Harbor.
For more information about this issue, refer to below Github page:
https://github.com/goharbor/harbor/issues/13342
As a work around, manually remove these records from the database to delete the replication jobs.
Login to Harbor vm using bosh:
bosh -d <deployment-name> -d ssh
Switch to root mode by running: sudo -i
Export the Docker alias:
alias docker='/var/vcap/packages/docker/bin/docker -H unix:///var/vcap/sys/run/docker/dockerd.sock'
Run Docker images and ensure the harbor-db container is running.
Connect to "harbor-db" container:
docker exec -it harbor-db /bin/bash
Connect to the database:
psql -U postgres -d registry
Run the below command and note down the policy ID that you want to delete:
select * from replication_schedule_job;
Remove the policy from database records, ensure to replace the policy ID with the one that you would like to delete:
delete from replication_schedule_job where policy_id=9;
delete from replication_policy where id=9;