Response Cache 政策部署错误问题排查

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

InvalidTimeout

错误消息

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

Error Saving Revision revision_number
CacheLookupTimeoutInSeconds value value should be greater than zero.

错误消息示例

Error Saving Revision 2
CacheLookupTimeoutInSeconds -1 value should be greater than zero.

错误屏幕截图示例

原因

如果 ResponseCache 政策<CacheLookupTimeoutInSeconds> 元素设置为负数,则 API 代理的部署将会失败。

例如,如果 <CacheLookupTimeoutInSeconds>-1,则 API 代理的部署将会失败。

诊断

  1. 找出 ResponseCache 政策中 <CacheLookupTimeoutInSeconds> 元素使用的无效值。您可以在错误消息中找到此信息。例如,在以下错误中,用于 <CacheLookupTimeoutInSeconds> 元素的无效值为 -1

    CacheLookupTimeoutInSeconds -1 value should be greater than zero.
    
  2. 检查出现故障的特定 API 代理中的所有 ResponseCache 政策。可能存在一个或多个指定了 <CacheLookupTimeoutInSeconds> 元素的 ResponseCache 政策。

    例如,以下政策配置将 <CacheLookupTimeoutInSeconds> 设置为 -1,这与错误消息中的内容匹配:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ResponseCache async="false" continueOnError="false" enabled="true" name="Response-Cache-1">
        <DisplayName>Response Cache-1</DisplayName>
        <Properties/>
        <CacheKey>
            <Prefix/>
            <KeyFragment ref="request.uri" type="string"/>
        </CacheKey>
        <Scope>Exclusive</Scope>
        <ExpirySettings>
            <ExpiryDate/>
            <TimeOfDay/>
            <TimeoutInSec ref="">3600</TimeoutInSec>
        </ExpirySettings>
        <CacheLookupTimeoutInSeconds>-1</CacheLookupTimeoutInSeconds>
    </ResponseCache>
    
  3. 如果 <CacheLookupTimeoutInSeconds> 指定为负整数,则会导致错误。

分辨率

请确保 ResponseCache 政策的 <CacheLookupTimeoutInSeconds> 元素的值始终指定为非负整数。

如需更正上面显示的 ResponseCache 政策示例,您可以将 <CacheLookupTimeoutInSeconds> element 修改为 30

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResponseCache async="false" continueOnError="false" enabled="true" name="Response-Cache-1">
    <DisplayName>Response Cache-1</DisplayName>
    <Properties/>
    <CacheKey>
        <Prefix/>
        <KeyFragment ref="request.uri" type="string"/>
    </CacheKey>
    <Scope>Exclusive</Scope>
    <ExpirySettings>
        <ExpiryDate/>
        <TimeOfDay/>
        <TimeoutInSec ref="">3600</TimeoutInSec>
    </ExpirySettings>
    <CacheLookupTimeoutInSeconds>30</CacheLookupTimeoutInSeconds>
</ResponseCache>

InvalidCacheResourceReference

错误消息

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

Error Deploying Revision revision_number to environment
Invalid cache resource reference cache_resource in Step definition response_cache_policy_name. Context Revision:revision_number;APIProxy:ResponseCache;Organization:organization;Environment:environment

错误消息示例

Error Deploying Revision 2 to prod
Invalid cache resource reference itemscache in Step definition ItemsResponseCache. Context Revision:2;APIProxy:StoresInventory;Organization:kkalckstein-eval;Environment:prod

错误屏幕截图示例

原因

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

诊断

  1. 标识 Response Cache 政策的 <CacheResource> 元素中使用的无效缓存以及出现错误的环境。您可以在错误消息中找到这两项。例如,在以下错误中,无效缓存的名称为 itemscache,而环境名称为 prod

    Invalid cache resource reference itemscache in Step definition ItemsResponseCache. Context Revision:2;APIProxy:StoresInventory;Organization:kkalckstein-eval;Environment:prod
    
  2. 检查出现故障的特定 API 代理中的所有 ResponseCache 政策。标识在 <CacheResource> 元素中指定了无效缓存(在第 1 步中标识)的特定 ResponseCache 政策。

    例如,以下政策将 <CacheResource> 的值设置为 itemscache,这与错误消息中的内容一致:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ResponseCache async="false" continueOnError="false" enabled="true" name="ItemsResponseCache">
      <DisplayName>ItemsResponseCache</DisplayName>
      <Properties/>
      <CacheKey>
          <Prefix/>
          <KeyFragment ref="request.uri" type="string"/>
      </CacheKey>
      <CacheResource>itemscache</CacheResource>
      <Scope>Exclusive</Scope>
      <ExpirySettings>
          <ExpiryDate/>
          <TimeOfDay/>
          <TimeoutInSec ref="">3600</TimeoutInSec>
      </ExpirySettings>
      <SkipCacheLookup/>
      <SkipCachePopulation/>
    </ResponseCache>
    
  3. 验证是否已在特定环境(在第 2 步中标识)中定义缓存(在第 1 步中确定)。

    在边缘界面中,依次转到 API > 环境配置,然后检查特定环境的缓存标签页中是否存在缓存。如果缓存不存在,则这是错误原因。

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

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

    Invalid cache resource reference does_not_exist in Step definition Response-Cache-1. Context Revision:2;APIProxy:ResponseCache;Organization:kkalckstein-eval;Environment:prod
    

