meshcloud / unipipe-service-broker

GitOps Open Service Broker - exposes service instances and bindings as files in a git repository
Apache License 2.0
14 stars 11 forks source link

Support shallow fetch to optimize start up cost for large repos #127

Open tracemeyers opened 12 months ago

tracemeyers commented 12 months ago

I have a lot of OSB provisionings in my git repo and a lot of chatty commits that result in very, very, very long clones every time a new k8s pod of unipipe is created.

It would be great to have an optional env var to configure shallow fetches for such scenarios. Something like this but not hard coded (requires jgit 6.3+).

diff --git a/src/main/kotlin/io/meshcloud/dockerosb/persistence/GitHandlerService.kt b/src/main/kotlin/io/meshcloud/dockerosb/persistence/GitHandlerService.kt
index 4d8d4cd..9b8af45 100644
--- a/src/main/kotlin/io/meshcloud/dockerosb/persistence/GitHandlerService.kt
+++ b/src/main/kotlin/io/meshcloud/dockerosb/persistence/GitHandlerService.kt
@@ -295,6 +295,7 @@ class GitHandlerService(

           // fetch remote
           git.fetch()
+              .setDepth(1)
               .apply {
                 refSpecs = listOf(
                     RefSpec("refs/heads/${gitConfig.remoteBranch}:refs/remotes/origin/${gitConfig.remoteBranch}")
JohannesRudolph commented 12 months ago

This is a very good idea.

However, shallow clones with insufficient depth can lead to issues with some git operations like rebase (for sure, but iirc that's not used in unripe) and merge (not sure). I think we've seen that with https://github.com/meshcloud/gate-resource but can't find the original issue anymore right now.

Have you attempted to run with a minimum depth in production?

tracemeyers commented 12 months ago

Yes we run it in production with a depth of 1.

On Tue, Nov 7, 2023, 16:15 Johannes Rudolph @.***> wrote:

This is a very good idea.

However, shallow clones with insufficient depth can lead to issues with some git operations like rebase (for sure, but iirc that's not used in unripe) and merge (not sure). I think we've seen that with https://github.com/meshcloud/gate-resource but can't find the original issue anymore right now.

Have you attempted to run with a minimum depth in production?

— Reply to this email directly, view it on GitHub https://github.com/meshcloud/unipipe-service-broker/issues/127#issuecomment-1800276847, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKVEWQRTNNRPZU4UNPKCFTYDKXJBAVCNFSM6AAAAAA7BVTCISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBQGI3TMOBUG4 . You are receiving this because you authored the thread.Message ID: @.***>

JohannesRudolph commented 4 months ago

HI @tracemeyers we've upgrade to jgit 6.10 since. Would you want to pick this optimization up again and provide a PR?