Skip to content

Commit

Permalink
fix: failed to download upgrade package from github (#92)
Browse files Browse the repository at this point in the history
Co-authored-by: liuyu <>
  • Loading branch information
eball authored Oct 17, 2024
1 parent 9bf03fe commit 4e23ba5
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/upgrade/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package upgrade
import (
"context"
"fmt"
"net/url"
"os"
"os/exec"
"strings"

"k8s.io/klog/v2"
)
Expand All @@ -15,6 +17,8 @@ type DownloadRelease struct {
devMode bool
}

const CDN = "https://dc3p1870nn3cj.cloudfront.net"

func (d *DownloadRelease) Run(ctx *PipelineContext) error {
d.jobCtx, d.jobCancel = context.WithCancel(ctx.InstallCtx)
installed, err := GetTerminusVersion(d.jobCtx, ctx.K8sClient)
Expand All @@ -38,7 +42,20 @@ func (d *DownloadRelease) Run(ctx *PipelineContext) error {

ctx.InstallPackgePath, err = github.downloadAndUnpack(d.jobCtx, installTgz)
if err != nil {
return err
klog.Error(err)
urlStrTokens := strings.Split(installTgz.String(), "/")
cdnUrlStr := strings.Join([]string{CDN, urlStrTokens[len(urlStrTokens)-1]}, "/")
cdnUrl, err := url.Parse(cdnUrlStr)
if err != nil {
klog.Error("get cdn url error, ", err)
return err
}

klog.Warning("failed to download release package, ", ctx.ReleaseVersion, ", try to download from cdn, ", cdnUrlStr)
ctx.InstallPackgePath, err = github.downloadAndUnpack(d.jobCtx, cdnUrl)
if err != nil {
return err
}
}

default:
Expand Down

0 comments on commit 4e23ba5

Please sign in to comment.