分辨率

确保 <CacheResource> 元素中指定的缓存名称已在您要部署 API 代理的环境中创建。

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

ResponseCacheStepAttachmentNotAllowedReq

错误消息

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

Error Deploying Revision revision_number to environment
Response cache step definition response_cache_policy_name can not be attached more than once in the request path.

错误消息示例

Error Deploying Revision 2 to test
Response cache step definition Response-Cache-1 can not be attached more than once in the request path.

错误屏幕截图示例

原因

如果将同一 ResponseCache 政策附加到 API 代理的任何中的多个请求路径,则会出现此错误。

例如,如果您在代理端点和目标端点的请求 Preflow 中附加了相同的 ResponseCache 政策,则会出现此错误。

诊断

  1. 标识多次附加的 ResponseCache 政策的名称。您可以在错误消息中找到此信息。例如,在以下错误中,ResponseCache 策略的名称是 Response‑Cache‑1。

    Error Deploying Revision 2 to test
    Response cache step definition Response-Cache-1 can not be attached more than once in the request path.
    
  2. 检查出现错误的 API 代理的代理端点和目标端点中的所有请求流。如果两个或多个请求流附加了相同的 ResponseCache 政策,则会导致错误。

    在以下示例中,默认代理端点 PreFlow 和默认目标端点 PreFlow 的请求路径中配置了相同的 ResponseCache 政策 Response-Cache-1

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ProxyEndpoint name="default">
        <Description/>
        <FaultRules/>
        <PreFlow name="PreFlow">
            <Request>
                <Step>
                    <Name>Response-Cache-1</Name>
                </Step>
            </Request>
        ...
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <TargetEndpoint name="default">
        <Description/>
        <FaultRules/>
        <PreFlow name="PreFlow">
            <Request/>
            <Response/>
        </PreFlow>
        <PostFlow name="PostFlow">
            <Request>
                <Step>
                    <Name>Response-Cache-1</Name>
                </Step>
            </Request>
        ...
    

解决方法

确保在 API 代理的所有流中,仅将一个 ResponseCache 政策附加到一个请求路径。

如需更正上面显示的示例,请从两个请求流之一中移除 ResponseCache 政策 Response-Cache-1

ResponseCacheStepAttachmentNotAllowedResp

错误消息

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

Error Deploying Revision revision_number to environment
Response cache step definition response_cache_policy_name can not be attached more than once in the response path.

错误消息示例

Error Deploying Revision 2 to test
Response cache step definition Response-Cache-1 can not be attached more than once in the response path.

错误屏幕截图示例

原因

如果将同一 ResponseCache 政策附加到 API 代理的任何流中的多个响应路径,则会出现此错误。

例如,如果您在代理端点和目标端点的响应 Preflow 中附加了相同的 ResponseCache 政策,则会出现此错误。

诊断

  1. 标识多次附加的 ResponseCache 政策的名称。您可以在错误消息中找到此信息。例如,在以下错误中,ResponseCache 政策的名称是 Response-Cache-1

    Error Deploying Revision 2 to test
    Response cache step definition Response-Cache-1 can not be attached more than once in the response path.
    
  2. 检查出现错误的 API 代理的代理端点和目标端点中的所有请求流。如果两个或多个响应流附加了相同的 ResponseCache 政策,则会导致错误。

    在以下示例中,默认代理端点 PreFlow 和默认目标端点 PreFlow 的响应路径中配置了相同的 ResponseCache 政策 Response-Cache-1

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ProxyEndpoint name="default">
        <Description/>
        <FaultRules/>
        <PreFlow name="PreFlow">
            <Request>
                <Step>
                    <Name>Response-Cache</Name>
                </Step>
            </Request>
            <Response>
                <Step>
                    <Name>Response-Cache-1</Name>
                </Step>
            </Response>
        </PreFlow>
        ...
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <TargetEndpoint name="default">
        <Description/>
        <FaultRules/>
        <PreFlow name="PreFlow">
            <Request/>
            <Response/>
        </PreFlow>
        <PostFlow name="PostFlow">
            <Request/>
            <Response>
                <Step>
                    <Name>Response-Cache-1</Name>
                </Step>
            </Response>
        </PostFlow>
        ...
    

