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

Fail to list existing Sinks #214

Closed
NicolaSpreafico opened this issue Aug 19, 2020 · 4 comments
Closed

Fail to list existing Sinks #214

NicolaSpreafico opened this issue Aug 19, 2020 · 4 comments
Assignees
Labels
api: logging Issues related to the googleapis/java-logging API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@NicolaSpreafico
Copy link

Hello,
In my Java application I implemented the Cloud Logging client in order to read the existing sinks.

This is a simple method I'm using to reproduce the issue:

@Test
public void testApi() throws Exception {
    InputStream jsonStream = new FileInputStream(CREDENTIAL_PATH);
    GoogleCredentials credentials = GoogleCredentials.fromStream(jsonStream).createScoped(Collections.singleton("https://www.googleapis.com/auth/logging.read"));

    Logging client = LoggingOptions.newBuilder().setCredentials(credentials).setProjectId("XXXXXXXX").build().getService();

    Page<Sink> sinks = client.listSinks();
    sinks.iterateAll().forEach(sink -> {
        System.out.println(sink.getName());
    });
}

When this code runs I'm getting this error:

java.lang.IllegalArgumentException: logging.googleapis.com/projects/XXXXXXXX/locations/global/buckets/_Required is not a valid sink destination
at com.google.cloud.logging.SinkInfo$Destination.fromPb(SinkInfo.java:348)
at com.google.cloud.logging.SinkInfo.fromPb(SinkInfo.java:592)
at com.google.cloud.logging.Sink.fromPb(Sink.java:259)
at com.google.cloud.logging.Sink$1.apply(Sink.java:267)
at com.google.cloud.logging.Sink$1.apply(Sink.java:264)
at com.google.common.collect.Lists$TransformingRandomAccessList$1.transform(Lists.java:605)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)
at com.google.cloud.PageImpl$PageIterator.computeNext(PageImpl.java:72)
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141)
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136)
at java.base/java.lang.Iterable.forEach(Iterable.java:74)

At first I tried to update the library up to latest version, I can see from documentation that is using 7.0.1 while on Maven repository the latest version is 9.0.1.
Same error...

Using API Explorer I can correctly list the 2 existing items, so it is strictly a client issue and not the API itself.

{
  "sinks": [
    {
      "name": "_Required",
      "destination": "logging.googleapis.com/projects/XXXXXXXX/locations/global/buckets/_Required",
      "filter": "LOG_ID(\"cloudaudit.googleapis.com/activity\") OR LOG_ID(\"externalaudit.googleapis.com/activity\") OR LOG_ID(\"cloudaudit.googleapis.com/system_event\") OR LOG_ID(\"externalaudit.googleapis.com/system_event\") OR LOG_ID(\"cloudaudit.googleapis.com/access_transparency\") OR LOG_ID(\"externalaudit.googleapis.com/access_transparency\")"
    },
    {
      "name": "_Default",
      "destination": "logging.googleapis.com/projects/XXXXXXXX/locations/global/buckets/_Default",
      "filter": "NOT LOG_ID(\"cloudaudit.googleapis.com/activity\") AND NOT LOG_ID(\"externalaudit.googleapis.com/activity\") AND NOT LOG_ID(\"cloudaudit.googleapis.com/system_event\") AND NOT LOG_ID(\"externalaudit.googleapis.com/system_event\") AND NOT LOG_ID(\"cloudaudit.googleapis.com/access_transparency\") AND NOT LOG_ID(\"externalaudit.googleapis.com/access_transparency\")"
    }
  ]
}

Also, trying with another project I'm getting the same issue.

Has something recently change on Cloud Logging service?
If there is a change indeed, is the client obsolete on retrieveing data?

Thanks
Regards

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/java-logging API. label Aug 19, 2020
@athakor athakor self-assigned this Aug 19, 2020
@athakor athakor added the type: question Request for information or clarification. Not an issue. label Aug 19, 2020
@NicolaSpreafico
Copy link
Author

NicolaSpreafico commented Aug 20, 2020

From source code I found where the problem occurs:
https://github.com/googleapis/java-logging/blob/master/google-cloud-logging/src/main/java/com/google/cloud/logging/SinkInfo.java#L340

It seems the new destination like

logging.googleapis.com/projects/XXXXXXXX/locations/global/buckets/_Required

is not yet managed or it does not have a pattern recognized anyway

Basing on a reply from Google support _Required is automatically created and holds Admin Activity audit logs, System Event audit logs, and Access Transparency logs(Refer to documentation).

It is a beta feature so maybe the library does not handle yet? This is breaking the "listSinks" method

@athakor athakor added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed type: question Request for information or clarification. Not an issue. labels Aug 21, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Aug 26, 2020
@athakor athakor removed the 🚨 This issue needs some love. label Aug 26, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Aug 26, 2020
@athakor athakor removed the 🚨 This issue needs some love. label Aug 26, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Aug 26, 2020
@athakor athakor added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed 🚨 This issue needs some love. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Aug 26, 2020
@athakor
Copy link
Contributor

athakor commented Sep 2, 2020

@NicolaSpreafico These issue has been resolved here #226.

closing these issue as it's already resolved, feel free to reopen it if you face.

@athakor athakor closed this as completed Sep 2, 2020
@chingor13
Copy link
Collaborator

Still need to release it. 2.0.0 is pending in master so we may need to backport and release a 1.x version with the cherry picked fix

@chingor13 chingor13 reopened this Sep 2, 2020
@keenan-devrel keenan-devrel assigned simonz130 and unassigned athakor Nov 11, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Feb 10, 2021
@daniel-sanche
Copy link
Contributor

Closing this since v2.0.0 has been released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/java-logging API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

6 participants