填充缓存政策部署错误问题排查

<ph type="x-smartling-placeholder"></ph> 您正在查看 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 [populate_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 PopulateCache-Token. Context Revision:2;APIProxy:TestCache;Organization:kkalckstein-eval;Environment:test

错误屏幕截图示例

原因

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

诊断

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

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

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

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <PopulateCache async="false" continueOnError="false" enabled="true" name="PopulateCache-Token">
        <DisplayName>PopulateCache-Token</DisplayName>
        <Properties/>
        <CacheKey>
            <Prefix/>
            <KeyFragment ref="request.queryparam.client_id"/>
        </CacheKey>
        <CacheResource>tokencache</CacheResource>
        <Scope>Exclusive</Scope>
        <ExpirySettings>
            <TimeoutInSec>3600</TimeoutInSec>
        </ExpirySettings>
        <Source>token</Source>
    </PopulateCache>
    
  3. 验证是否已在特定环境(在第 1 步中标识)中定义缓存(在第 1 步中确定)。

    在 Edge 界面中,依次点击管理 >环境 >test,检查缓存是否存在于环境配置缓存标签页中。如果缓存不存在,则这是错误原因。

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

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

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

解决方法

确保在想要部署 API 代理的环境中创建了 PopulateCache 政策的 <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 支持团队联系以获取帮助。