hound-search/hound

Can't sync repo with 'main' branch

sbuehnemann opened this issue · 10 comments

Hi, I'm using the following config to pull a repo that was created with 'main' as the default branch:

{
  "max-concurrent-indexers": 2,
  "dbpath": "data",
  "health-check-uri": "/healthz",
  "ms-between-poll": 120000,
  "repos": {
    "grp/myrepo": {
      "url": "git@gitlab.com:myorg/grp/myrepo.git",
      "vcs-config" : {
        "ref" : "main"
      }
    }
  }
}

Initial sync starts and I can search the code. But on the next sync cycle the logs tell that it doesn't work:

2021/09/16 15:28:29 Searcher started for grp/myrepo
2021/09/16 15:28:30 merge 0 files + mem
2021/09/16 15:28:30 9274 data bytes, 41852 index bytes
2021/09/16 15:28:30 All indexes built!
2021/09/16 15:28:30 running server at http://localhost:6080...
2021/09/16 15:29:02 Failed to git fetch /data/data/vcs-8f4c4ff10bd1cff3080eac3b8382cc80532d171d, see output below
fatal: Couldn't find remote ref master
fatal: the remote end hung up unexpectedly
Continuing...
2021/09/16 15:29:02 vcs pull error (grp/myrepo - git@gitlab.com:myorg/grp/myrepo.git): exit status 128
2021/09/16 15:29:33 Failed to git fetch /data/data/vcs-8f4c4ff10bd1cff3080eac3b8382cc80532d171d, see output below
fatal: Couldn't find remote ref master
fatal: the remote end hung up unexpectedly
Continuing...

The link in the search results also points to master, so it leads to a 404.

Any clues?

That's weird. Can you tell me if replacing "ref": "main" with "detect-ref" : true stops the errors from happening?

Unfortunately still the same behavior:

021/09/16 18:48:30 Searcher started for grp/myrepo
2021/09/16 18:48:32 merge 0 files + mem
2021/09/16 18:48:32 9274 data bytes, 41852 index bytes
2021/09/16 18:48:32 All indexes built!
2021/09/16 18:48:32 running server at http://localhost:6080...
2021/09/16 18:49:05 Failed to git fetch /data/data/vcs-8f4c4ff10bd1cff3080eac3b8382cc80532d171d, see output below
fatal: Couldn't find remote ref master
fatal: the remote end hung up unexpectedly
Continuing...
2021/09/16 18:49:05 vcs pull error (grp/myrepo - git@gitlab.com:unicepta/grp/myrepo.git): exit status 128
2021/09/16 18:49:37 Failed to git fetch /data/data/vcs-8f4c4ff10bd1cff3080eac3b8382cc80532d171d, see output below
fatal: Couldn't find remote ref master
fatal: the remote end hung up unexpectedly
Continuing...
2021/09/16 18:49:37 vcs pull error (grp/myrepo - git@gitlab.com:unicepta/grp/myrepo.git): exit status 128

Can I enable debugging for more verbose logging?

I just created a public repo you can use for debugging:

{
  "max-concurrent-indexers": 2,
  "dbpath": "data",
  "title": "Unihound",
  "health-check-uri": "/healthz",
  "ms-between-poll": 120000,
  "repos": {
    "grp/myrepo": {
      "url": "git@gitlab.com:m2887/grp/myrepo.git",
      "vcs-config" : {
        "detect-ref" : true
      }
    }
  }
}

I can repro the same behavior, both with detect-ref and a specific ref.

Minimal log entry:

2022/01/16 03:25:25 Failed to git fetch /data/data/vcs-9f9271ce172eba04b863d2fbc9981b6f2e3a527b, see output below
warning: redirecting to https://github.com/nasqueron/notifications.git/
fatal: Couldn't find remote ref master
Continuing...
2022/01/16 03:25:25 vcs pull error (notifications - https://www.github.com/nasqueron/notifications.git): exit status 128

Relevant code to determine the branch (with defaultRef hardcoded to master):

func (g *GitDriver) targetRef(dir string) string {
    var targetRef string
    if g.Ref != "" {
        targetRef = g.Ref
    } else if g.DetectRef {
        targetRef = g.refDetetector.detectRef(dir)
    }

    if targetRef == "" {
        targetRef = defaultRef
    }

    return targetRef
}

To debug this, could be interesting to add some debug logging there.

@sbuehnemann How did you start Hound?

I've added debug info at dereckson@1c99508 and it works perfectly fine with the same configuration file.

Then I've got an illumination flash: I've started by hound server with the etsy/hound image, updated 3 years ago, as documented in the README.

The issue you describe matches the behavior of older versions of Hound, like the one still used in etsy/hound image.

If so, it should be fixed by #405.

Thanks for the hint, I'll try it out tomorrow.

@sbuehnemann let me know if that doesn't solve your problem. I'm going to close this in favor of #405 instead.

@sbuehnemann we've updated the README — try using the Docker instructions again and see if that works for you.

(Thank you for your help @dereckson, much appreciated)