Binding Services Defined in a Composite to Services Not Defined In the Composite

I’m bringing this conversation over from Slack, since we have a 10K message limit.

In which I learned “How to bind services defined in a composite to service groups that are not in the composite.”

I’m working in a studio with a Rails application (supermarket) and a background worker (sidekiq, as the supermarket-worker package). The code is in the supermarket repository on a branch0.

First, start up postgresql and redis:

hab svc load core/postgresql
hab svc load core/redis

Then, start supermarket and supermarket-worker:

hab svc load chefops/supermarket --bind redis:redis.default --bind database:postgresql.default

hab svc load chefops/supermarket-worker --bind redis:redis.default

I thought this would work the same way with the composite, but it didn’t. That is, I tried this:

hab svc load chefops/supermarket-composite \
  --bind redis:redis.default \
  --bind database:postgresql.default

However, this wasn’t passing the binds into the services in the composite. I had to additionally specify the name of the service that I wanted to use with each binding.

hab svc load chefops/supermarket-composite \
  --bind supermarket-worker:redis:redis.default \
  --bind supermarket:redis.default \
  --bind supermarket:database:postgresql.default

Note that supermarket itself needs to bind to redis, as well as the sidekiq worker.

Whoa that looks super weird. @christophermaier may have some more details on the behavior of composites and binds

It does look odd, but it’s correct: https://www.habitat.sh/docs/developing-packages/#additional-binding-support