使缓存失效政策部署错误问题排查

您正在查看的是 Apigee Edge 文档。
转到 Apigee X 文档
信息

InvalidCacheResourceReference

错误消息

通过 Edge 界面或 Edge Management API 部署 API 代理失败,并显示以下错误消息:

Error Deploying Revision revision_number to environment
Invalid cache resource reference [cache_resource] in Step definition [invalidate_cache_policy_name]. Context Revision:[revision_number];APIProxy:[apiproxy_name];Organization:[organization];Environment:[environment]

错误消息示例

Error Deploying Revision 2 to test
Invalid cache resource reference tokencache in Step definition InvalidateCache-Token. Context Revision:2;APIProxy:TestCache;Organization:kkalckstein-eval;Environment:test

错误屏幕截图示例

原因

如果将 InvalidateCache 政策中的 <CacheResource> 元素设置为部署 API 代理的环境中不存在的名称,则会出现此错误。

诊断

  1. 识别 InvalidateCache 政策名称、InvalidateCache 政策的 <CacheResource> 元素中使用的无效缓存以及出现错误的环境。您可以在错误消息中找到这些项。例如,在以下错误中,InvalidateCache 政策名称为 InvalidateCache-Token,无效缓存的名称为 tokencache,环境名称为 test

    Invalid cache resource reference tokencache in Step definition InvalidateCache-Token. Context Revision:2;APIProxy:TestCache;Organization:kkalckstein-eval;Environment:test
    
  2. 检查失败的 InvalidateCache 政策 XML,并验证为 <CacheResource> 元素指定的缓存名称与错误消息是否匹配。

    在此示例中,在 <CacheResource> 元素中指定的缓存名称为 tokencache

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <InvalidateCache async="false" continueOnError="false" enabled="true" name="InvalidateCache-Token">
        <DisplayName>InvalidateCache-Token</DisplayName>
        <Properties/>
        <CacheKey>
            <Prefix/>
            <KeyFragment ref=""/>
        </CacheKey>
        <CacheResource>tokencache</CacheResource>
        <Scope>Exclusive</Scope>
        <CacheContext>
            <APIProxyName/>
            <ProxyName>default</ProxyName>
            <TargetName>default</TargetName>
        </CacheContext>
        <PurgeChildEntries>false</PurgeChildEntries>
    </InvalidateCache>
    
  3. 验证是否已在特定环境(在第 1 步中标识)中定义缓存(在第 1 步中确定)。

    在边缘界面中,依次前往管理 > 环境 > 测试,检查环境配置缓存标签页中是否存在缓存。如果缓存不存在,则这是错误原因。

    例如,注意在下面的屏幕截图中,不存在名为 tokencache 的缓存。

    由于未在 test 环境中定义名为 tokencache 的缓存,因此会收到错误:

    Invalid cache resource reference tokencache in Step definition InvalidateCache-Token. Context Revision:2;APIProxy:TestCache;Organization:kkalckstein-eval;Environment:test
    

分辨率

确保在想要部署 API 代理的环境中创建了 InvalidateCache 政策的 <CacheResource> 元素中指定的缓存。

如需了解如何创建缓存,请参阅创建和修改环境缓存

CacheNotFound

错误消息

通过 Edge 界面或 Edge Management API 部署 API 代理时,系统会显示如下错误消息,而且 API 代理的部署状态会标记为“部分部署”:

Error: Cache : cache_resource, not found in organization : organization__environment.

错误消息示例

Error Cache : configCache, not found in organization : kkalckstein-eval__test

原因

如果尚未在特定的消息处理器组件上创建错误消息中提及的特定缓存,就会发生此错误。消息处理器是内部 Edge 组件,用于处理流经 Apigee Edge 的 API 流量。

分辨率

如果您是 Private Cloud 用户,请按照以下说明操作:

  1. 列出 API 代理部署并确定哪些消息处理器存在错误 steps.cache.CacheNotFound

    curl -u $USERID:$USERPASSWORD http://:8080/v1/organizations//environments//apis//revisions//deployments

    输出示例

      {
        "aPIProxy" : "TestCache",
        "environment" : [ {
          "configuration" : {
            "basePath" : "/",
            "configVersion" : "SHA-512:45d3f39783414d3859bf2dec4135d8f5f9960ee6b2d361db2799c82693a8e3f8b95dbbb37c547eb3c0a3819d8ca51727f390502bcaefdf1f113263521a9023b6",
            "steps" : [ ]
          },
          "name" : "prod",
          "server" : [ {
            "pod" : {
              "name" : "pod1",
              "region" : "us-central1"
            },
            "status" : "deployed",
            "type" : [ "message-processor" ],
            "uUID" : "f2e5e34a-5630-43a9-8fef-48a5b9da76d1"
          }, {
            "pod" : {
              "name" : "pod1",
              "region" : "us-central1"
            },
            "status" : "deployed",
            "type" : [ "message-processor" ],
            "uUID" : "879a6538-a5e0-4503-b142-9cb2b4e0623d"
          }, {
          "error" : "Cache : configCache, not found in organization : kkalckstein-eval__test",
          "errorCode" : "steps.cache.CacheNotFound",
          "status" : "error",
          "type" : [ "message-processor" ],
           "uUID" : "a8f9ce0b-c32d-48a9-b26c-9c75d8bf467d"
      },
      ...
          "state" : "deployed"
        } ],
        "name" : "2",
        "organization" : "kkalckstein-eval"
        ...
    
  2. 记下您在其中观察到错误 steps.cache.CacheNotFound 的消息处理器的 UUID。确定与 UUID 对应的消息处理器的主机名/IP 地址。

  3. 登录到特定消息处理器,然后使用以下命令重新启动它:

    apigee-service edge-message-processor restart

如果您是公有云用户,或者私有云问题仍然存在,请联系 Apigee 支持团队获取帮助。