Spring Cloud Config Server: error: No such label: master - java

when I access the url http://localhost:8888/actuator/health y have this error
{
"status": "DOWN",
"details": {
"diskSpace": {
"status": "UP",
"details": {
"total": 457192763392,
"free": 347865096192,
"threshold": 10485760
}
},
"refreshScope": {
"status": "UP"
},
"configServer": {
"status": "DOWN",
"details": {
"repository": {
"application": "app",
"profiles": "default"
},
"error": "org.springframework.cloud.config.server.environment.NoSuchLabelException: No such label: master"
}
}
}
}
my application.yml
enter image description here

By default, spring cloud server tries to get properties from branch "master" in the git repository. Your repository doesn't have it (you have branch "main" instead).
You can use property default-label to set custom branch name (see docs):
spring:
cloud:
config:
server:
git:
default-label: main
Or, you can rename your branch to master and leave all other things as they are.

Check your property file name and request file name.
I was getting same and resolved by making two below changes.
1st Change:
spring.cloud.config.server.git.uri=E:\\\\spring_microservice\\\\git-localconfig-repo
Removed file///...... and added 4 slash (\\)
2nd Change:
Actually i was making request with incorrect property file name. I was making request like http://localhost:8888/limit-servers/default but correct file name is limit-server.properties so i have correct the request as below.
http://localhost:8888/limit-server/default
And it worked for me.

I was getting the same issue, and resolved it by making the two below changes:
spring.cloud.config.server.git.uri=E:/spring_microservice/git-localconfig-repo
Added forward slash (/) everywhere.

You can simply add in your configuration file application.properties or apllication.yml, the following line of code :
- For people that use application.properties file :
spring.cloud.config.server.git.default-label=main
- For people that use application.use file :
spring:
cloud:
config:
server:
git:
default-label: main

Related

Why an user with the 'read' role on the database cannot list the collections?

