Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placeholder cannot be resolved #20614

Closed
Vladg90 opened this issue Mar 23, 2020 · 10 comments
Closed

Placeholder cannot be resolved #20614

Vladg90 opened this issue Mar 23, 2020 · 10 comments
Labels
status: duplicate A duplicate of another issue

Comments

@Vladg90
Copy link

Vladg90 commented Mar 23, 2020

I'm deploying a spring boot application in PCF, using the CredHub service for storing credentials. However, when I'm using version 2.2.5.RELEASE of spring boot, the placeholders from CredHub can't be resolved when words are separated with a . (or dash) in the placeholder. For example

vcap.services.credhub-instance-name.credentials.ssl.trust-password // not working
vcap.services.credhub-instance-name.credentials.someplaceholder // working

I tried using version 2.2.4.RELEASE, that one works fine for both placeholders.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 23, 2020
@wilkinsona
Copy link
Member

Thanks for the report. This could be a duplicate of #20432 or #20438. To eliminate the former, could you please try with a 2.2.6 snapshot available from https://repo.spring.io/.snapshot

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Mar 23, 2020
@Vladg90
Copy link
Author

Vladg90 commented Mar 23, 2020

I tried with 2.2.6.BUILD-SNAPSHOT, same issue.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 23, 2020
@wilkinsona
Copy link
Member

wilkinsona commented Mar 23, 2020

Thanks for trying a snapshot. To allow us to investigate further, can you please provide a small sample that reproduces the problem? You can share it with us by zipping it up and attaching it to this issue or by pushing it to a separate repository.

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Mar 23, 2020
@Vladg90
Copy link
Author

Vladg90 commented Mar 23, 2020

Just attached a sample app.

properties-credhub-issue.zip

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 23, 2020
@wilkinsona
Copy link
Member

Thanks for the sample. Unfortunately, it leaves more moving parts than I would like to be able to effectively diagnose the problem. Let's try a different approach. Could you please share the value of the VCAP_SERVICES environment variable when the app is deployed in your CloudFoundry environment?

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Mar 23, 2020
@Vladg90
Copy link
Author

Vladg90 commented Mar 24, 2020

Not sure if this is helpful, but here it is:
System-Provided:

{
 "VCAP_SERVICES": {
  "credhub": [
   {
    "binding_name": null,
    "credentials": {
     "credhub-ref": "/credhub-service-broker/credhub/bbcf88dd-1a62-44d6-842b-1ef4c611d2de/credentials"
    },
    "instance_name": "credhub-instance",
    "label": "credhub",
    "name": "credhub-instance",
    "plan": "default",
    "provider": null,
    "syslog_drain_url": null,
    "tags": [
     "credhub"
    ],
    "volume_mounts": []
   }
  ]
 }
}

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 24, 2020
@wilkinsona
Copy link
Member

wilkinsona commented Mar 24, 2020

Thanks. It helps a little, but still leaves quite a bit of unknown, particularly as you're using a custom buildpack. The key thing that's missing is what is populating the Environment with credentials that are stored in CredHub such that ${vcap.services.credhub-instance.credentials.demo.property} can be resolved.

I can reproduce the symptom that you've reported by running the same app with a VCAP_SERVICES environment variable set to { "credhub": [ { "credentials": { "demo.property": "demoValue" }, "name": "credhub-instance" } ] }. It starts successfully with Spring Boot 2.2.4, fails with 2.2.5, but works with 2.2.6.BUILD-SNAPSHOT. This is what I expected and is why I suggested that this may be a duplicate of #20432.

Can you please double-check that you continue to experience the problem with the latest 2.2.6 snapshot? If you do and you'd like us to spend some more time investigating this problem, we're going to need a more complete sample that describes everything that's necessary to reproduce it.

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Mar 24, 2020
@scottfrederick
Copy link
Contributor

scottfrederick commented Mar 24, 2020

The key thing that's missing is what is populating the Environment with credentials that are stored in CredHub such that ${vcap.services.credhub-instance.credentials.demo.property} can be resolved.

Cloud Foundry's container runtime does some magic in the application container to replace any credhub-ref field in the credentials structure of a service binding with the contents of the JSON text stored in CredHub. It does this using the CredHub interpolation endpoint.

While a Cloud Foundry user running a command like cf env app-name will see VCAP_SERVICES as in the example above, the application's environment might contain something more like:

{
 "VCAP_SERVICES": {
  "credhub": [
   {
    "binding_name": null,
    "credentials": {
      "demo": {
        "property": "demoValue"
      }
    },
    ...
  ]
 }
}

The best way to see what the application actually gets in its Environment is to enable the Spring Boot Actuators /actuator/env endpoint and view the PropertySource added by the VcapEnvironmentPostProcessor.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 24, 2020
@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Mar 24, 2020
@Vladg90
Copy link
Author

Vladg90 commented Mar 25, 2020

I double-checked, it worked indeed with 2.2.6 snapshot. Sorry I didn't get back to you yesterday, I was pretty busy with something else.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 25, 2020
@wilkinsona
Copy link
Member

Great. Thanks for letting us know.

@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants