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

Sentry-gradle + Skaffold causes infinite restarts with Spring Boot #628

Closed
jasonab opened this issue Jan 9, 2024 · 11 comments · Fixed by #634
Closed

Sentry-gradle + Skaffold causes infinite restarts with Spring Boot #628

jasonab opened this issue Jan 9, 2024 · 11 comments · Fixed by #634
Assignees
Labels
bug Something isn't working Platform: Java

Comments

@jasonab
Copy link

jasonab commented Jan 9, 2024

Gradle Version

8.5

AGP Version

Kotlin 1.9.22

Code Minifier/Optimizer

None

Version

4.1.1

Sentry SDK Version

Spring Boot 7.1.0

Steps to Reproduce

Kotlin + Spring Boot + Gradle

Adding the Sentry Gradle plugin, then running my local dev environment with Skaffold sync, causes Skaffold to infinitely loop its sync. Spring barely finishes starting up before it is killed and auto-restarted because of changes in disk caused by the Gradle plugin. Using Sentry Spring Boot Starter lib directly does not exhibit this behavior.

Expected Result

Spring starts up correctly and continues running

Actual Result

Spring is constantly restarted by Skaffold because of file changes on disk

@jasonab jasonab added bug Something isn't working Platform: Android labels Jan 9, 2024
@github-project-automation github-project-automation bot moved this to Needs Discussion in Mobile & Cross Platform SDK Jan 9, 2024
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Jan 9, 2024
@jasonab jasonab changed the title Sentry-gradle + Skaffold causes infinite restarts Sentry-gradle + Skaffold causes infinite restarts with Spring Boot Jan 9, 2024
@stefanosiano
Copy link
Member

@adinauer Can you have a look into it?

@adinauer
Copy link
Member

@jasonab I've never used skaffold, can you please provide a minimum reproducible sample?

@jasonab
Copy link
Author

jasonab commented Jan 10, 2024

My honest answer is, "no, I can't" because it would require providing not only a code sample, but a k8s cluster definition and a skaffold config to sync the code.

I know that the file change is in the resources directory, but I can't tell what file is being written or changed to cause the sync.

@romtsn
Copy link
Member

romtsn commented Jan 10, 2024

🤔 could you try disable dependencies report?

sentry {
  includeDependenciesReport = false // or .set(false) for .kts
}

another culprit could be telemetry:

sentry {
  telemetry = false // or .set(false) for .kts
}

@jasonab
Copy link
Author

jasonab commented Jan 10, 2024

I will explore those options, thank you

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Jan 10, 2024
@jasonab
Copy link
Author

jasonab commented Jan 11, 2024

@romtsn I tried using those flags, both separately and together, but did not see any change in behavior - skaffold still sees constant file changes to be synced. It appears that every single file in my /resources directory is being touched, somehow. There are no actual changes happening, but Skaffold sees them as being modified.

@adinauer
Copy link
Member

@jasonab have you enabled source context in the gradle plugin? If so, can you please try disabling it.

sentry {
  includeSourceContext = false // or .set(false) for .kts
}

Might also be sentry-debug-meta.properties that changes. If so this issue would be linked to #616

@romtsn is there a way to disable SentryGenerateDebugMetaPropertiesTask without us changing the code?

@jasonab is there a way to run gradle with debug logging to see what sentry tasks execute before a restart?

@adinauer
Copy link
Member

It appears that every single file in my /resources directory is being touched

Ah I missed the "every" when first reading. Hmm I wouldn't know how we cause this. Maybe @romtsn has some ideas.

@jasonab
Copy link
Author

jasonab commented Jan 12, 2024

I tried setting includeSourceContext explicity to false, but that had no effect.

Here are the Gradle tasks that run to generate the jar:

Task :_skaffoldFailIfJibOutOfDate
Task :bootBuildInfo
Task :checkKotlinGradlePluginConfigurationErrors
Task :compileKotlin UP-TO-DATE
Task :compileJava NO-SOURCE
Task :generateGitProperties UP-TO-DATE
Task :collectExternalDependenciesForSentry UP-TO-DATE
Task :generateSentryBundleIdJava SKIPPED
Task :generateSentryDebugMetaPropertiesjava
Task :processResources
Task :classes

Task :jib

After looking at the Skaffold logs in debug mode, I believe that it is the sentry-debug-meta.properties that is changing. If I do a watch on that file, I see the timestamp increment regularly while the dev loop is running. I can only assume that the file is updated late in the Gradle build cycle, causing Skaffold to believe that it has changed, and forcing the infinite loop.

I'm not sure why this causes Skaffold to sync the entire resources directory (which it clearly is), but certainly no other files are changing on my local machine.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Jan 12, 2024
@adinauer
Copy link
Member

@jasonab thanks for checking.

Task :generateSentryDebugMetaPropertiesjava

Yeah this also indicates sentry-debug-meta.properties. We'll look into it.

@romtsn
Copy link
Member

romtsn commented Jan 12, 2024

@jasonab I think you can work it around for now as follows:

import io.sentry.android.gradle.tasks.SentryGenerateDebugMetaPropertiesTask

// or maybe some env variable indicating that Skaffold is running
if (gradle.startParameter.taskNames.any { it.contains("jib" }) {
  tasks.withType<SentryGenerateDebugMetaPropertiesTask>() {
    enabled = false
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Platform: Java
Projects
Archived in project
5 participants