1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AgentCore Runtime V2でのアップデート時の更新時の挙動と注意点(VPC構成のみ)

1
Posted at

こんにちは、ふくちです。

AgentCore Runtimeのデフォルトがplatform version V2になったらしいですネ。
じゃあこれ対応するかーということでバージョンを上げてデプロイしたら、CloudFormationが UPDATE_ROLLBACK_FAILED になりました。なんじゃらほい。

原因はざっくり言うと、VPCエンドポイントを夜止めている構成・V2は更新時にコンテナを起動する仕様が合わさったことでした。

構成

AgentCore RuntimeをVPC内で動かしていて、各種AWSサービスにはVPCエンドポイント経由でアクセスする形です。
ただインターフェースエンドポイントは時間課金されるので、利用者のいない夜中は削除する形にしています。

するとこの時間帯はAgentCore RuntimeからECRに届かなくなります。AgentCore Runtime起動時にECRからイメージ取得するので、そもそも起動ができなくなるって感じですね。

で、V1の時はこの夜間でも問題なく新しいバージョンのデプロイができていました。なのでいつも通りにこんな感じで更新してみたのですがなんかコケました。

時間 出来事
18:00 AgentCore RuntimeをV2に切り替え(イメージは同じ)、動作確認はすべてOK
20:00 インターフェースエンドポイントを削除
21:15 修正PRをmerge・デプロイ
21:19 AgentCore Runtimeの更新が失敗
21:23 ロールバックでも失敗し、UPDATE_ROLLBACK_FAILED で停止

AgentCore Runtimeのエラーは下記のように出ているので、ECRに届かなかったと見るべきでしょう。

Agent runtime update failed with status: UPDATE_FAILED
Reason: Couldn't reach the container registry or its Amazon S3 layer storage.
If the runtime uses a VPC, check VPC endpoints (including the S3 gateway endpoint),
NAT, and security group egress.

V2の仕様

V2からは構築時・アップデート時にスナップショットを保持しておき、それを元にコンテナの高速起動を可能にしているようです。
そしてこのスナップショット準備に、一度コンテナを起動する必要があるそうです。具体的には/pingがhealthyになったところでスナップショットを取得するようです。

A V2 create or update operation prepares and snapshots your environment, so it behaves differently from V1.
On V1, a runtime reaches READY in seconds. On V2, preparing the snapshot adds a one-time cost, and create and update run for several minutes before the runtime reaches READY.
AgentCore Runtime takes the snapshot on the first healthy /ping response, or, if you configure a build warmup hook, after the hook’s memory call.

つまり、新規作成・更新時にコンテナを起動する必要があるので、その時にECRからイメージを取れる必要があるということです。
なので私の構成だと夜間にはインターフェースエンドポイントがなく、その時にECRからイメージを取得できないので、更新処理実行時のスナップショット作成ができずに失敗していたんですネ。

もう少しわかりやすく図示してみましょう。V1の流れはこんな感じ。
image.png

それに対してV2の流れはこんな感じ。なのでVPCエンドポイントを削除している夜間にはアップデートできないんですね。
image.png

まとめ

VPC内ではないAgentCore Runtimeなら気にしなくていいポイントですが、S3 Filesと連携しているなどでVPC内に置いている場合は更新時の環境に注意して下さい。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?