分辨率

确保在 API 代理的所有流中,仅将一个 ResponseCache 政策附加到一个响应路径。

如需更正上面显示的示例,请从两个响应路径之一中移除 ResponseCache 政策 Response-Cache-1

InvalidMessagePatternForErrorCode

错误消息

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

Error Deploying Revision revision_number to environment
Invalid message pattern found for error code steps.cache.InvalidSkipCacheLookUpCondition.

Error Deploying Revision revision_number to environment
Invalid message pattern found for error code steps.cache.InvalidSkipCachePopulationCondition.

错误消息示例

Error Deploying Revision 2 to prod
Invalid message pattern found for error code steps.cache.InvalidSkipCacheLookUpCondition.

Error Deploying Revision 2 to prod
Invalid message pattern found for error code steps.cache.InvalidSkipCachePopulationCondition.

错误屏幕截图示例

原因

如果 ResponseCache 政策中的 <SkipCacheLookup><SkipCachePopulation> 元素包含无效条件,则会出现此错误。

诊断

  1. 检查 API 代理中出现错误的所有 ResponseCache 政策,并检查是否有任何政策满足为 <SkipCacheLookup> 和/或 <SkipCachePopulation> 元素指定的条件。

  2. 检查为 <SkipCacheLookup> 和/或 <SkipCachePopulation> 元素指定的条件是否无效。如果是,则会导致此错误。

    在以下示例中,<SkipCachePopulation> 元素使用 JavaScript 运算符 === 检查是否有无效的相等值和相等类型。

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ResponseCache async="false" continueOnError="false" enabled="true" name="Response-Cache-1">
        <DisplayName>Response Cache-1</DisplayName>
        <Properties/>
        <CacheKey>
            <Prefix/>
            <KeyFragment ref="request.uri" type="string"/>
        </CacheKey>
        <Scope>Exclusive</Scope>
        <ExpirySettings>
            <ExpiryDate/>
            <TimeOfDay/>
            <TimeoutInSec ref="">3600</TimeoutInSec>
        </ExpirySettings>
        <CacheLookupTimeoutInSeconds>2</CacheLookupTimeoutInSeconds>
        <SkipCacheLookup>request.header.bypass-cache === "true"</SkipCacheLookup>
    </ResponseCache>
    

    由于运算符 === 无效,您会收到以下错误:

    Invalid message pattern found for error code steps.cache.InvalidSkipCacheLookUpCondition.
    

分辨率

确保为 <SkipCacheLookup> 和/或 <SkipCachePopulation> 元素指定的条件始终有效。

如需更正上面显示的 ResponseCache 政策示例,您可以修改 <SkipCacheLookup> 以使用 = 运算符:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResponseCache async="false" continueOnError="false" enabled="true" name="Response-Cache-1">
    <DisplayName>Response Cache-1</DisplayName>
    <Properties/>
    <CacheKey>
        <Prefix/>
        <KeyFragment ref="request.uri" type="string"/>
    </CacheKey>
    <Scope>Exclusive</Scope>
    <ExpirySettings>
        <ExpiryDate/>
        <TimeOfDay/>
        <TimeoutInSec ref="">3600</TimeoutInSec>
    </ExpirySettings>
    <CacheLookupTimeoutInSeconds>2</CacheLookupTimeoutInSeconds>
    <SkipCacheLookup>request.header.bypass-cache = "true"</SkipCacheLookup>
</ResponseCache>

CacheNotFound

错误消息

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

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

错误消息示例

Error Cache : Response-Cache-1, not found in organization : kkalckstein-eval__prod

原因

如果尚未在特定的消息处理器组件上创建错误消息中提及的特定缓存,就会发生此错误。

分辨率

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

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

    输出示例

    curl -u $USERID:$USERPASSWORD http://<management-server-host>:8080/v1/organizations/<org-name>/environments/<env-name>/apis/<apiproxy-name>/revisions/<revision-number>/deployments
    {
      "aPIProxy" : "ResponseCache",
      "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 : Response-Cache-1, not found in organization : kkalckstein-eval__prod",
        "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 支持团队联系以获取帮助。