Lock artifact on helm index download
- cleanup locks with GC
This commit is contained in:
parent
98deb3fa54
commit
131b9b8e33
|
@ -13,6 +13,7 @@ RUN go mod download
|
|||
COPY main.go main.go
|
||||
COPY api/ api/
|
||||
COPY controllers/ controllers/
|
||||
COPY internal/ internal/
|
||||
|
||||
# build
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o source-controller main.go
|
||||
|
|
|
@ -209,6 +209,19 @@ func (r *HelmRepositoryReconciler) index(repository sourcev1.HelmRepository) (so
|
|||
}, "", err
|
||||
}
|
||||
|
||||
// acquire lock
|
||||
unlock, err := r.Storage.Lock(artifact)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("unable to acquire lock: %w", err)
|
||||
return sourcev1.SourceCondition{
|
||||
Type: sourcev1.ReadyCondition,
|
||||
Status: corev1.ConditionFalse,
|
||||
Reason: sourcev1.IndexFetchFailedReason,
|
||||
Message: err.Error(),
|
||||
}, "", err
|
||||
}
|
||||
defer unlock()
|
||||
|
||||
// save artifact to storage
|
||||
err = r.Storage.WriteFile(artifact, index)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue