Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    William S Johnstone III
    @wjohnst3
    Could not find artifact org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:pom:unknown in spring-milestones (https://repo.spring.io/milestone)
    ugg...figured it out
    group id moved
    com.google.cloud :)
    Mike Eltsufin
    @meltsufin
    Yup! And it's in Maven Central now.
    Dan Natic
    @dnatic09

    Hey friends. I am trying to run unit tests in my spring-cloud-gcp-storage-starter application. The application works perfectly because it can pull the correct ENV variables to start the GCP client. In the unit test context, it crashes that the credentials are not available. Is there a recommended way to get this library to support running in a unit test context? I need to point the Storage client to a localhost GCP storage server and to run without passing credentials.

    java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

    Elena Felder
    @elefeint
    You'd want to have a test-only configuration file containing a CredentialsProvider bean; something like this:
    @Bean
    public CredentialsProvider credentialsProvider() {
        return NoCredentialsProvider.create();
    }
    William S Johnstone III
    @wjohnst3
    Hey, I'm using GCP secrets manager from a GKE container using SpringCloudGCP v2.0.0-RC2. I would like to configure the credentials location to be an absolute path. My credentials file is in a shared volume mounted in the container. The DefaultCredentialsProvider.class seems to expect the json file to be a resource on the classpath and not an absolute path. Is there a reason for that? I can serve it in an env var as well and put it on the encoded-key, but I would like to use the file. I also would not like to put the credentials in the image. Is there a way around this? I can impl my own provider, but I'm not sure how to make the bean available at bootstrap time. Thank you.
    Mike Eltsufin
    @meltsufin
    You should be able to specify an absolute path.
    Have you tried: spring.cloud.gcp.credentials.location=file:/usr/local/key.json ?
    William S Johnstone III
    @wjohnst3
    Tried location: file:~/secrets/secrets/credentials.json, got an error. I put the json file in my resource dir and it worked fine.
    file:/user/local/secrets/secrets/credentials.json doesn't work either
    William S Johnstone III
    @wjohnst3
    Read access on the location is ok, so it isn't that
    i also pushed the docker image to gke with a small check.
    William S Johnstone III
    @wjohnst3
    Path.of("/secrets/secrets/credentials.json") and checked exists
    Mike Eltsufin
    @meltsufin
    We use the Spring Resource. Are you able to load it using ctx.getResource("file:/secrets/secrets/credentials.json")?
    Attoumane
    @akuma8

    Hi there,
    I use this dependency in my project:

     <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-gcp-starter-trace</artifactId>
      </dependency>

    With

    <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-gcp-dependencies</artifactId>
                    <version>1.2.6.RELEASE</version>
                    <type>pom</type>
                    <scope>import</scope>
     </dependency>

    But at runtime I have a zipkin class not found exception:

    ava.lang.NoClassDefFoundError: zipkin2.Endpoint$Builder
        at java.base/java.lang.invoke.MethodType.throwNoClassDefFoundError(MethodType.java:380)
        at java.base/java.lang.invoke.MethodType.vmResolveFromMethodDescriptorString(MethodType.java:362)
        at java.base/java.lang.invoke.MethodHandle.sendResolveMethodHandle(MethodHandle.java:1227)
        at java.base/java.lang.invoke.MethodHandle.getCPMethodHandleAt(Native Method)
        at java.base/java.lang.invoke.MethodHandle.resolveInvokeDynamic(MethodHandle.java:1074)
        at io.lettuce.core.tracing.BraveTracing$Builder.<init>(BraveTracing.java:112)
        at io.lettuce.core.tracing.BraveTracing$Builder.<init>(BraveTracing.java:106)
        at io.lettuce.core.tracing.BraveTracing.builder(BraveTracing.java:98)
        at org.springframework.cloud.sleuth.autoconfig.instrument.redis.LazyTracing.braveTracing(TraceLettuceClientResourcesBeanPostProcessor.java:133)
        at org.springframework.cloud.sleuth.autoconfig.instrument.redis.LazyTracing.isEnabled(TraceLettuceClientResourcesBeanPostProcessor.java:112)
        at io.lettuce.core.RedisChannelHandler.<init>(RedisChannelHandler.java:88)
        at io.lettuce.core.StatefulRedisConnectionImpl.<init>(StatefulRedisConnectionImpl.java:76)
        at io.lettuce.core.RedisClient.newStatefulRedisConnection(RedisClient.java:661)
        at io.lettuce.core.RedisClient.connectStandaloneAsync(RedisClient.java:277)
        at io.lettuce.core.RedisClient.connect(RedisClient.java:211)
        at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.lambda$getConnection$1(StandaloneConnectionProvider.java:115)
        at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider$$Lambda$1215.0000000040947880.get(Unknown Source)
        at java.base/java.util.Optional.orElseGet(Optional.java:369)
        at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:115)
        at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1459)
        at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1247)
        at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1230)
        at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedReactiveConnection(LettuceConnectionFactory.java:989)
        at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getReactiveConnection(LettuceConnectionFactory.java:445)
        at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getReactiveConnection(LettuceConnectionFactory.java:98)
        at org.springframework.boot.actuate.redis.RedisReactiveHealthIndicator$$Lambda$1187.00000000409473B0.get(Unknown Source)
        at reactor.core.publisher.MonoSupplier.call(MonoSupplier.java:85)
        at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:227)
        at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
        at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
        at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadP
    Do I need to provide that dependency myself?
    Attoumane
    @akuma8
    Note that adding this dependency solved the issue:
            <dependency>
                <groupId>io.zipkin.zipkin2</groupId>
                <artifactId>zipkin</artifactId>
                <version>2.23.2</version>
            </dependency>
    Mike Eltsufin
    @meltsufin
    Are you using a Zipkin server or Stackdriver for storing the traces? This dependency should not be necessary for Stackdriver Trace. See: spring-cloud/spring-cloud-gcp#1757
    Nuno Marujo
    @nhmarujo
    Hi. I am using spring-cloud-gcp-starter-logging and would like to include logstash markers. Is there any way to do so?
    Maybe some way to additionally register the LogstashMarkersJsonProvider?
    Attoumane
    @akuma8
    @meltsufin I use StackDriver. I upgraded from 1.2.0.RELEASE to 1.2.6.RELEASE, I don't have the issue with the 1.2.0.RELEASE.
    gabalmat
    @gabalmat

    Hi all, I have a Spring Boot application that I've deployed to Google App Engine. I'm trying to configure it to use secrets stored in GCP Secret Manager. I've added spring-cloud-gcp-starter-secretmanager:2.0.0 to my project and added this property to my application.yml
    database-name: ${sm://projects/<my-project>/secrets/db-name}

    However I know the secret isn't getting resolved because when I deploy and run the app, I see this in the logs
    org.postgresql.util.PSQLException: FATAL: database "//projects/<my-project>/secrets/db-name" does not exist

    I don't see any output specific to secretmanager, so I can't tell if I've misconfigured something and secretmanager isn't even getting invoked, or if it is getting invoked, and simply can't resolve the secret. I'm using the default properties listed here: https://cloud.spring.io/spring-cloud-static/spring-cloud-gcp/current/reference/html/#configuration-10 and I've already verified that my GAE service account has the correct access to the secrets.

    Anyone know what the output I'm seeing might indicate? Thanks in advance.

    You might want to compare your setup with that
    gabalmat
    @gabalmat

    @meltsufin Thank you. I need to make a correction to my post above though. It turns out my secrets in application.yml are getting resolved just fine. However I should have stated that the following configuration is located in bootstrap.yml

    database-name: ${sm://projects/<my-project>/secrets/db-name}

    So it's the secret in bootstrap.yml that's not getting resolved. I would rather add this configuration to application.yml and then I suspect all would be well. The problem is when I add the spring-cloud-gcp-starter-secretmanager:2.0.0 dependency to my project, I get this error when I try to run:

    java.lang.IllegalArgumentException: A database name must be provided.

    It seems that it wants the spring.cloud.gcp.sql.database-name property defined in bootstrap.yml. When I move that configuration there, the app runs again. However, it seems I can't resolve the secret in bootstrap.yml.

    Any idea why it wants database-name defined in bootstrap.yml? Thanks again

    13 replies
    Rohan Liston
    @rohanliston
    Hi all, I'm trying to upgrade to the new Spring Cloud GCP release train and include the spring-cloud-gcp-starter-data-firestore library using Gradle. I created a project using start.spring.io which seems to have included the correct dependency management config, but when I try to use Firestore classes (e.g. FirestoreTemplate), none of them can be found. The entire com.google.cloud.spring.data package can't be found at all.
    The Spring Cloud GCP docs (https://docs.spring.io/spring-cloud-gcp/docs/current/reference/html/index.html#getting-started) still point to the old config. Is the new release train ready to be used, or should I stick with the old one for now?
    Rohan Liston
    @rohanliston
    Whoops - user error. I hadn't set the Gradle project to auto-refresh within IntelliJ.
    It's working now.
    Mike Eltsufin
    @meltsufin
    :thumbsup:
    William S Johnstone III
    @wjohnst3
    Hey, when calling GCP Secretes Manager I have been putting a @Value annotation like so... @Value("${sm://my-secrete}") However, I need to sometimes default this to "". Is that possible?
    Daniel Zou
    @dzou

    @wjohnst3 -- Hey, unfortunately right now the best we can do for defaulting is related to environment variables: example.secret=${MY_ENV_VARIABLE:${sm://application-secret/latest}} i.e. if MY_ENV_VARIABLE is set, use that, else use the secret.

    We can try to support your use-case though. So in this case, if sm://my-secrete does not exist, you want to default to empty string?

    6 replies
    Ryan Baxter
    @ryanjbaxter
    We are going to be doing a Hoxton SR10 release on Thursday does Spring Cloud GCP 1.2.x need a release?
    Mike Eltsufin
    @meltsufin
    Yes, please, we have some bug fixes since 1.2.6.
    Felipe Adorno
    @FelipeAdorno
    Hi I'm try change from spring-cloud-stream-rabbitmq to spring-cloud-gcp-pubsub-stream-binder but I need autoconfigure DLQ and message ordering, I can achieve that using configuration properties?
    Mike Eltsufin
    @meltsufin
    auto-creating DLQ is in the works (GoogleCloudPlatform/spring-cloud-gcp#358), but you can also just create the DQL topic and subscriptions yourself. There is an issue for message ordering (GoogleCloudPlatform/spring-cloud-gcp#85 ).
    Jonathan Schneider
    @jkschneider
    hi, we just worked out all the terraform necessary to provision a spring cloud eureka server on GCP. anybody at google or elsewhere have a place where we could post a blog or guide on how to do this? wasn’t obvious.
    Mike Eltsufin
    @meltsufin

    hi, we just worked out all the terraform necessary to provision a spring cloud eureka server on GCP. anybody at google or elsewhere have a place where we could post a blog or guide on how to do this? wasn’t obvious.

    I think GCP Community could be great place for something like this. See: https://cloud.google.com/community/tutorials/write

    gabalmat
    @gabalmat

    Hi all, I have an application that needs to read from a GCP Firestore (native mode) database. I would like to use Spring Data repositories, however the only Repository interface I'm able to find for native mode is FirestoreReactiveRepository.

    The problem is that my application is non-reactive and I need the ability to access another non-reactive relational db. When I try to add spring-boot-starter-data-jpa to my project, I get the following error:
    Reactive Repositories are not supported by JPA. Offending repository is <MyRepositoryWhichExtendsFiretoreReactiveRepository>

    Does anyone know of another way to use Spring Data Repositories with Firestore in native mode bedsides using FirestoreReactiveRepository? Thanks in advance!

    Mike Eltsufin
    @meltsufin
    We only support reactive repositories for Firestore currently.
    Spring Data Datastore might be an option for you since it actually uses the same Firestore back-end.
    1 reply
    Spencer Gibb
    @spencergibb
    When we update to boot 2.3.10 via spring-cloud-build 2.3.4.RELEASE gcp has a compile error
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project spring-cloud-gcp-storage: Compilation failure
    [ERROR] /home/spencer/workspace/spring/spring-cloud-gcp/spring-cloud-gcp-storage/src/main/java/org/springframework/cloud/gcp/storage/integration/filters/GcsPersistentAcceptOnceFileListFilter.java:[31,8] org.springframework.cloud.gcp.storage.integration.filters.GcsPersistentAcceptOnceFileListFilter is not abstract and does not override abstract method isDirectory(com.google.cloud.storage.BlobInfo) in org.springframework.integration.file.filters.AbstractDirectoryAwareFileListFilter
    looks like a change in spring integration
    Spencer Gibb
    @spencergibb
    Looks like a change like this will fix it
        @Override
        protected boolean isDirectory(BlobInfo blobInfo) {
            return (blobInfo != null) ? blobInfo.isDirectory() : false;
        }
    working on the Hoxton.SR11 release
    Spencer Gibb
    @spencergibb
    artem approved it for me
    Mike Eltsufin
    @meltsufin
    Thanks for taking care of it!