|
|
|
@@ -6,6 +6,7 @@ import ( |
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/algo" |
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" |
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/model" |
|
|
|
"gitlink.org.cn/jcce-pcm/utils/tool" |
|
|
|
"io" |
|
|
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" |
|
|
|
"k8s.io/apimachinery/pkg/runtime" |
|
|
|
@@ -20,7 +21,7 @@ func NewCloudScheduler() *cloudScheduler { |
|
|
|
return &cloudScheduler{} |
|
|
|
} |
|
|
|
|
|
|
|
func (cs cloudScheduler) pickOptimalStrategy(task *algo.Task, providers ...*algo.Provider) (*algo.Task, error) { |
|
|
|
func (cs *cloudScheduler) pickOptimalStrategy(task *algo.Task, providers ...*algo.Provider) (*algo.Task, error) { |
|
|
|
strategy := algo.NewK8sStrategy(task, providers...) |
|
|
|
taskResult, err := algo.ScheduleWithFullCollaboration(strategy, strategy.ProviderList) |
|
|
|
if err != nil { |
|
|
|
@@ -29,12 +30,13 @@ func (cs cloudScheduler) pickOptimalStrategy(task *algo.Task, providers ...*algo |
|
|
|
return taskResult, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (cs cloudScheduler) getNewStructForDb(task *types.TaskInfo, participantIds []int64) (interface{}, error) { |
|
|
|
func (cs *cloudScheduler) getNewStructForDb(task *types.TaskInfo, participantIds []int64) (interface{}, error) { |
|
|
|
bytes, err := json.Marshal(task.Metadata) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
cloud := cs.UnMarshalK8sStruct(string(bytes), task.TaskId) |
|
|
|
cloud.Id = tool.GenSnowflakeID() |
|
|
|
cloud.YamlString = string(bytes) |
|
|
|
if len(participantIds) != 0 { |
|
|
|
cloud.ParticipantId = participantIds[0] |
|
|
|
@@ -42,7 +44,7 @@ func (cs cloudScheduler) getNewStructForDb(task *types.TaskInfo, participantIds |
|
|
|
return cloud, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (cs cloudScheduler) UnMarshalK8sStruct(yamlString string, taskId int64) model.Cloud { |
|
|
|
func (cs *cloudScheduler) UnMarshalK8sStruct(yamlString string, taskId int64) model.Cloud { |
|
|
|
var cloud model.Cloud |
|
|
|
d := kyaml.NewYAMLOrJSONDecoder(bytes.NewBufferString(yamlString), 4096) |
|
|
|
var err error |
|
|
|
|