adapt to services
This commit is contained in:
@@ -41,9 +41,17 @@ type Spec struct {
|
||||
}
|
||||
|
||||
func (b *ArgoBuilder) CreateDAG() (string, error) {
|
||||
|
||||
// handle services by checking if there is only one processing with hostname and port
|
||||
if (b.isService()){
|
||||
b.createNginxVolumes()
|
||||
}
|
||||
|
||||
b.createTemplates()
|
||||
b.createDAGstep()
|
||||
b.createVolumes()
|
||||
|
||||
|
||||
if b.Timeout > 0 {
|
||||
b.Workflow.Spec.Timeout = b.Timeout
|
||||
}
|
||||
@@ -87,7 +95,7 @@ func (b *ArgoBuilder) createTemplates() {
|
||||
image_name := strings.Split(command, " ")[0] // TODO : decide where to store the image name, GUI or models.computing.Image
|
||||
temp_container := Container{Image: image_name} // TODO : decide where to store the image name, GUI or models.computing.Image
|
||||
temp_container.Command = getComputingCommands(command)
|
||||
temp_container.Args = getComputingArgs(strings.Split(args, " "), command)
|
||||
temp_container.Args = getComputingArgs(args, command)
|
||||
// Only for dev purpose,
|
||||
input_names := getComputingEnvironmentName(strings.Split(env, " "))
|
||||
|
||||
@@ -100,6 +108,7 @@ func (b *ArgoBuilder) createTemplates() {
|
||||
new_temp := Template{Name: argo_name, Container: temp_container}
|
||||
new_temp.Inputs.Parameters = inputs_container
|
||||
new_temp.Container.VolumeMounts = append(new_temp.Container.VolumeMounts, VolumeMount{Name: "workdir", MountPath: "/mnt/vol"}) // TODO : replace this with a search of the storage / data source name
|
||||
new_temp.Container.VolumeMounts = append(new_temp.Container.VolumeMounts, VolumeMount{Name: "nginx-demo", MountPath: "/usr/share/nginx"}) // Used for processing services' demo with nginx
|
||||
b.Workflow.Spec.Templates = append(b.Workflow.Spec.Templates, new_temp)
|
||||
|
||||
}
|
||||
@@ -136,9 +145,20 @@ func (b *ArgoBuilder) createVolumes() {
|
||||
b.Workflow.Spec.Volumes = append(b.Workflow.Spec.Volumes, new_volume)
|
||||
}
|
||||
|
||||
// For demo purposes, until we implement the use of storage ressources
|
||||
func (b *ArgoBuilder) createNginxVolumes() {
|
||||
new_volume := VolumeClaimTemplate{}
|
||||
new_volume.Metadata.Name = "nginx-demo"
|
||||
new_volume.Spec.AccessModes = []string{"ReadWriteOnce"}
|
||||
new_volume.Spec.Resources.Requests.Storage = "1Gi"
|
||||
|
||||
b.Workflow.Spec.Volumes = append(b.Workflow.Spec.Volumes, new_volume)
|
||||
}
|
||||
|
||||
|
||||
func (b *ArgoBuilder) getDependency(current_computing_id string) (dependencies []string) {
|
||||
for _, link := range b.graph.Links {
|
||||
if !b.IsProcessing(link.Source.ID) || !b.IsProcessing(link.Destination.ID) {
|
||||
if !b.IsProcessing(link.Source.ID) {
|
||||
continue
|
||||
}
|
||||
source := b.graph.Items[link.Source.ID].Processing
|
||||
@@ -159,17 +179,20 @@ func getComputingCommands(user_input string) []string {
|
||||
return strings.Split(user_input, " ")
|
||||
}
|
||||
|
||||
func getComputingArgs(user_input []string, command string) (list_args []string) {
|
||||
func getComputingArgs(user_input string, command string) (list_args []string) {
|
||||
if len(user_input) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
args := strings.Split(user_input," ")
|
||||
|
||||
// quickfix that might need improvement
|
||||
if strings.Contains(command, "sh -c") {
|
||||
list_args = append(list_args, strings.Join(user_input, " "))
|
||||
list_args = append(list_args, strings.Join(args, " "))
|
||||
return
|
||||
}
|
||||
|
||||
list_args = append(list_args, user_input...)
|
||||
list_args = append(list_args, args...)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -262,3 +285,20 @@ func getStringValue(comp resource_model.AbstractResource, key string) string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (b *ArgoBuilder) isService() bool{
|
||||
// for dev purpose do not commit to main
|
||||
if os.Getenv("test_service") != ""{
|
||||
return true
|
||||
}
|
||||
|
||||
comp_list := b.getProcessings()
|
||||
|
||||
if len(comp_list) != 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
comp := comp_list[0]
|
||||
|
||||
return comp.Data.ResourceModel.Model["port"].Value != "" && comp.Data.ResourceModel.Model["hostname"].Value != ""
|
||||
}
|
||||
Reference in New Issue
Block a user