Skip to content

Commit 7cb67cf

Browse files
GiteaBotbohde
andauthored
fix: allow actions artifacts storage migration to complete succesfully (#31251) (#31257)
Backport #31251 by @bohde Change the copy to use `ActionsArtifact.StoragePath` instead of the `ArtifactPath`. Skip artifacts that are expired, and don't error if the file to copy does not exist. --- When trying to migrate actions artifact storage from local to MinIO, we encountered errors that prevented the process from completing successfully: * The migration tries to copy the files using the per-run `ArtifactPath`, instead of the unique `StoragePath`. * Artifacts that have been marked expired and had their files deleted would throw an error * Artifacts that are pending, but don't have a file uploaded yet will throw an error. This PR addresses these cases, and allow the process to complete successfully. Co-authored-by: Rowan Bohde <rowan.bohde@gmail.com>
1 parent 1c1c2d3 commit 7cb67cf

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

cmd/migrate_storage.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ package cmd
55

66
import (
77
"context"
8+
"errors"
89
"fmt"
10+
"io/fs"
911
"strings"
1012

1113
actions_model "code.gitea.io/gitea/models/actions"
@@ -162,8 +164,20 @@ func migrateActionsLog(ctx context.Context, dstStorage storage.ObjectStorage) er
162164

163165
func migrateActionsArtifacts(ctx context.Context, dstStorage storage.ObjectStorage) error {
164166
return db.Iterate(ctx, nil, func(ctx context.Context, artifact *actions_model.ActionArtifact) error {
165-
_, err := storage.Copy(dstStorage, artifact.ArtifactPath, storage.ActionsArtifacts, artifact.ArtifactPath)
166-
return err
167+
if artifact.Status == int64(actions_model.ArtifactStatusExpired) {
168+
return nil
169+
}
170+
171+
_, err := storage.Copy(dstStorage, artifact.StoragePath, storage.ActionsArtifacts, artifact.StoragePath)
172+
if err != nil {
173+
// ignore files that do not exist
174+
if errors.Is(err, fs.ErrNotExist) {
175+
return nil
176+
}
177+
return err
178+
}
179+
180+
return nil
167181
})
168182
}
169183

0 commit comments

Comments
 (0)