在尝试通过API清除Jfrog Artifactory中虚拟Helm存储库缓存时出现HTTP 400错误。

huangapple go评论54阅读模式
英文:

Getting an HTTP 400 error when trying to zap the cache of a virtual Helm repo in Jfrog Artifactory via API

问题

I'm having a problem with the cache of a virtual Helm repository (containing only a local repo) on a self-hosted JFrog Artifactory (version 7.49.8). I was trying to zap the cache of the entire repo via the API https://jfrog.com/help/r/jfrog-rest-apis/zap-cache.

However, I keep getting status 400 errors, no matter whether I try the virtual or repo or the local repo (as the error message suggests):

curl -H "X-Jfrog-Art-Api: $ADMIN_API_KEY" \
  http://artifactory.my-company.com/artifactory/api/zap/my-virtual-helm-repo

{
    "errors": [
        {
            "status": 400,
            "message": "Repository 'my-virtual-helm-repo' is not a local repository"
        }
    ]
}

Alright, so I tried zapping the local repo that's included in the virtual repo (even though the UI doesn't offer zapping of local repos):

curl -H "X-Jfrog-Art-Api: $ADMIN_API_KEY" \
  http://artifactory.my-company.com/artifactory/api/zap/my-included-local-helm-repo

{
    "errors": [
        {
            "status": 400,
            "message": "Got a zap request on a non-local-cache node 'my-included-local-helm-repo:'."
        }
    ]
}

I'm able to Zap Cache the virtual repo via the Artifactory UI. What's the trick to get the REST call to work?

英文:

I'm having a problem with the cache of a virtual Helm repository (containing only a local repo) on a self-hosted JFrog Artifactory (version 7.49.8). I was trying to zap the cache of the entire repo via the API https://jfrog.com/help/r/jfrog-rest-apis/zap-cache.

However, I keep getting status 400 errors, no matter whether I try the virtual or repo or the local repo (as the error message suggests):

curl -H "X-Jfrog-Art-Api: $ADMIN_API_KEY" \
  http://artifactory.my-company.com/artifactory/api/zap/my-virtual-helm-repo

{
    "errors": [
        {
            "status": 400,
            "message": "Repository 'my-virtual-helm-repo' is not a local repository"
        }
    ]
}

Alright, so I tried zapping the local repo that's included in the virtual repo (even though the UI doesn't offer zapping of local repos):

curl -H "X-Jfrog-Art-Api: $ADMIN_API_KEY" \
  http://artifactory.my-company.com/artifactory/api/zap/my-included-local-helm-repo

{
    "errors": [
        {
            "status": 400,
            "message": "Got a zap request on a non-local-cache node 'my-included-local-helm-repo:'."
        }
    ]
}

I'm able to Zap Cache the virtual repo via the Artifactory UI. What's the trick to get the REST call to work?

答案1

得分: 1

Part 1 - What does Zap cache serve?

将这个回答分成两个部分:

第一部分 - Zap缓存服务是什么?

Zap缓存指的是强制使检索缓存周期和未命中检索缓存周期超时。您还可以清除整个存储库缓存。这些信息源自JFrog文档。换句话说,Zap缓存功能会重置整个缓存存储库的MCRP,确保在Zap之后向客户端发送新鲜的元数据。Zap Cache 链接

需要准确和最新元数据的用户应该降低此设置,可能将其设置为“0”以禁用它。这将导致拉取速度较慢,因为Artifactory会频繁提供新鲜的元数据。但是,这确保始终使用最准确的数据。如果用户优先考虑性能,他们应该增加此设置。然而,这样做意味着Artifactory会更频繁地使用其缓存,牺牲了准确性。请参考“远程存储库如何工作”以更好地理解。

第二部分 - 了解失败的原因

在理解了这个术语及其重要性之后,值得提到,清除虚拟存储库的缓存与清除远程存储库的缓存不同(API端点不同)。

要在远程存储库上触发清除缓存API,与您上面提到的方式完全相同。有关远程存储库如何工作的有趣阅读

要在虚拟存储库上触发清除缓存:

curl -H "X-Jfrog-Art-Api: $ADMIN_API_KEY" 'http://artifactory.my-company.com/artifactory/api/artifactactions/zapVirtual' -H 'Content-Type: application/json' -H 'Accept: application/json, text/plain' --data-raw '{"repoKey":"npm-virtual","path":""}'

{"info":"'def-npm' 的缓存已成功清除。"}

英文:

Let's break this answer into two parts:

Part 1 - What does Zap cache serve?

Zapping a cache refers to forcing the Retrieval Cache Period and Missed Retrieval Cache Period to time out. You can also zap an entire repository cache. This information is derived from JFrog documentation. In other words, the Zap Cache function resets the MCRP for the whole cached repository, ensuring that fresh metadata is sent to the client after the Zap.Zap Cache Link

Users who need accurate and up-to-date metadata should lower the setting, potentially disabling it by setting it to "0". This action would result in slower pulls because Artifactory would frequently serve fresh metadata. However, this ensures that the most accurate data is always used. If users prioritize performance, they should increase this setting. Nevertheless, doing so means that Artifactory will use its cache more often than not, compromising accuracy. Refer to "How does remote repository work" to gain a better understanding.

Part 2 - Understanding the reason for failure

After comprehending the term and its significance, it's important to mention that zapping cache on virtual repository differs from zapping cache from remote repository ( The API endpoint is different)

For triggering a zap cache API on remote repository it is exactly as you mentioned above. interesting read on how remote repositories work

For triggering a zap cache on a virtual repository:

curl -H "X-Jfrog-Art-Api: $ADMIN_API_KEY" 'http://artifactory.my-company.com/artifactory/api/artifactactions/zapVirtual' -H 'Content-Type: application/json' -H 'Accept: application/json, text/plain' --data-raw '{"repoKey":"npm-virtual","path":""}' 

{"info":"The caches of 'def-npm' have been successfully zapped."}

答案2

得分: 0

要解决此问题,您可以尝试通过检查API请求的URL或负载中是否存在任何错误,验证您是否具有执行操作所需的足够权限,并确保Jfrog Artifactory的服务器或网络没有临时问题来进行故障排除。

英文:

To resolve this issue, you can try troubleshooting by checking if there are any errors in the API request URL or payload, verifying that you have sufficient permissions to perform the action, and ensuring that there are no temporary issues with Jfrog Artifactory's servers or network.

huangapple
  • 本文由 发表于 2023年4月17日 18:19:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76034090.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定