Prepull for pod & Asym Jobs
This commit is contained in:
@@ -3,10 +3,10 @@ package models
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"oc-monitord/conf"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/config"
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/models"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources/native_tools"
|
||||
@@ -20,10 +20,11 @@ type Parameter struct {
|
||||
}
|
||||
|
||||
type Container struct {
|
||||
Image string `yaml:"image"`
|
||||
Command []string `yaml:"command,omitempty,flow"`
|
||||
Args []string `yaml:"args,omitempty,flow"`
|
||||
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty"`
|
||||
Image string `yaml:"image"`
|
||||
ImagePullPolicy string `yaml:"imagePullPolicy,omitempty"`
|
||||
Command []string `yaml:"command,omitempty,flow"`
|
||||
Args []string `yaml:"args,omitempty,flow"`
|
||||
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Container) AddVolumeMount(volumeMount VolumeMount, volumes []VolumeMount) []VolumeMount {
|
||||
@@ -45,9 +46,10 @@ func (c *Container) AddVolumeMount(volumeMount VolumeMount, volumes []VolumeMoun
|
||||
}
|
||||
|
||||
type VolumeMount struct {
|
||||
Name string `yaml:"name"`
|
||||
MountPath string `yaml:"mountPath"`
|
||||
Storage *resources.StorageResource `yaml:"-"`
|
||||
Name string `yaml:"name"`
|
||||
MountPath string `yaml:"mountPath"`
|
||||
Storage *resources.StorageResource `yaml:"-"`
|
||||
IsReparted bool `yaml:"-"`
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
@@ -98,17 +100,18 @@ type InOut struct {
|
||||
}
|
||||
|
||||
type Template struct {
|
||||
Name string `yaml:"name"`
|
||||
Inputs InOut `yaml:"inputs,omitempty"`
|
||||
Outputs InOut `yaml:"outputs,omitempty"`
|
||||
Container Container `yaml:"container,omitempty"`
|
||||
Dag *Dag `yaml:"dag,omitempty"`
|
||||
Metadata TemplateMetadata `yaml:"metadata,omitempty"`
|
||||
Resource ServiceResource `yaml:"resource,omitempty"`
|
||||
Name string `yaml:"name"`
|
||||
Inputs InOut `yaml:"inputs,omitempty"`
|
||||
Outputs InOut `yaml:"outputs,omitempty"`
|
||||
Container Container `yaml:"container,omitempty"`
|
||||
Dag *Dag `yaml:"dag,omitempty"`
|
||||
Metadata TemplateMetadata `yaml:"metadata,omitempty"`
|
||||
Resource ServiceResource `yaml:"resource,omitempty"`
|
||||
NodeSelector map[string]string `yaml:"nodeSelector,omitempty"`
|
||||
}
|
||||
|
||||
func (template *Template) CreateEventContainer(execution *workflow_execution.WorkflowExecution, nt *resources.NativeTool, dag *Dag) {
|
||||
container := Container{Image: "natsio/nats-box"}
|
||||
container := Container{Image: "natsio/nats-box", ImagePullPolicy: "IfNotPresent"}
|
||||
container.Command = []string{"sh", "-c"} // all is bash
|
||||
|
||||
var event native_tools.WorkflowEventParams
|
||||
@@ -136,7 +139,7 @@ func (template *Template) CreateEventContainer(execution *workflow_execution.Wor
|
||||
cmd := exec.Command(
|
||||
"nats",
|
||||
"pub",
|
||||
"--server", conf.GetConfig().NatsURL+":4222",
|
||||
"--server", config.GetConfig().NATSUrl+":4222",
|
||||
tools.WORKFLOW_EVENT.GenerateKey(),
|
||||
string(payload),
|
||||
)
|
||||
@@ -159,7 +162,7 @@ func (template *Template) CreateContainer(exec *workflow_execution.WorkflowExecu
|
||||
return
|
||||
}
|
||||
inst := instance.(*resources.ProcessingInstance)
|
||||
container := Container{Image: inst.Access.Container.Image}
|
||||
container := Container{Image: inst.Access.Container.Image, ImagePullPolicy: "IfNotPresent"}
|
||||
if container.Image == "" {
|
||||
return
|
||||
}
|
||||
@@ -198,12 +201,20 @@ func (template *Template) ReplacePerEnv(arg string, envs []models.Param) string
|
||||
return arg
|
||||
}
|
||||
|
||||
// Add the metadata that allow Admiralty to pick up an Argo Workflow that needs to be reparted
|
||||
// The value of "clustername" is the peerId, which must be replaced by the node name's for this specific execution
|
||||
// AddAdmiraltyAnnotations marque le template pour qu'Admiralty route le pod
|
||||
// vers le cluster virtuel correspondant au peerId.
|
||||
//
|
||||
// - elect: "" déclenche le webhook Admiralty sur le pod créé par Argo.
|
||||
// - nodeSelector cible le virtual node Admiralty dont le label
|
||||
// multicluster.admiralty.io/cluster-name vaut peerId,
|
||||
// ce qui contraint le scheduling au cluster distant.
|
||||
func (t *Template) AddAdmiraltyAnnotations(peerId string) {
|
||||
if t.Metadata.Annotations == nil {
|
||||
t.Metadata.Annotations = make(map[string]string)
|
||||
}
|
||||
t.Metadata.Annotations["multicluster.admiralty.io/elect"] = ""
|
||||
t.Metadata.Annotations["multicluster.admiralty.io/clustername"] = peerId
|
||||
if t.NodeSelector == nil {
|
||||
t.NodeSelector = make(map[string]string)
|
||||
}
|
||||
t.NodeSelector["multicluster.admiralty.io/cluster-name"] = peerId
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ package models
|
||||
|
||||
type VolumeClaimTemplate struct {
|
||||
Metadata struct {
|
||||
Name string `yaml:"name"`
|
||||
Name string `yaml:"name"`
|
||||
Annotations map[string]string `yaml:"annotations,omitempty"`
|
||||
} `yaml:"metadata"`
|
||||
Spec VolumeSpec `yaml:"spec"`
|
||||
}
|
||||
@@ -15,3 +16,12 @@ type VolumeSpec struct {
|
||||
} `yaml:"requests"`
|
||||
} `yaml:"resources"`
|
||||
}
|
||||
|
||||
// ExistingVolume references a pre-provisioned PVC (created by oc-datacenter).
|
||||
// Used in Workflow.Spec.ExistingVolumes (yaml: "volumes") instead of volumeClaimTemplates.
|
||||
type ExistingVolume struct {
|
||||
Name string `yaml:"name"`
|
||||
PersistentVolumeClaim struct {
|
||||
ClaimName string `yaml:"claimName"`
|
||||
} `yaml:"persistentVolumeClaim"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user