fix(compose): scale 生成時に depends_on の dev 参照を書き換える#12
Merged
Conversation
generate_scaled_compose が dev サービスを dev-1..dev-N にリネームする際、 他サービスの depends_on: dev 参照が書き換えられず、scaled compose で 未定義サービスへの依存となって docker compose up が失敗していた。 _rewrite_depends_on() を追加し、list 形式と map 形式 (condition 付き) の 両方で dev 参照を dev-i に展開する。scale > 1 の場合は全インスタンスへ 展開して service_healthy チェーンが正しく機能するようにする。 これにより compose.yml 側で dev の healthcheck と他サービスからの depends_on: dev: condition: service_healthy が利用可能になる。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generate_scaled_composeが dev サービスをdev-1..Nにリネームする際、他サービスのdepends_on: dev参照を書き換えていなかったため、scaled compose で未定義サービスへの依存となりdocker compose upが失敗していた問題を修正_rewrite_depends_on()を新設し、list形式 (depends_on: [dev, mysql]) とmap形式 (depends_on: {dev: {condition: service_healthy}}) の両方を扱うdev参照を全インスタンス (dev-1..N) に展開し、service_healthyチェーンを scaled デプロイでも維持compose.ymlで dev に healthcheck を付け、mysql/app/nginxからdepends_on: dev: condition: service_healthyを書ける背景
carmo-system-console プロジェクトで、
app.working_dir: /work/carmo-system-consoleを指定すると Docker がdevの clone より先に空ディレクトリを作ってしまい、base/entrypoint.shがif [ ! -d "$GIT_REPO" ]で clone をスキップしてソースが配置されない race があった。依存関係で順序を明示しようとしたが、本変更がない状態では scaled compose 生成後にdev参照が残って失敗するため、本 fix が前提となる。Test plan
devbase_work_1の/work/carmo-system-consoleを消したのちdevbase upを実行し、dev-1 Healthy → mysql Starting → app Started → nginx Startedの順で起動することを確認.docker-compose.scale.yml) でmysql.depends_onがdevからdev-1に書き換わっていることを確認depends_onの list 形式 (depends_on: [dev]) を使うプロジェクトでの動作確認