Compare commits

...

8 Commits

Author SHA1 Message Date
Zexi Li
436b809249 Merge pull request #12390 from zexi/automated-cherry-pick-of-#12226-upstream-release-3.8
Automated cherry pick of #12226: [WIP] fix(baremetal): avoid redfish resp nil cause panic
2021-10-12 11:47:03 +08:00
Zexi Li
d894992e29 fix(baremetal): avoid redfish resp nil cause panic 2021-10-12 11:33:31 +08:00
Zexi Li
c0db3ead14 Merge pull request #12388 from ioito/automated-cherry-pick-of-#12387-upstream-release-3.8
Automated cherry pick of #12387: fix(region): support tag sync for mongodb
2021-10-11 19:18:23 +08:00
Qu Xuan
91dbb1b64e fix(region): support tag sync for mongodb 2021-10-11 17:12:31 +08:00
Zexi Li
7f52cc5ec0 Merge pull request #12385 from zexi/automated-cherry-pick-of-#12384-upstream-release-3.8
Automated cherry pick of #12384: fix(glance): s3 uploaded image removed
2021-10-11 15:02:39 +08:00
Zexi Li
213637679e Merge pull request #12382 from rainzm/automated-cherry-pick-of-#12381-upstream-release-3.8
Automated cherry pick of #12381: fix(devtool): creates a forward using the specified address
2021-10-11 12:45:19 +08:00
Zexi Li
02dc737ccd fix(glance): s3 uploaded image removed 2021-10-11 12:43:35 +08:00
rainzm
627e97b73a fix(devtool): creates a forward using the specified address 2021-10-11 10:55:49 +08:00
11 changed files with 130 additions and 19 deletions

View File

