Updated worker nightly to run with latest shared version
This commit is contained in:
@@ -11,7 +11,7 @@ require (
|
|||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.0
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/satori/go.uuid v1.2.0
|
github.com/satori/go.uuid v1.2.0
|
||||||
github.com/shuffle/shuffle-shared v0.5.31
|
github.com/shuffle/shuffle-shared v0.5.53
|
||||||
k8s.io/api v0.28.3
|
k8s.io/api v0.28.3
|
||||||
k8s.io/apimachinery v0.28.3
|
k8s.io/apimachinery v0.28.3
|
||||||
k8s.io/client-go v0.28.3
|
k8s.io/client-go v0.28.3
|
||||||
|
|||||||
@@ -288,6 +288,10 @@ github.com/shuffle/shuffle-shared v0.5.29 h1:n4vThl7v3mFVXbrIW71XREFdmZZo7mOBAWx
|
|||||||
github.com/shuffle/shuffle-shared v0.5.29/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI=
|
github.com/shuffle/shuffle-shared v0.5.29/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI=
|
||||||
github.com/shuffle/shuffle-shared v0.5.31 h1:OV4IIfKWWFW66WjGvyXOmmsSz3p8pW9L1ge1mDo8ftM=
|
github.com/shuffle/shuffle-shared v0.5.31 h1:OV4IIfKWWFW66WjGvyXOmmsSz3p8pW9L1ge1mDo8ftM=
|
||||||
github.com/shuffle/shuffle-shared v0.5.31/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI=
|
github.com/shuffle/shuffle-shared v0.5.31/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI=
|
||||||
|
github.com/shuffle/shuffle-shared v0.5.44 h1:6WiFPIsij+IWvXY7vzVX7cUicb+PYOzhTbWF/gDmYeU=
|
||||||
|
github.com/shuffle/shuffle-shared v0.5.44/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI=
|
||||||
|
github.com/shuffle/shuffle-shared v0.5.53 h1:Osr5sjr0wppqlf/MjH1oykdcw/Q48d8+ZnerRrYfOA4=
|
||||||
|
github.com/shuffle/shuffle-shared v0.5.53/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI=
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
|
|||||||
@@ -354,7 +354,8 @@ func shutdown(workflowExecution shuffle.WorkflowExecution, nodeId string, reason
|
|||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
|
|
||||||
//log.Printf("[DEBUG][%s] All App Logs: %#v", workflowExecution.ExecutionId, allLogs)
|
//log.Printf("[DEBUG][%s] All App Logs: %#v", workflowExecution.ExecutionId, allLogs)
|
||||||
newresp, err := topClient.Do(req)
|
client := shuffle.GetExternalClient(abortUrl)
|
||||||
|
newresp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[WARNING][%s] Failed abort request: %s", workflowExecution.ExecutionId, err)
|
log.Printf("[WARNING][%s] Failed abort request: %s", workflowExecution.ExecutionId, err)
|
||||||
} else {
|
} else {
|
||||||
@@ -464,6 +465,9 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
|
|||||||
// Check action if subflow
|
// Check action if subflow
|
||||||
// Check if url is default (shuffle-backend)
|
// Check if url is default (shuffle-backend)
|
||||||
// If it doesn't exist, add it
|
// If it doesn't exist, add it
|
||||||
|
|
||||||
|
// FIXME: This does NOT replace it in all cases as the data
|
||||||
|
// is not saved in the database as the correct param.
|
||||||
if action.AppName == "shuffle-subflow" {
|
if action.AppName == "shuffle-subflow" {
|
||||||
// Automatic replacement of URL
|
// Automatic replacement of URL
|
||||||
for paramIndex, param := range action.Parameters {
|
for paramIndex, param := range action.Parameters {
|
||||||
@@ -471,17 +475,19 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(param.Value, "shuffle-backend") {
|
if !strings.Contains(param.Value, "shuffle-backend") {
|
||||||
// Automatic replacement as this is default
|
continue
|
||||||
if len(os.Getenv("BASE_URL")) > 0 {
|
}
|
||||||
action.Parameters[paramIndex].Value = os.Getenv("BASE_URL")
|
|
||||||
log.Printf("[DEBUG][%s] Replaced backend_url with base_url %s", workflowExecution.ExecutionId, os.Getenv("BASE_URL"))
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(os.Getenv("SHUFFLE_CLOUDRUN_URL")) > 0 {
|
// Automatic replacement as this is default
|
||||||
action.Parameters[paramIndex].Value = os.Getenv("SHUFFLE_CLOUDRUN_URL")
|
if len(os.Getenv("BASE_URL")) > 0 {
|
||||||
log.Printf("[DEBUG][%s] Replaced backend_url with cloudrun %s", workflowExecution.ExecutionId, os.Getenv("SHUFFLE_CLOUDRUN_URL"))
|
action.Parameters[paramIndex].Value = os.Getenv("BASE_URL")
|
||||||
}
|
log.Printf("[DEBUG][%s] Replaced backend_url with base_url %s", workflowExecution.ExecutionId, os.Getenv("BASE_URL"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(os.Getenv("SHUFFLE_CLOUDRUN_URL")) > 0 {
|
||||||
|
action.Parameters[paramIndex].Value = os.Getenv("SHUFFLE_CLOUDRUN_URL")
|
||||||
|
log.Printf("[DEBUG][%s] Replaced backend_url with cloudrun %s", workflowExecution.ExecutionId, os.Getenv("SHUFFLE_CLOUDRUN_URL"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -745,6 +751,8 @@ func removeContainer(containername string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer cli.Close()
|
||||||
|
|
||||||
// FIXME - ucnomment
|
// FIXME - ucnomment
|
||||||
// containers, err := cli.ContainerList(ctx, types.ContainerListOptions{
|
// containers, err := cli.ContainerList(ctx, types.ContainerListOptions{
|
||||||
// All: true,
|
// All: true,
|
||||||
@@ -800,6 +808,8 @@ func getWorkerURLs() ([]string, error) {
|
|||||||
return workerUrls, err
|
return workerUrls, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer cli.Close()
|
||||||
|
|
||||||
// Specify the name of the service for which you want to list tasks
|
// Specify the name of the service for which you want to list tasks
|
||||||
serviceName := "shuffle-workers"
|
serviceName := "shuffle-workers"
|
||||||
|
|
||||||
@@ -827,12 +837,19 @@ func askOtherWorkersToDownloadImage(image string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check environment SHUFFLE_AUTO_IMAGE_DOWNLOAD
|
||||||
|
if os.Getenv("SHUFFLE_AUTO_IMAGE_DOWNLOAD") == "false" {
|
||||||
|
log.Printf("[DEBUG] SHUFFLE_AUTO_IMAGE_DOWNLOAD is false. NOT distributing images %s", image)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
urls, err := getWorkerURLs()
|
urls, err := getWorkerURLs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Error in listing worker urls: %s", err)
|
log.Printf("[ERROR] Error in listing worker urls: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
httpClient := &http.Client{}
|
||||||
for _, url := range urls {
|
for _, url := range urls {
|
||||||
log.Printf("[DEBUG] Trying to speak to: %s", url)
|
log.Printf("[DEBUG] Trying to speak to: %s", url)
|
||||||
imagesRequest := ImageRequest{
|
imagesRequest := ImageRequest{
|
||||||
@@ -855,7 +872,6 @@ func askOtherWorkersToDownloadImage(image string) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
httpClient := &http.Client{}
|
|
||||||
resp, err := httpClient.Do(req)
|
resp, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Error in making request to %s : %s", url, err)
|
log.Printf("[ERROR] Error in making request to %s : %s", url, err)
|
||||||
@@ -892,6 +908,8 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer dockercli.Close()
|
||||||
|
|
||||||
for _, action := range relevantActions {
|
for _, action := range relevantActions {
|
||||||
appname := action.AppName
|
appname := action.AppName
|
||||||
appversion := action.AppVersion
|
appversion := action.AppVersion
|
||||||
@@ -1116,6 +1134,7 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) {
|
|||||||
shutdown(workflowExecution, action.ID, fmt.Sprintf("%s", err.Error()), true)
|
shutdown(workflowExecution, action.ID, fmt.Sprintf("%s", err.Error()), true)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
defer reader.Close()
|
||||||
baseTag := strings.Split(image, ":")
|
baseTag := strings.Split(image, ":")
|
||||||
if len(baseTag) > 1 {
|
if len(baseTag) > 1 {
|
||||||
tag := baseTag[1]
|
tag := baseTag[1]
|
||||||
@@ -1226,6 +1245,7 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) {
|
|||||||
shutdown(workflowExecution, action.ID, fmt.Sprintf("%s", err.Error()), true)
|
shutdown(workflowExecution, action.ID, fmt.Sprintf("%s", err.Error()), true)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
defer reader.Close()
|
||||||
baseTag := strings.Split(image, ":")
|
baseTag := strings.Split(image, ":")
|
||||||
if len(baseTag) > 1 {
|
if len(baseTag) > 1 {
|
||||||
tag := baseTag[1]
|
tag := baseTag[1]
|
||||||
@@ -1494,7 +1514,8 @@ func handleSubflowPoller(ctx context.Context, workflowExecution shuffle.Workflow
|
|||||||
bytes.NewBuffer([]byte(data)),
|
bytes.NewBuffer([]byte(data)),
|
||||||
)
|
)
|
||||||
|
|
||||||
newresp, err := topClient.Do(req)
|
client := shuffle.GetExternalClient(streamResultUrl)
|
||||||
|
newresp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Failed making request (1): %s", err)
|
log.Printf("[ERROR] Failed making request (1): %s", err)
|
||||||
time.Sleep(time.Duration(sleepTime) * time.Second)
|
time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||||
@@ -2101,7 +2122,8 @@ func sendSelfRequest(actionResult shuffle.ActionResult) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
newresp, err := topClient.Do(req)
|
client := shuffle.GetExternalClient(streamUrl)
|
||||||
|
newresp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR][%s] Error running finishing request (2): %s", actionResult.ExecutionId, err)
|
log.Printf("[ERROR][%s] Error running finishing request (2): %s", actionResult.ExecutionId, err)
|
||||||
return
|
return
|
||||||
@@ -2158,9 +2180,10 @@ func sendResult(workflowExecution shuffle.WorkflowExecution, data []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
newresp, err := topClient.Do(req)
|
client := shuffle.GetExternalClient(streamUrl)
|
||||||
|
newresp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR][%s] Error running finishing request: %s", workflowExecution.ExecutionId, err)
|
log.Printf("[ERROR][%s] Error running finishing request (1): %s", workflowExecution.ExecutionId, err)
|
||||||
log.Printf("[DEBUG][%s] Shutting down (23)", workflowExecution.ExecutionId)
|
log.Printf("[DEBUG][%s] Shutting down (23)", workflowExecution.ExecutionId)
|
||||||
shutdown(workflowExecution, "", "", false)
|
shutdown(workflowExecution, "", "", false)
|
||||||
return
|
return
|
||||||
@@ -2348,6 +2371,12 @@ func webserverSetup(workflowExecution shuffle.WorkflowExecution) net.Listener {
|
|||||||
func downloadDockerImageBackend(client *http.Client, imageName string) error {
|
func downloadDockerImageBackend(client *http.Client, imageName string) error {
|
||||||
log.Printf("[DEBUG] Trying to download image %s from backend %s as it doesn't exist. All images: %#v", imageName, baseUrl, downloadedImages)
|
log.Printf("[DEBUG] Trying to download image %s from backend %s as it doesn't exist. All images: %#v", imageName, baseUrl, downloadedImages)
|
||||||
|
|
||||||
|
// Check environment SHUFFLE_AUTO_IMAGE_DOWNLOAD
|
||||||
|
if os.Getenv("SHUFFLE_AUTO_IMAGE_DOWNLOAD") == "false" {
|
||||||
|
log.Printf("[DEBUG] SHUFFLE_AUTO_IMAGE_DOWNLOAD is false. Not downloading image %s", imageName)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if arrayContains(downloadedImages, imageName) {
|
if arrayContains(downloadedImages, imageName) {
|
||||||
log.Printf("[DEBUG] Image %s already downloaded", imageName)
|
log.Printf("[DEBUG] Image %s already downloaded", imageName)
|
||||||
return nil
|
return nil
|
||||||
@@ -2407,12 +2436,15 @@ func downloadDockerImageBackend(client *http.Client, imageName string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer dockercli.Close()
|
||||||
|
|
||||||
imageLoadResponse, err := dockercli.ImageLoad(context.Background(), tar, true)
|
imageLoadResponse, err := dockercli.ImageLoad(context.Background(), tar, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Error loading images: %s", err)
|
log.Printf("[ERROR] Error loading images: %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer imageLoadResponse.Body.Close()
|
||||||
body, err := ioutil.ReadAll(imageLoadResponse.Body)
|
body, err := ioutil.ReadAll(imageLoadResponse.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Error reading: %s", err)
|
log.Printf("[ERROR] Error reading: %s", err)
|
||||||
@@ -2570,9 +2602,11 @@ func sendAppRequest(ctx context.Context, incomingUrl, appName string, port int,
|
|||||||
log.Printf("[DEBUG][%s] Adding %s to cache (%#v)", workflowExecution.ExecutionId, newExecId, action.Name)
|
log.Printf("[DEBUG][%s] Adding %s to cache (%#v)", workflowExecution.ExecutionId, newExecId, action.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Add 5 tries
|
client := shuffle.GetExternalClient(streamUrl)
|
||||||
|
|
||||||
newresp, err := topClient.Do(req)
|
// Set client timeout to 5 seconds
|
||||||
|
client.Timeout = time.Duration(10) * time.Second
|
||||||
|
newresp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Another timeout issue here somewhere
|
// Another timeout issue here somewhere
|
||||||
// context deadline
|
// context deadline
|
||||||
@@ -2630,6 +2664,8 @@ func baseDeploy() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer cli.Close()
|
||||||
|
|
||||||
for key, value := range autoDeploy {
|
for key, value := range autoDeploy {
|
||||||
newNameSplit := strings.Split(key, ":")
|
newNameSplit := strings.Split(key, ":")
|
||||||
|
|
||||||
@@ -2897,7 +2933,6 @@ func main() {
|
|||||||
shutdown(workflowExecution, "", "", true)
|
shutdown(workflowExecution, "", "", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
topClient = client
|
|
||||||
firstRequest := true
|
firstRequest := true
|
||||||
environments := []string{}
|
environments := []string{}
|
||||||
for {
|
for {
|
||||||
@@ -3007,15 +3042,14 @@ func handleRunExecution(resp http.ResponseWriter, request *http.Request) {
|
|||||||
var workflowExecution shuffle.WorkflowExecution
|
var workflowExecution shuffle.WorkflowExecution
|
||||||
data = fmt.Sprintf(`{"execution_id": "%s", "authorization": "%s"}`, execRequest.ExecutionId, execRequest.Authorization)
|
data = fmt.Sprintf(`{"execution_id": "%s", "authorization": "%s"}`, execRequest.ExecutionId, execRequest.Authorization)
|
||||||
streamResultUrl := fmt.Sprintf("%s/api/v1/streams/results", baseUrl)
|
streamResultUrl := fmt.Sprintf("%s/api/v1/streams/results", baseUrl)
|
||||||
topClient = shuffle.GetExternalClient(streamResultUrl)
|
|
||||||
|
|
||||||
req, err := http.NewRequest(
|
req, err := http.NewRequest(
|
||||||
"POST",
|
"POST",
|
||||||
streamResultUrl,
|
streamResultUrl,
|
||||||
bytes.NewBuffer([]byte(data)),
|
bytes.NewBuffer([]byte(data)),
|
||||||
)
|
)
|
||||||
|
|
||||||
newresp, err := topClient.Do(req)
|
client := shuffle.GetExternalClient(streamResultUrl)
|
||||||
|
newresp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Failed making request (2): %s", err)
|
log.Printf("[ERROR] Failed making request (2): %s", err)
|
||||||
resp.WriteHeader(401)
|
resp.WriteHeader(401)
|
||||||
@@ -3145,6 +3179,8 @@ func handleDownloadImage(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer client.Close()
|
||||||
|
|
||||||
// check if images are already downloaded
|
// check if images are already downloaded
|
||||||
// Retrieve a list of Docker images
|
// Retrieve a list of Docker images
|
||||||
images, err := client.ImageList(context.Background(), types.ImageListOptions{})
|
images, err := client.ImageList(context.Background(), types.ImageListOptions{})
|
||||||
@@ -3155,6 +3191,7 @@ func handleDownloadImage(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for _, img := range images {
|
for _, img := range images {
|
||||||
for _, tag := range img.RepoTags {
|
for _, tag := range img.RepoTags {
|
||||||
splitTag := strings.Split(tag, ":")
|
splitTag := strings.Split(tag, ":")
|
||||||
|
|||||||
Reference in New Issue
Block a user