Ambiguous error message when missing `public dir`
Problem
Today, when we rake pages.rake
for the purpose of importing pages into new architecture
we sometimes end-up with missing public directory
on NFS storage.
This is expected type of ERROR
, as when we initially created pages_metadatum
we did not check
the presence of the public dir
on a disk, so some percentage of projects will not have public dir
.
However, when we run the rake task with a pages_migration_mark_as_not_deployed
(which should be on by default)
we spell out that as an error:
E, [2021-03-02T00:43:12.429639 #2530] ERROR -- : project_id: 17048520 /var/opt/gitlab/gitlab-rails/shared/pages/my/project failed to be migrated in 0.01 seconds: Can't create zip archive: Can not find valid public dir in /var/opt/gitlab/gitlab-rails/shared/pages/my/project
Proposal
What we should do?
- Ensure that we consider this error to be explicitly defined as not erroring condition, rather a warning condition
- Likely improve the
Pages::ZipDirectoryService
to return a proper indication what type of error is that - As part of
Migration::MigrateLegacyStorageToDeploymentService
treat that as awarning
or a success if a feature flag is enabled, as this is more like a corrective action
module Pages
class ZipDirectoryService
def execute
unless resolve_public_dir
return error("Can not find valid public dir in #{@input_dir}", missing_public: true)
end
end
end
end
module Pages
class MigrateLegacyStorageToDeploymentService
def execute_unsafe
zip_result = ::Pages::ZipDirectoryService.new(
project.pages_path,
ignore_invalid_entries: @ignore_invalid_entries
).execute
if zip_result[:status] == :error
if zip_result[:missing_public] && Feature.enabled?(:pages_migration_mark_as_not_deployed, project)
unless project.pages_metadatum&.reload&.pages_deployment
project.mark_pages_as_not_deployed
end
return success(message: "Missing public directory at #{project.pages_path}. Corrected project to be not deployed")
end
return error("Can't create zip archive: #{zip_result[:message]}")
end
end
end
end
module Pages
class MigrateFromLegacyStorageService
def migrate_project(project)
if result[:status] == :success
@logger.info("project_id: #{project.id} #{project.pages_path} has been migrated in #{time.round(2)} seconds: #{result[:message]}")
end
end
end
end
Related to
Edited by Kamil Trzciński