Given a normal user ('simpleROUser', only with the 'read' role on the database), it is throwing error when attempting to list collections.
The error message is:
Exception in thread "main" com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): 'not authorized on wmMonitoring to execute command { listCollections: 1, cursor: {}, $db: "wmMonitoring", ...' on server xxxxxxx:27001. The full response is {"operationTime": {"$timestamp": {"t": 1614169303, "i": 1}}, "ok": 0.0, "errmsg": "not authorized on wmMonitoring to execute command { listCollections: 1, cursor: {}, $db: \"wmMonitoring\", ...
However, changing only the user credentials to one with 'root' role, it works (lists all the collections under the database 'wmMonitoring'.
I've checked the 'simpleROUser' privileges, the 'listCollections' is there.
rs-dev-00:PRIMARY> grants = db.getUser( "simpleROUser", { showCredentials: true, showPrivileges: true, showAuthenticationRestrictions: true } )
rs-dev-00:PRIMARY> grants.user
simpleROUser
rs-dev-00:PRIMARY> grants.inheritedPrivileges
[
{
"resource" : {
"db" : "wmISMonitoring",
"collection" : ""
},
"actions" : [
...
"listCollections",
...
]
},
...
]
rs-dev-00:PRIMARY>
So... what am I missing?
More info:
MongoDB server: Percona distribution, v4.4.1-3
Mongo Java Driver: v4.2.1
Found th issue.
In Brazilan Portuguese, this is also referred as "dedo gordo".
There was a typo in the grant: the actual database name is wmMonitoring.
Once the database name (in the grant command) has fixed, everything else worked.

Pushing mocks to remote wiremock server fails with "JSON Parsing" Error

I am trying to post mappings to a remote server from a spring application. What I found while debugging is that my JSON gets converted to "StubMapping" and this is the place where the code is failing with the following error.
Error creating bean with name 'wiremockConfig' defined in file [C:\Users\Addy\school-impl-api\target\classes\com\test\school\project\wiremock\WiremockConfig.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.test.order.implementation.product.wiremock.WiremockConfig$$EnhancerBySpringCGLIB$$b100848d]: Constructor threw exception; nested exception is com.github.tomakehurst.wiremock.common.JsonException: {
"errors" : [ {
"code" : 10,
"source" : {
"pointer" : "/mappings"
},
"title" : "Error parsing JSON",
"detail" : "Unrecognized field \"mappings\" (class com.github.tomakehurst.wiremock.stubbing.StubMapping), not marked as ignorable"
} ]
}
I got details for posting to a remote standalone server from the following issue (last comment).
https://github.com/tomakehurst/wiremock/issues/1138
My code for posting to the remote server is like this:
WireMock wm = new WireMock("https", "wiremock-poc.apps.pcf.sample.int", 443);
wm.loadMappingsFrom("src/main/resources"); // Root dir contains mappings and __files
This gets loaded when I run the profile local.
Please provide your guidance on how to solve this and move further.
Regards
Update: Sample mapping file.
{
"mappings": [
{
"request": {
"method": "GET",
"urlPathPattern": "/school/admin/rest/users/([0-9]*)?([a-zA-Z0-9_\\-\\=\\?\\.]*)"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"bodyFileName": "./mockResponses/School-getUser.json"
}
}
]
}
After a discussion in chat found out that it's supported to keep each mapping in a separate file.
Here's the source code that is responsible for that: RemoteMappingsLoader#load

Java Azure Function Not Executing Locally

Hi all, I'm working on Azure functions, I'm new to this, I have created a local java Azure function project using the below archetype:
*mvn archetype:generate -DgroupId=com.mynew.serverlesstest -DartifactId=serverlessexample -
DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype -
DinteractiveMode=false*
*The template has a simple java function.
Upon executing a "mvn clean package" command, function.json gets generated in the target folder for the function, below is my function.json*
{
"scriptFile" : "..\\serverlessexample-1.0-SNAPSHOT.jar",
"entryPoint" : "com.mynew.serverlesstest.Function.hello",
"bindings" : [ {
"type" : "httpTrigger",
"name" : "req",
"direction" : "in",
"authLevel" : "anonymous",
"methods" : [ "get", "post" ]
}, {
"type" : "http",
"name" : "$return",
"direction" : "out"
} ],
"disabled" : false
}
on doing a mvn azure-functions:run, the application starts successfully , and I get below in the command prompt:
[06-04-2020 07:26:55] Initializing function HTTP routes
[06-04-2020 07:26:55] Mapped function route 'api/hello' [get,post] to 'hello'
[06-04-2020 07:26:55] Mapped function route 'api/HttpTrigger-Java' [get,post] to 'HttpTrigger-Java'
[06-04-2020 07:26:55]
[06-04-2020 07:26:55] Host initialized (424ms)
[06-04-2020 07:26:55] Host started (433ms)
[06-04-2020 07:26:55] Job host started
Http Functions:
hello: [GET,POST] Hosting environment: Production
http://localhost:7071/api/hello
Content root path: C:\Users\ramaswamys\Development\azure-
serverless\serverlessexample\target\azure-functions\serverlessexample-20200403205054646
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
HttpTrigger-Java: [GET,POST] http://localhost:7071/api/HttpTrigger-Java
[06-04-2020 07:27:00] Host lock lease acquired by instance ID
'000000000000000000000000852CF5C4'.
But when I try hitting the api(http://localhost:7071/api/hello) from postman, I dont get any response, I see the below in the command prompt:
[06-04-2020 07:29:04] Executing HTTP request: {
[06-04-2020 07:29:04] "requestId": "af46115f-7a12-49a9-87e0-7fb073a66450",
[06-04-2020 07:29:04] "method": "GET",
[06-04-2020 07:29:04] "uri": "/api/hello"
[06-04-2020 07:29:04] }
[06-04-2020 07:29:05] Executing 'Functions.hello' (Reason='This function was programmatically called
via the host APIs.', Id=7c712cdf-332f-413f-bda2-138f9b89025b)
After this nothing happens:
after 30 min I get a timeout exception like below in the command prompt:
Microsoft.Azure.WebJobs.Host: Timeout value of 00:30:00 was exceeded by function: Functions.hello.
Can someone suggest what might be causing this, why no response is seen in the postman, Am I doing
any thing wrong here ? Am I missing any configuration stuff ? Timely help would be appreciated
Please have a check of your function code.
From the info you offer, the trigger has already be triggered. So that means the code logic inside your trigger is not completed. In other words, you successfully triggered the trigger, but you are stuck in the internal logic of the trigger. Please check your code.

NotXContentException when creating ingest pipeline in Elasticsearch 5.1.2 (Solaris)

I am trying to create a ingest pipeline using below PUT request:
{
"description": "ContentExtractor",
"processors": [
{
"extractor": {
"field": "contentData",
"target_field": "content"
}
}
]
}
But this is resulting in following error:
{
"error": {
"root_cause": [
{
"type": "not_x_content_exception",
"reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
}
],
"type": "not_x_content_exception",
"reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
},
"status": 500
}
I see below exception in ES logs:
org.elasticsearch.common.compress.NotXContentException: Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes
at org.elasticsearch.common.compress.CompressorFactory.compressor(CompressorFactory.java:57) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.common.xcontent.XContentHelper.convertToMap(XContentHelper.java:65) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.ingest.PipelineStore.validatePipeline(PipelineStore.java:154) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.ingest.PipelineStore.put(PipelineStore.java:133) ~[elasticsearch-5.1.2.jar:5.1.2]
This problem happening when Elasticsearch is running in Solaris, same request works fine in case of Linux. What am I doing wrong? Can somebody help me to fix this issue?
Thanks in advance.
Got the exact same error message but (on different version of elasticsearch and) when querying with erroneous
data format (misinterpreted doc https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html : "request body" is expected as plain JSON -- it is not intended to explain HTTP request body)
or using old syntax within path of URL (just after 'index' in the URL) :
curl -XPUT -H "Content-Type: application/json" http://host:port/index/_mapping/_doc -d "mappings=#mymapping.json"
Just remove the "mappings=" and trailing path!

Spring profiles not ordering correctly when obtaining config from Spring Cloud Config Server

I have a Spring Boot application obtaining configuration from Spring Cloud config server (native mode). The base application.yml file in the config location loaded by the config server contains the following:
eureka:
client:
service-url:
defaultZone: ${BOOT_EUREKA_LOCATIONS:http://instance1.localhost:7761/eureka,http://instance2.localhost:7762/eureka,http://instance3.localhost:7763/eureka}
register-with-eureka: true
---
spring:
profiles: test
eureka:
client:
register-with-eureka: false #no registration on Eureka when testing
service-url:
defaultZone: ${BOOT_EUREKA_LOCATIONS:http://sparky:8761/eureka}
When hitting the endpoint for config server (http://mygateway/config-server/myapp/test), I get back the following for the "myapp" application running in profile "test":
{
"name": "myapp",
"profiles": [
"test"
],
"label": null,
"version": null,
"state": null,
"propertySources": [
{
"name": "file:////wherever/application.yml#test",
"source": {
"spring.profiles": "test",
"eureka.client.register-with-eureka": false,
"eureka.client.service-url.defaultZone": "${BOOT_EUREKA_LOCATIONS:http://sparky:8761/eureka}"
}
},
{
"name": "file:////whereever/application.yml",
"source": {
"eureka.client.service-url.defaultZone": "${BOOT_EUREKA_LOCATIONS:http://instance1.localhost:7761/eureka,http://instance2.localhost:7762/eureka,http://instance3.localhost:7763/eureka}"
When running myApp in the test profile, the value of eureka.client.service-url.defaultZone is http://instance1.localhost:7761/eureka,http://instance2.localhost:7762/eureka,http://instance3.localhost:7763/eureka, which is unexpected.
I would have expected the entry in the test profile to override it (as it does if you have the application.yml locally). Thoughts on why I wouldn't be getting the value from the "test" profile when using the value in myApp?
My intent would be to add the "default" values at the top, and have the "profile" override any non-standard defaults.
Update:
myApp/env does NOT show the "application.yml#test" loaded, however it shows the test profile, but only the default values returned back from the config server (not the #test ones):
{
"profiles": [
"test"
],
"server.ports": {
"local.server.port": 7761
},
"configService:file:////wherever/application.yml": {
"eureka.client.service-url.defaultZone": "http://instance1.localhost:7761/eureka,http://instance2.localhost:7762/eureka,http://instance3.localhost:7763/eureka"
It was a complete user error. I was setting the default "test" active profile in the application.yml instead of passing in as an environment variable or bootstrap.yml, therefore it wasn't loaded soon enough for the config server hit.

Categories

Resources