SteeltoeOSS / Steeltoe

.NET Components for Externalized Configuration, Database Connectors, Service Discovery, Logging and Distributed Tracing, Application Management, Security, and more.
https://steeltoe.io
Apache License 2.0
1.01k stars 163 forks source link

Application name in manifest.yml is overriding spring:application:name in appsettings.json #34

Closed robblargent closed 5 years ago

robblargent commented 5 years ago

To support Blue/Green deployments we apply a version number suffix on the application name in the manifest.yml when pushing to PCF:

---
applications:
- name: appname-v1-0-1
  path: ./bin/linux-x64
  memory: 256MB
  stack: cflinuxfs3
  buildpacks:
  - dotnet_core_buildpack
  instances: 1
  env:
    ASPNETCORE_ENVIRONMENT: sandbox
  services:
  - config-server

We do not apply a version number suffix on the application name in appsettings.json:

{
    "spring": {
        "application": {
            "name": "appname"
        }
    }
}

We have a yml configuration file called {application}-{environment}.yml (e.g. appname-sandbox.yml).

The issue is that the name of the application in manifest.yml / VCAP_APPLICATION is being used rather than the application name in appsettings.json, by the Steeltoe Configuration libraries, when attempting to locate a yml configuration file.

We have also attempted to explicitly set the application name in code via the Steeltoe.Extensions.Configuration.ConfigServer.ConfigServerConfigurationBuilderExtensions.AddConfigServer(environment, ApplicationName, LogFactory) extension method, but the application name is not propagated properly. The application name from the manifest.yml is still being used.

This behavior seems to be inconsistent with Java Spring Boot.

This looks to be the same, or very similar, to the issue reported at: https://github.com/SteeltoeOSS/Configuration/issues/37

In that same issue it was stated:

I believe the problem you were having with this was that spring.application.name was always being overridden by the name in the manifest.yml when you pushed the app to PCF. This Steeltoe behavior was not consistent with Java Spring Boot applications.

With Java based apps, if you DID NOT configure spring.application.name, then s.a.n would be set to the application name from manifest.yml. If you DID configure s.a.n, then it would be left alone and remain as configured.

With Steeltoe 2.2, to be released by end of 1st Qtr, we no longer override s.a.n when pushing to PCF (i.e. we follow what Java Spring Boot does).

Any idea when this will be fixed?

cf-gitbot commented 5 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/166170694

The labels on this github issue will be updated when the story is started.

stuwilliams-clgx commented 5 years ago

This is a serious problem for real production scenarios.

dtillman commented 5 years ago

@robblargent : Hey .. looking at this ... what version of Steeltoe CloudFoundry and ConfigServer are you seeing this with? Dave

stuwilliams-clgx commented 5 years ago

[cid:image001.jpg@01D5113D.58C265F0]

We’ll happily test any solutions.

From: Dave Tillman notifications@github.com Sent: Thursday, May 23, 2019 7:54 AM To: SteeltoeOSS/steeltoe steeltoe@noreply.github.com Cc: williams, Stuart stuwilliams@corelogic.com; Comment comment@noreply.github.com Subject: Re: [SteeltoeOSS/steeltoe] Application name in manifest.yml is overriding spring:application:name in appsettings.json (#34)

[External Content] This message is from an external source. Please exercise caution when opening attachments or links.

@robblargenthttps://github.com/robblargent : Hey .. looking at this ... what version of Steeltoe CloudFoundry and ConfigServer are you seeing this with? Dave

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/SteeltoeOSS/steeltoe/issues/34?email_source=notifications&email_token=AINNSLHVBW4KA4GKWWZWMTLPW2VZ3A5CNFSM4HOPAV72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWCPQ5I#issuecomment-495253621, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AINNSLED5GEDFPYPX2IQNZ3PW2VZ3ANCNFSM4HOPAV7Q.


This message may contain confidential or proprietary information intended only for the use of the addressee(s) named above or may contain information that is legally privileged. If you are not the intended addressee, or the person responsible for delivering it to the intended addressee, you are hereby notified that reading, disseminating, distributing or copying this message is strictly prohibited. If you have received this message by mistake, please immediately notify us by
replying to the message and delete the original message and any copies immediately thereafter.

Thank you.


CLLD

dtillman commented 5 years ago

@stuwilliams-clgx @robblargent : Trying to recreate this problem.. and I'm not seeing it right now with my test using 2.2 of Steeltoe... not saying it doesn't exist.. just trying recreate it so I can fix it. Dave

stuwilliams-clgx commented 5 years ago

We’ll make a repo and post it to public github and you can grab it and use it as a test.

-S

From: Dave Tillman notifications@github.com Sent: Thursday, May 23, 2019 8:01 AM To: SteeltoeOSS/steeltoe steeltoe@noreply.github.com Cc: williams, Stuart stuwilliams@corelogic.com; Mention mention@noreply.github.com Subject: Re: [SteeltoeOSS/steeltoe] Application name in manifest.yml is overriding spring:application:name in appsettings.json (#34)

[External Content] This message is from an external source. Please exercise caution when opening attachments or links.

@stuwilliams-clgxhttps://github.com/stuwilliams-clgx @robblargenthttps://github.com/robblargent : Trying to recreate this problem.. and I'm not seeing it right now with my test using 2.2 of Steeltoe... not saying it doesn't exist.. just trying recreate it so I can fix it. Dave

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/SteeltoeOSS/steeltoe/issues/34?email_source=notifications&email_token=AINNSLH2XCANGZ3BNAU33ALPW2WUJA5CNFSM4HOPAV72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWCQIPY#issuecomment-495256639, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AINNSLBTFTSHGPBWNVSXUETPW2WUJANCNFSM4HOPAV7Q.


This message may contain confidential or proprietary information intended only for the use of the addressee(s) named above or may contain information that is legally privileged. If you are not the intended addressee, or the person responsible for delivering it to the intended addressee, you are hereby notified that reading, disseminating, distributing or copying this message is strictly prohibited. If you have received this message by mistake, please immediately notify us by
replying to the message and delete the original message and any copies immediately thereafter.

Thank you.


CLLD

dtillman commented 5 years ago

@stuwilliams-clgx : Thanks Stuart!

robblargent commented 5 years ago

@dtillman : According to our foundation folks we are running the following: PAS -> 2.3.9 PAS Windows -> 2.3.8 SCS -> 2.0.2

On that note, I have been able to reproduce this issue on whatever is currently running on Pivotal Web Services.

An example that reproduces the issue is located at https://github.com/robblargent/bg-config-server . Please let me know if those instructions are clear and/or if I can provide any additional information.

urvin08 commented 5 years ago

I am also able to reproduce this issue when I am consuming Steeltoe.Extensions.Configuration.ConfigServerCore v2.2.0. With this version, while deploying to PCF it is using the PCF app name in "spring.application.name".

Downgrading the version to Steeltoe.Extensions.Configuration.ConfigServerCore to v2.1.1 resolved the issue for me.

dtillman commented 5 years ago

@stuwilliams-clgx @robblargent @urvin08 : Thanks ... looking this... we'll get a fix out as soon as we can. Dave

dtillman commented 5 years ago

With this change, spring:application:name will no longer be set/overriden by the Steeltoe libraries. Config Server client will use the following name(s), in the following order, when retrieving configuration values from a server:

  1. spring:cloud:config:name if found
  2. spring:application:name if found
  3. vcap:application:name if found (typically provided by Steeltoe CloudFoundry configuration provider) 4: IHostingEnvironment.ApplicationName as default