Merge pull request #1747 from yashsinghcodes/main
fixes some of the issue in 2.1.0-rc2
This commit is contained in:
+22
-12
@@ -246,16 +246,16 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This is really the environment's name - NOT org-id
|
// This is really the environment's name - NOT org-id
|
||||||
orgId := request.Header.Get("Org-Id")
|
environment := request.Header.Get("Org-Id")
|
||||||
if len(orgId) == 0 {
|
if len(environment) == 0 {
|
||||||
log.Printf("[AUDIT] No org-id header set")
|
log.Printf("[AUDIT] No org-id header set")
|
||||||
resp.WriteHeader(401)
|
resp.WriteHeader(401)
|
||||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Specify the org-id header."}`)))
|
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Specify the org-id header."}`)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
environment := request.Header.Get("org")
|
orgId := request.Header.Get("org")
|
||||||
if len(environment) == 0 {
|
if len(orgId) == 0 {
|
||||||
//log.Printf("[AUDIT] No 'org' header set (get workflow queue). ")
|
//log.Printf("[AUDIT] No 'org' header set (get workflow queue). ")
|
||||||
/*
|
/*
|
||||||
resp.WriteHeader(403)
|
resp.WriteHeader(403)
|
||||||
@@ -280,9 +280,19 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) {
|
|||||||
//log.Printf("[AUDIT] Get workflow queue for org %s, env %s, orborus label %s", orgId, environment, orborusLabel)
|
//log.Printf("[AUDIT] Get workflow queue for org %s, env %s, orborus label %s", orgId, environment, orborusLabel)
|
||||||
|
|
||||||
ctx := shuffle.GetContext(request)
|
ctx := shuffle.GetContext(request)
|
||||||
env, err := shuffle.GetEnvironment(ctx, orgId, "")
|
// Get all env and check the name?
|
||||||
if err != nil {
|
envs, err := shuffle.GetEnvironments(ctx, orgId)
|
||||||
log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", orgId, err)
|
|
||||||
|
if err != nil || len(envs) == 0 {
|
||||||
|
log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", environment, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var env *shuffle.Environment
|
||||||
|
for _, e := range envs {
|
||||||
|
if e.Name == environment {
|
||||||
|
env = &e
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timeNow := time.Now().Unix()
|
timeNow := time.Now().Unix()
|
||||||
@@ -297,7 +307,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) {
|
|||||||
|
|
||||||
//log.Printf("Found env: %#v", env)
|
//log.Printf("Found env: %#v", env)
|
||||||
if len(env.OrgId) > 0 {
|
if len(env.OrgId) > 0 {
|
||||||
environment = env.OrgId
|
orgId = env.OrgId
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Workflow stats disabled for now
|
// FIXME: Workflow stats disabled for now
|
||||||
@@ -338,7 +348,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) {
|
|||||||
//if int(envData.CPUPercent) > percentageCheck {
|
//if int(envData.CPUPercent) > percentageCheck {
|
||||||
// Get cached data
|
// Get cached data
|
||||||
percentages := []float64{}
|
percentages := []float64{}
|
||||||
cacheKey := fmt.Sprintf("%s_%s_percent", orgId, strings.ToLower(environment))
|
cacheKey := fmt.Sprintf("%s_%s_percent", environment , strings.ToLower(orgId))
|
||||||
|
|
||||||
// Marshal float list into []byte
|
// Marshal float list into []byte
|
||||||
cacheData := []byte{}
|
cacheData := []byte{}
|
||||||
@@ -448,7 +458,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
executionRequests, err := shuffle.GetWorkflowQueue(ctx, orgId, 100)
|
executionRequests, err := shuffle.GetWorkflowQueue(ctx, environment, 100)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Skipping as this comes up over and over
|
// Skipping as this comes up over and over
|
||||||
//log.Printf("(2) Failed reading body for workflowqueue: %s", err)
|
//log.Printf("(2) Failed reading body for workflowqueue: %s", err)
|
||||||
@@ -476,8 +486,8 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(orgId) > 0 {
|
if len(environment) > 0 {
|
||||||
env, err := shuffle.GetEnvironment(ctx, orgId, foundId)
|
env, err := shuffle.GetEnvironment(ctx, foundId, environment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", orgId, err)
|
log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", orgId, err)
|
||||||
//resp.WriteHeader(401)
|
//resp.WriteHeader(401)
|
||||||
|
|||||||
@@ -813,20 +813,20 @@ func handleBackendImageDownload(ctx context.Context, images string) error {
|
|||||||
newImages = append(newImages, curimage)
|
newImages = append(newImages, curimage)
|
||||||
|
|
||||||
// Force remove the current image to avoid cached layers
|
// Force remove the current image to avoid cached layers
|
||||||
if swarmConfig == "run" || swarmConfig == "swarm" {
|
// if swarmConfig == "run" || swarmConfig == "swarm" {
|
||||||
_, err := dockercli.ImageRemove(ctx, curimage, image.RemoveOptions{
|
// _, err := dockercli.ImageRemove(ctx, curimage, image.RemoveOptions{
|
||||||
Force: true,
|
// Force: true,
|
||||||
PruneChildren: true,
|
// PruneChildren: true,
|
||||||
})
|
// })
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Printf("[ERROR] Failed removing image for re-download: %s", err)
|
// log.Printf("[ERROR] Failed removing image for re-download: %s", err)
|
||||||
} else {
|
// } else {
|
||||||
log.Printf("[DEBUG] Removed image: %s", curimage)
|
// log.Printf("[DEBUG] Removed image: %s", curimage)
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
//log.Printf("[DEBUG] Skipping image removal for %s as swarmConfig is not set to run or swarm. Value: %#v", curimage, swarmConfig)
|
// //log.Printf("[DEBUG] Skipping image removal for %s as swarmConfig is not set to run or swarm. Value: %#v", curimage, swarmConfig)
|
||||||
}
|
// }
|
||||||
|
|
||||||
err := shuffle.DownloadDockerImageBackend(&http.Client{Timeout: imagedownloadTimeout}, curimage)
|
err := shuffle.DownloadDockerImageBackend(&http.Client{Timeout: imagedownloadTimeout}, curimage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -874,6 +874,7 @@ func handleBackendImageDownload(ctx context.Context, images string) error {
|
|||||||
// Update the service to run with the new image
|
// Update the service to run with the new image
|
||||||
//docker service update --image username/imagename:latest servicename --force
|
//docker service update --image username/imagename:latest servicename --force
|
||||||
serviceUpdateOptions := types.ServiceUpdateOptions{}
|
serviceUpdateOptions := types.ServiceUpdateOptions{}
|
||||||
|
service.Spec.TaskTemplate.ForceUpdate++
|
||||||
resp, err := dockercli.ServiceUpdate(
|
resp, err := dockercli.ServiceUpdate(
|
||||||
ctx,
|
ctx,
|
||||||
service.ID,
|
service.ID,
|
||||||
|
|||||||
Reference in New Issue
Block a user