Fix: The error of cannot fetch addon package breaks the loop to continue looking for addon package in the remaining registries (#5188)

Signed-off-by: zhaohuihui <zhaohuihui_yewu@cmss.chinamobile.com>
(cherry picked from commit 9263633db7)

Co-authored-by: zhaohuihui <zhaohuihui_yewu@cmss.chinamobile.com>
This commit is contained in:
github-actions[bot]
2022-12-14 13:36:05 +08:00
committed by GitHub
co-authored by zhaohuihui
parent f36c8f8fbb
commit 18639ccbae
3 changed files with 5 additions and 2 deletions
+3
View File
@@ -43,6 +43,9 @@ var (
// ErrBothCueAndYamlTmpl means yaml and cue app template are exist in addon
ErrBothCueAndYamlTmpl = NewAddonError("yaml and cue app template are exist in addon, should only keep one of them")
// ErrFetch means fetch addon package error(package not exist or parse archive error and so on)
ErrFetch = NewAddonError("cannot fetch addon package")
)
// WrapErrRateLimit return ErrRateLimit if is the situation, or return error directly
+1 -1
View File
@@ -174,7 +174,7 @@ func (i versionedRegistry) loadAddon(ctx context.Context, name, version string)
addonPkg.Meta.SystemRequirements = LoadSystemRequirements(addonVersion.Annotations)
return addonPkg, nil
}
return nil, fmt.Errorf("cannot load addon '%s'(%s) package from registry '%s'", addonVersion.Name, addonVersion.Version, i.name)
return nil, ErrFetch
}
// loadAddonVersions Load all available versions of the addon
+1 -1
View File
@@ -575,7 +575,7 @@ func enableAddon(ctx context.Context, k8sClient client.Client, dc *discovery.Dis
continue
}
err = pkgaddon.EnableAddon(ctx, addonName, version, k8sClient, dc, apply.NewAPIApplicator(k8sClient), config, registry, args, nil, pkgaddon.FilterDependencyRegistries(i, registries), opts...)
if errors.Is(err, pkgaddon.ErrNotExist) {
if errors.Is(err, pkgaddon.ErrNotExist) || errors.Is(err, pkgaddon.ErrFetch) {
continue
}
if unMatchErr := new(pkgaddon.VersionUnMatchError); errors.As(err, unMatchErr) {