From fa61d0a7173d077b1726a52d816241205f1e2f88 Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Tue, 2 Mar 2021 20:42:54 +0800 Subject: [PATCH] mirror: retry publish if tarball is not valid (#1174) --- cmd/mirror.go | 5 +++-- pkg/cluster/operation/upgrade.go | 2 +- server/handler/component.go | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/mirror.go b/cmd/mirror.go index 6fb455426e..6be0a212cd 100644 --- a/cmd/mirror.go +++ b/cmd/mirror.go @@ -465,8 +465,9 @@ func newMirrorPublishCmd() *cobra.Command { goos, goarch, flagSet, ) if err != nil { - // retry if the error is manifest too old - if err == repository.ErrManifestTooOld { + // retry if the error is manifest too old or validation failed + if err == repository.ErrManifestTooOld || + strings.Contains(err.Error(), "INVALID TARBALL") { fmt.Printf("server returned an error: %s, retry...\n", err) if _, ferr := tarfile.Seek(0, 0); ferr != nil { // reset the reader return ferr diff --git a/pkg/cluster/operation/upgrade.go b/pkg/cluster/operation/upgrade.go index d2801adf8c..c53cebf306 100644 --- a/pkg/cluster/operation/upgrade.go +++ b/pkg/cluster/operation/upgrade.go @@ -234,7 +234,7 @@ func increaseScheduleLimit(ctx context.Context, pc *api.PDClient) ( newLimit = regionScheduleLimitThreshold } if err := pc.SetReplicationConfig("region-schedule-limit", newLimit); err != nil { - // try to revert leader scheduler limit by our best effort, does not make sence + // try to revert leader scheduler limit by our best effort, does not make sense // to handle this error again _ = pc.SetReplicationConfig("leader-schedule-limit", currLeaderScheduleLimit) return currLeaderScheduleLimit, currRegionScheduleLimit, err diff --git a/server/handler/component.go b/server/handler/component.go index e954ec6854..687fa8fa46 100644 --- a/server/handler/component.go +++ b/server/handler/component.go @@ -102,6 +102,7 @@ func (h *componentSigner) sign(r *http.Request, m *v1manifest.RawManifest) (sr * case model.ErrorWrongSignature: return nil, ErrorForbiden case model.ErrorWrongChecksum, model.ErrorWrongFileName: + log.Errorf("Publish component: %s", err.Error()) return nil, ErrorInvalidTarball case nil: return nil, nil