@@ -43,6 +43,9 @@ const (
SERVICE_TYPE_ETCD = "etcd"
SERVICE_TYPE_INFLUXDB = "influxdb"
STATUS_UPDATE_TAGS = "update_tags"
STATUS_UPDATE_TAGS_FAILED = "update_tags_fail"
)
var (

View File

@@ -784,17 +784,13 @@ func (self *SMongoDB) PerformRemoteUpdate(ctx context.Context, userCred mcclient
func (self *SMongoDB) StartRemoteUpdateTask(ctx context.Context, userCred mcclient.TokenCredential, replaceTags bool, parentTaskId string) error {
data := jsonutils.NewDict()
if replaceTags {
data.Add(jsonutils.JSONTrue, "replace_tags")
data.Add(jsonutils.NewBool(replaceTags), "replace_tags")
task, err := taskman.TaskManager.NewTask(ctx, "MongoDBRemoteUpdateTask", self, userCred, data, parentTaskId, "", nil)
if err != nil {
return errors.Wrap(err, "NewTask")
}
if task, err := taskman.TaskManager.NewTask(ctx, "MongoDBRemoteUpdateTask", self, userCred, data, parentTaskId, "", nil); err != nil {
log.Errorln(err)
return errors.Wrap(err, "Start ElasticcacheRemoteUpdateTask")
} else {
self.SetStatus(userCred, api.DBINSTANCE_UPDATE_TAGS, "StartRemoteUpdateTask")
task.ScheduleRun(nil)
}
return nil
self.SetStatus(userCred, apis.STATUS_UPDATE_TAGS, "StartRemoteUpdateTask")
return task.ScheduleRun(nil)
}
func (self *SMongoDB) OnMetadataUpdated(ctx context.Context, userCred mcclient.TokenCredential) {

View File

@@ -0,0 +1,94 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package tasks
import (
"context"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/util/logclient"
)
type MongoDBRemoteUpdateTask struct {
taskman.STask
}
func init() {
taskman.RegisterTask(MongoDBRemoteUpdateTask{})
}
func (self *MongoDBRemoteUpdateTask) taskFail(ctx context.Context, mongodb *models.SMongoDB, err error) {
mongodb.SetStatus(self.UserCred, apis.STATUS_UPDATE_TAGS_FAILED, err.Error())
self.SetStageFailed(ctx, jsonutils.NewString(err.Error()))
}
func (self *MongoDBRemoteUpdateTask) OnInit(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
mongodb := obj.(*models.SMongoDB)
replaceTags := jsonutils.QueryBoolean(self.Params, "replace_tags", false)
iMongoDB, err := mongodb.GetIMongoDB()
if err != nil {
self.taskFail(ctx, mongodb, errors.Wrapf(err, "GetIMongoDB"))
return
}
oldTags, err := iMongoDB.GetTags()
if err != nil {
if errors.Cause(err) == cloudprovider.ErrNotSupported || errors.Cause(err) == cloudprovider.ErrNotImplemented {
self.OnRemoteUpdateComplete(ctx, mongodb, nil)
return
}
self.taskFail(ctx, mongodb, errors.Wrapf(err, "GetTags"))
return
}
tags, err := mongodb.GetAllUserMetadata()
if err != nil {
self.taskFail(ctx, mongodb, errors.Wrapf(err, "GetAllUserMetadata"))
return
}
tagsUpdateInfo := cloudprovider.TagsUpdateInfo{OldTags: oldTags, NewTags: tags}
err = cloudprovider.SetTags(ctx, iMongoDB, mongodb.ManagerId, tags, replaceTags)
if err != nil {
if errors.Cause(err) == cloudprovider.ErrNotSupported || errors.Cause(err) == cloudprovider.ErrNotImplemented {
self.OnRemoteUpdateComplete(ctx, mongodb, nil)
return
}
logclient.AddActionLogWithStartable(self, mongodb, logclient.ACT_UPDATE_TAGS, err, self.GetUserCred(), false)
self.SetStageFailed(ctx, jsonutils.NewString(err.Error()))
return
}
logclient.AddActionLogWithStartable(self, mongodb, logclient.ACT_UPDATE_TAGS, tagsUpdateInfo, self.GetUserCred(), true)
self.OnRemoteUpdateComplete(ctx, mongodb, nil)
}
func (self *MongoDBRemoteUpdateTask) OnRemoteUpdateComplete(ctx context.Context, mongodb *models.SMongoDB, data jsonutils.JSONObject) {
self.SetStage("OnSyncStatusComplete", nil)
models.StartResourceSyncStatusTask(ctx, self.UserCred, mongodb, "MongoDBSyncstatusTask", self.GetTaskId())
}
func (self *MongoDBRemoteUpdateTask) OnSyncStatusComplete(ctx context.Context, mongodb *models.SMongoDB, data jsonutils.JSONObject) {
self.SetStageComplete(ctx, nil)
}
func (self *MongoDBRemoteUpdateTask) OnSyncStatusCompleteFailed(ctx context.Context, mongodb *models.SMongoDB, data jsonutils.JSONObject) {
self.SetStageFailed(ctx, data)
}

View File

@@ -104,6 +104,7 @@ func checkSshableForYunionCloud(session *mcclient.ClientSession, serverDetail *c
lfParams := jsonutils.NewDict()
lfParams.Set("proto", jsonutils.NewString("tcp"))
lfParams.Set("port", jsonutils.NewInt(22))
lfParams.Set("addr", jsonutils.NewString(ip))
data, err := modules.Servers.PerformAction(session, serverDetail.Id, "list-forward", lfParams)
if err != nil {
err = errors.Wrapf(err, "unable to List Forward for server %s", serverDetail.Id)

View File

@@ -115,7 +115,7 @@ type SImage struct {
// 镜像大小, 单位Byte
Size int64 `nullable:"true" list:"user" create:"optional"`
// 存储地址
Location string `nullable:"true"`
Location string `nullable:"true" list:"user"`
// 镜像格式
DiskFormat string `width:"20" charset:"ascii" nullable:"true" list:"user" create:"optional" default:"raw"`

View File

@@ -28,6 +28,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/image/models"
"yunion.io/x/onecloud/pkg/image/options"
"yunion.io/x/onecloud/pkg/mcclient/modules/notify"
"yunion.io/x/onecloud/pkg/util/procutils"
)
@@ -89,8 +90,10 @@ func (self *PutImageTask) OnInit(ctx context.Context, obj db.IStandaloneModel, d
if err != nil {
log.Errorf("failed update image location %s", err)
} else {
if err = procutils.NewCommand("rm", "-f", imagePath).Run(); err != nil {
log.Errorf("failed remove file %s: %s", imagePath, err)
if !strings.Contains(imagePath, options.Options.S3MountPoint) {
if err = procutils.NewCommand("rm", "-f", imagePath).Run(); err != nil {
log.Errorf("failed remove file %s: %s", imagePath, err)
}
}
}
}

View File

@@ -71,12 +71,13 @@ const (
ALIYUN_ES_API_VERSION = "2017-06-13"
ALIYUN_KAFKA_API_VERSION = "2019-09-16"
ALIYUN_SERVICE_ECS = "ecs"
ALIYUN_SERVICE_VPC = "vpc"
ALIYUN_SERVICE_RDS = "rds"
ALIYUN_SERVICE_SLB = "slb"
ALIYUN_SERVICE_KVS = "kvs"
ALIYUN_SERVICE_NAS = "nas"
ALIYUN_SERVICE_ECS = "ecs"
ALIYUN_SERVICE_VPC = "vpc"
ALIYUN_SERVICE_RDS = "rds"
ALIYUN_SERVICE_SLB = "slb"
ALIYUN_SERVICE_KVS = "kvs"
ALIYUN_SERVICE_NAS = "nas"
ALIYUN_SERVICE_MONGO_DB = "mongodb"
)
var (

View File

@@ -252,6 +252,10 @@ func (self *SRegion) GetMongoDBsByType(mongoType string) ([]SMongoDB, error) {
return dbs, nil
}
func (self *SMongoDB) SetTags(tags map[string]string, replace bool) error {
return self.region.SetResourceTags(ALIYUN_SERVICE_MONGO_DB, "INSTANCE", self.GetId(), tags, replace)
}
func (self *SRegion) GetICloudMongoDBById(id string) (cloudprovider.ICloudMongoDB, error) {
db, err := self.GetMongoDB(id)
if err != nil {

View File

@@ -38,6 +38,8 @@ func (self *SRegion) tagRequest(serviceType, action string, params map[string]st
return self.kvsRequest(action, params)
case ALIYUN_SERVICE_NAS:
return self.nasRequest(action, params)
case ALIYUN_SERVICE_MONGO_DB:
return self.mongodbRequest(action, params)
default:
return nil, fmt.Errorf("invalid service type")
}

View File

@@ -251,6 +251,10 @@ func (self *SRegion) DeleteMongoDB(id string) error {
})
}
func (self *SMongoDB) SetTags(tags map[string]string, replace bool) error {
return self.region.SetResourceTags("mongodb", "instance", []string{self.InstanceId}, tags, replace)
}
func (self *SMongoDB) GetIBackups() ([]cloudprovider.SMongoDBBackup, error) {
return self.region.GetMongoDBBackups(self.InstanceId)
}

View File

@@ -177,6 +177,9 @@ func (r *SBaseRedfishClient) Probe(ctx context.Context) error {
if r.IsDebug {
log.Debugf("%s", resp.PrettyString())
}
if resp == nil {
return errors.Errorf("Response is nil")
}
err = r.IRedfishDriver().ParseRoot(resp)
if err != nil {
return errors.Wrap(err, "r.IRedfishDriver().ParseRoot(resp)")