風柳メモ

ソフトウェア・プログラミング関連の覚書が中心

Google App Engineでアプリケーションが更新できなくなって焦った

風柳のGoogle App Engineアプリケーション置き場はごった煮の実験場なので…

特にバージョンとか意識しなくてよいや、とずっとapp.yamlは「version: 1」のままにしていたのですが……。
咋夜、何気なく更新しようとすると……

Deploying new version.
2009-04-21 04:09:39,858 ERROR appcfg.py:1235 An unexpected error occurred. Aborting.
Traceback (most recent call last):
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.py", line 1228, in DoUpload
    self.Commit()
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.py", line 1101, in Commit
    self.Deploy()
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.py", line 1129, in Deploy
    version=self.version)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 303, in Send
    f = self.opener.open(req)
  File "C:\Python25\lib\urllib2.py", line 387, in open
    response = meth(req, response)
  File "C:\Python25\lib\urllib2.py", line 498, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python25\lib\urllib2.py", line 425, in error
    return self._call_chain(*args)
  File "C:\Python25\lib\urllib2.py", line 360, in _call_chain
    result = func(*args)
  File "C:\Python25\lib\urllib2.py", line 506, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
Rolling back the update.
Error 403: --- begin server output ---

Too Many Versions (403)
The application already has the maximum number of versions.
--- end server output ---

とかいって怒られてしまい……え?(゚o゚;)

まだこの時点では比較的冷静でした

Too Many Versions (403)
The application already has the maximum number of versions.

このメッセージからして『きっと、ひとつのバージョンで更新続けていたから、マイナーバージョン番号が上限に達したんだよね』と考え、とりあえずapp.yamlのversionをあげて試してみると……あれ、同じだ……。
とりあえず、2〜10、50、100で試したけど、ダメ。
当然ながら、管理画面にもデフォルトバージョン(1)がひとつ表示されているだけで、変化無し。

そろそろ焦りはじめます

ネットでそれらしき症状をいくつかあたってみましたが()、おおまかに言って、

  1. メジャーバージョン(app.yaml)を変更する。
  2. 既存のバージョンを削除する。

が対策らしく……

  1. は、上述したように自分の環境ではNG。
  2. も、既存バージョンがひとつしか存在せず、かつ、デフォルトバージョンになるために削除出来ない…。

という……。

うわー、これって八方塞がり?!

『こうなるともう、このアプリケーションを捨てるしかないの、もしかして?ウワー勘弁して〜』
と一通り騒いだ後(実際は、深夜というか明け方近くなので脳内ででしたが)、
『お、おちけつ。appcfg.pyのオプション引数を調べてみよまい。appcfg.py --helpで……と。おっ、-f(--force)オプションとかあるじゃん(←字面だけみて説明読んでいない)、これで……って
appcfg.py: error: no such option: -f
って、なめとんか〜〜。』
と、素敵なひとり阿鼻叫喚の時期を過ぎ……。

あら、収束したわ

何気なくためした、

appcfg.py vacuum_indexes furyu-tei/

で、解決。
むむ、vacuum_indexesって、データベースの未使用インデックス削除じゃないの?

Deleting Unused Indexes

When you change or remove an index from index.yaml, the original index is not deleted from App Engine automatically. This gives you the opportunity to leave an older version of the app running while new indexes are being built, or to revert to the older version immediately if a problem is discovered with a newer version.

When you are sure that old indexes are no longer needed, you can delete them from App Engine using the following command:

appcfg.py vacuum_indexes myapp/

This command deletes all indexes for the app that are not mentioned in the most recently uploaded version of index.yaml.

そう読めるんだけれども……ここからどうやって、

Too Many Versions (403)
The application already has the maximum number of versions.

エラーの原因だと読み取れというのでございましょう。

そんなわけで……

GAE使いの方は、

  1. バージョン管理はちゃんとしましょう、というか、デフォルトバージョン以外に最低でもひとつは作っておきましょう。
  2. 定期的にappcfg.py vacuum_indexesしておきましょう。

ってことですかね。