mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-29 17:58:36 +08:00
Merge pull request #1269 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:hotfix/qj-host-remote-file-support-retry-glance to release/2.6.0
* commit 'deafebd3e0ce4b2fd92d35739a5816aba5817871': fix: 1. remote file will retry glance if peer url is not available 2. ssh authorized keys ends with \n
This commit is contained in:
@@ -2781,6 +2781,7 @@ func (self *SHost) AllowPerformAddNetif(ctx context.Context,
|
||||
}
|
||||
|
||||
func (self *SHost) PerformAddNetif(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
log.Debugf("add_netif %s", data)
|
||||
mac, _ := data.GetString("mac")
|
||||
if len(mac) == 0 || len(netutils.FormatMacAddr(mac)) == 0 {
|
||||
return nil, httperrors.NewBadRequestError("Invaild mac address")
|
||||
|
||||
@@ -182,5 +182,5 @@ func MergeAuthorizedKeys(oldKeys string, pubkeys *sshkeys.SSHKeys) string {
|
||||
for _, val := range allkeys {
|
||||
keys = append(keys, val)
|
||||
}
|
||||
return strings.Join(keys, "\n")
|
||||
return strings.Join(keys, "\n") + "\n"
|
||||
}
|
||||
|
||||
@@ -147,7 +147,19 @@ func (r *SRemoteFile) fetch(preChksum string) bool {
|
||||
return fetchSucc
|
||||
}
|
||||
|
||||
// retry download
|
||||
func (r *SRemoteFile) download(getData bool, preChksum string) bool {
|
||||
result := r.downloadInternal(getData, preChksum)
|
||||
if !result && len(r.downloadUrl) > 0 {
|
||||
log.Errorf("download from cached url %s failed, try direct download from %s ...", r.downloadUrl, r.url)
|
||||
r.downloadUrl = ""
|
||||
result = r.downloadInternal(getData, preChksum)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (r *SRemoteFile) downloadInternal(getData bool, preChksum string) bool {
|
||||
os.Remove(r.tmpPath)
|
||||
fi, err := os.Create(r.tmpPath)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
|
||||
Reference in New Issue
Block a user