ARTIFACTORY:如何解决元数据迁移问题升级后,由于sha256值缺失的工件

Shivani Budhodi
2023-01-22 11:06

概述:

Artifactory原生支持sha-256,当文件部署到任何存储库时,Artifactory计算sha-256校验和,并在数据库中维护。Artifactory 5.5实现了一个数据库模式更改,以本地支持SHA-256校验和。

可能在某些情况下,Artifactory被多次升级到不同的6。xversions which have sha-256 compatibility, however, in certain cases, there could be a few artifacts that still has no sha-256 calculated as it was deployed on Artifactory when running on a version below 5.5

当从5.5以下版本使用Artifactory时,同时升级到最新版本7。x, there is a possibility that there could be some artifacts that might not be having a sha-256 associated with it. This indicates that the sha-256 were not calculated for the specific artifacts nor the执行sha-256迁移

因此,在升级到7。xversion, it is possible to encounter the below error which indicates that sha-256 entry is not available for this specific artifact in the database.java.lang.IllegalStateException:执行api/v1/packages/gav%3A%2F% 2forge .maven失败。内部服务器错误和响应消息:{"cause":"处理请求时内部错误","message":" id为(gav://org.maven.test:junit)的补丁包错误:插入尝试后未在db中找到匹配的文件"}
由于这个未计算的SHA-256校验和在迁移期间可以在UI中观察到以下警告:

用户添加图片
调试错误的步骤:

步骤1:首先,检查数据库中是否存在没有SHA-256值的工件。

为此,在数据库中运行以下查询,以了解有多少工件没有SHA-256值。

查询:

$ select count(*) as " Nodes: No-SHA256 " from node_type=1且sha256为NULL的节点;
$ select count(*) as " Binaries: No-SHA256" from binary where sha256为NULL;

如果输出不为零,则意味着数据库中存在没有计算SHA-256校验和的工件。

步骤2:因此,我们需要通过添加JFROG_HOME/artifactory/var/etc/artifactory/artifactory.system.properties中提到的以下参数来执行sha-256迁移
文件放在Artifactory实例的每个节点上。
SHA2迁移块
artifactory.sha2.migration.job.enabled = true
artifactory.sha2.migration.job.queue.workers = 5

更新Artifactory .system.properties文件后,滚动重启Artifactory。

通过将上述属性添加到artifactory.system。属性,将为当前在数据库中没有条目的每个工件生成SHA-256值。

一旦迁移完成,我们将能够在UI上查看包页面,而没有任何警告,并且在日志中观察到的错误消息应该被消除。

注意:SHA256迁移后,建议迁移完成后移除所有与SHA256相关的系统属性,并重新启动。