Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Check git repo is writable before proceeding #865

Merged
merged 2 commits into from
Dec 11, 2017

Conversation

squaremo
Copy link
Member

@squaremo squaremo commented Dec 4, 2017

Our "gitsync" mechanism relies on being able to push a tag back to the
upstream repository. But in the daemon, we consider it ready to go
once we've managed to clone the repository. This results in confusing
errors: if the repo is read-only (either because the deploy key is, or
because it's an https URL) then syncing will succeed in effect, but
report problems.

This commit adds a check that we can write to the upstream repo,
before considering the daemon ready to go. The check is that we can
push an otherwise-meaningless tag (then delete it) -- this being a
fairly innocuous write operation.

I have made this generate a "helpful error" (i.e., with extended help text), so that it will be returned to fluxctl if the daemon has not got past cloning the repo.

Our "gitsync" mechanism relies on being able to push a tag back to the
upstream repository. But in the daemon, we consider it ready to go
once we've managed to clone the repository. This results in confusing
errors: if the repo is read-only (either because the deploy key is, or
because it's an `https` URL) then syncing will succeed in effect, but
report problems.

This commit adds a check that we can write to the upstream repo,
before considering the daemon ready to go. The check is that we can
push an otherwise-meaningless tag (then delete it) -- this being a
fairly innocuous write operation.
While starting up, the daemon continually checks whether it can clone
the upstream repo, and if so, whether it can write to it. If this
results in an error, it stores this away and keeps trying. Until it
succeeds, when asked to do anything related to the git repo (i.e.,
almost anything), it responds with the stored error.

In that interim, it's possible that a user will ask for something that
needs a cloned repo; and if so, a helpful error is .. helpful.
@squaremo squaremo changed the title Issue/858 check git write Check git repo is writable before proceeding Dec 4, 2017
Copy link
Contributor

@samb1729 samb1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM, only a nitpick to note

@@ -16,6 +16,7 @@ import (

const (
DefaultCloneTimeout = 2 * time.Minute
CheckPushTag = "flux-write-check"

This comment was marked as abuse.

This comment was marked as abuse.

@squaremo squaremo merged commit 64c455a into master Dec 11, 2017
@squaremo squaremo deleted the issue/858-check-git-write branch December 11, 2017 17:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants