Issue with pkg_optional_binds


I’m trying to use pkg_bind_optional feature and I’m unable to access the bind data even though instance has that data received in the census. Here is the context:

  • There are two service groups using different service group keys in the same ring.
  • Both the service groups are running the same package. Based on a toml value they have different post-configuration steps at the end of the run hook.
    *So if toml value=primary(something) then I’m doing a hab config apply of a toml that has the below in the run hook.
cat <<TOML > {{pkg.svc_data_path}}/config.toml
roottoken = "${ROOT_TOKEN}"
dr_token = ${dr_token}

hab config apply --user "{{cfg.svc_group_enc.user_key}}" "{{svc.service}}.{{}}@{{}}" "$(date +%s)" "{{pkg.svc_data_path}}/config.toml"
  * If the toml value=secondary then nothing. (No hab config apply)


  • Here are the bind details in the plan

Now in the VM that has the toml value=secondary when I do a curl localhost:9631/census | jq . | grep dr_token I see the value I need. However in the run hook when i try {{bind.vaultend.cfg.dr_token}} or {{bind.vaultend.first.cfg.dr_token}} or use the service name instead like {{vault.dev_kiran_edc1@umarla_dev_org.cfg.dr_token}} I receive blank values (nothing). I have also tried this

{{#if bind.vaultend ~}}
              echo "bind found"
{{else ~}}
              echo "no bind found"
{{/if ~}}

Which always prints no bind found.

Is there something I’m missing here?

Kiran Marla


Can you show your hab svc load command? Specifically you need to add a --bind for the optional service in order for the consuming service to see its configuration data.