Make it easier for admins to resync project mirrors
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=5500) </details> <!--IssueSummary end--> @dstanley and I were on a customer call, and the database encryption key was switched so most of the `project_mirror_data` were undecipherable, resulting in OpenSSL errors. We ended up finding all the invalid entries via: ```ruby ProjectImportData.find_each do |data| begin data.credentials rescue => e puts data.id end end ``` The customer was trying to force an update of a scheduled mirror, but it was stuck in the "Update Scheduled" state. Attempting to force a sync via: ```ruby UpdateAllMirrorsWorker.new.perform ``` Would result in nothing happening. We checked `ProjectMirrorData#next_execution_timestamp` and `Project#import_status` and tried to modify the values to do something. ```ruby RepositoryUpdateMirrorWorker.new.perform(project.id) ``` Would result in such error messages as: ```sh Project build/test/redis_exporter was in inconsistent state: finished ``` @dstanley I think this works: ```ruby project = Project.find_by_full_path('build/test/redis_exporter') project.import_fail('manually failed') project.mirror_data.update(next_execution_timestamp: Time.now) UpdateAllMirrorsWorker.new.perform ``` I think there needs be a number of improvements: 1. Admins (or someone with special privileges) should be able to cancel and schedule an import immediately 2. UpdateAllMirrorsWorker should not fail if a single entry in the database has corrupted attr_encrypted fields /cc: @tiagonbotelho, @DouweM
issue