this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(controller): more reliable bootstrap flow

Khue Doan 44276326 7401c336

+30 -30
+8 -2
Makefile
··· 3 3 4 4 env ?= local 5 5 6 - default: infra platform 6 + default: infra platform apps 7 7 8 8 compose: 9 9 docker compose up --build --detach ··· 11 11 infra: compose 12 12 # TODO multiple env 13 13 temporal workflow start \ 14 + --workflow-id infra-manual \ 14 15 --task-queue cloudlab \ 15 16 --type Infra \ 16 - --input '{ "url": "https://github.com/khuedoan/cloudlab", "revision": "master", "oldRevision": "790763a8166e306f34559870c60e818505117e6b", "stack": "local" }' 17 + --input '{ "url": "https://github.com/khuedoan/cloudlab", "revision": "master", "stack": "local" }' 18 + temporal workflow result --workflow-id infra-manual 17 19 18 20 platform: 19 21 # TODO multiple env 20 22 temporal workflow start \ 23 + --workflow-id platform-manual \ 21 24 --task-queue cloudlab \ 22 25 --type Platform \ 23 26 --input '{ "url": "https://github.com/khuedoan/cloudlab", "revision": "master", "registry": "registry.127.0.0.1.sslip.io", "cluster": "local" }' 27 + temporal workflow result --workflow-id platform-manual 24 28 25 29 apps: 26 30 # TODO multiple env 27 31 temporal workflow start \ 32 + --workflow-id apps-manual \ 28 33 --task-queue cloudlab \ 29 34 --type Apps \ 30 35 --input '{ "url": "https://github.com/khuedoan/cloudlab", "revision": "master", "registry": "registry.127.0.0.1.sslip.io", "cluster": "local" }' 36 + temporal workflow result --workflow-id apps-manual 31 37 32 38 test: 33 39 cd controller && go test ./...
+8 -9
controller/workflows/apps.go
··· 1 1 package workflows 2 2 3 3 import ( 4 + "os" 4 5 "path/filepath" 5 6 "strings" 6 7 "time" 7 8 8 9 "cloudlab/controller/activities" 9 10 10 - "go.temporal.io/sdk/temporal" 11 11 "go.temporal.io/sdk/workflow" 12 12 ) 13 13 ··· 22 22 logger := workflow.GetLogger(ctx) 23 23 logger.Info("Platform workflow started", "platform", input) 24 24 25 - var repoPath string 25 + var workspace string 26 26 if err := workflow.ExecuteActivity( 27 27 workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ 28 28 StartToCloseTimeout: 1 * time.Minute, 29 - RetryPolicy: &temporal.RetryPolicy{MaximumAttempts: 3}, 30 29 }), 31 30 activities.Clone, 32 31 input.Url, 33 32 input.Revision, 34 - ).Get(ctx, &repoPath); err != nil { 33 + ).Get(ctx, &workspace); err != nil { 35 34 return err 36 35 } 37 36 38 - appsDir := repoPath + "/apps" 37 + defer os.RemoveAll(workspace) 38 + 39 + appsDir := workspace + "/apps" 39 40 40 41 // TODO this should be a separate activity 41 42 var matchedPaths []string 42 43 if err := workflow.ExecuteActivity( 43 44 workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ 44 - StartToCloseTimeout: 1 * time.Minute, 45 - RetryPolicy: &temporal.RetryPolicy{MaximumAttempts: 2}, 45 + StartToCloseTimeout: 10 * time.Second, 46 46 }), 47 47 activities.DiscoverApps, 48 48 appsDir, ··· 51 51 return err 52 52 } 53 53 ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ 54 - StartToCloseTimeout: 5 * time.Minute, 55 - RetryPolicy: &temporal.RetryPolicy{MaximumAttempts: 2}, 54 + StartToCloseTimeout: 1 * time.Minute, 56 55 }) 57 56 58 57 var futures []workflow.Future
+7 -8
controller/workflows/infra.go
··· 2 2 3 3 import ( 4 4 "fmt" 5 + "os" 5 6 "time" 6 7 7 8 "cloudlab/controller/activities" ··· 21 22 logger := workflow.GetLogger(ctx) 22 23 logger.Info("Infra workflow started", "infra", input) 23 24 24 - // Clone activity: 30s timeout, quick retry on worker failure 25 25 cloneCtx := workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ 26 26 StartToCloseTimeout: 1 * time.Minute, 27 - RetryPolicy: &temporal.RetryPolicy{ 28 - MaximumAttempts: 3, 29 - }, 30 27 }) 31 28 32 - var path string 33 - if err := workflow.ExecuteActivity(cloneCtx, activities.Clone, input.Url, input.Revision).Get(ctx, &path); err != nil { 29 + var workspace string 30 + if err := workflow.ExecuteActivity(cloneCtx, activities.Clone, input.Url, input.Revision).Get(ctx, &workspace); err != nil { 34 31 return nil, err 35 32 } 33 + 34 + defer os.RemoveAll(workspace) 36 35 37 36 // Graph and analysis activities: moderate timeout 38 37 analysisCtx := workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ ··· 46 45 var prunedGraph *activities.Graph 47 46 48 47 // Get the terragrunt graph 49 - if err := workflow.ExecuteActivity(analysisCtx, activities.TerragruntGraph, path+"/infra/"+input.Stack).Get(ctx, &graph); err != nil { 48 + if err := workflow.ExecuteActivity(analysisCtx, activities.TerragruntGraph, workspace+"/infra/"+input.Stack).Get(ctx, &graph); err != nil { 50 49 return nil, err 51 50 } 52 51 ··· 57 56 } else { 58 57 // Determine changed modules and prune graph 59 58 var changedModules []string 60 - if err := workflow.ExecuteActivity(analysisCtx, activities.ChangedModules, path, input.OldRevision).Get(ctx, &changedModules); err != nil { 59 + if err := workflow.ExecuteActivity(analysisCtx, activities.ChangedModules, workspace, input.OldRevision).Get(ctx, &changedModules); err != nil { 61 60 return nil, err 62 61 } 63 62
+7 -11
controller/workflows/platform.go
··· 1 1 package workflows 2 2 3 3 import ( 4 + "os" 4 5 "time" 5 6 6 7 "cloudlab/controller/activities" 7 8 8 - "go.temporal.io/sdk/temporal" 9 9 "go.temporal.io/sdk/workflow" 10 10 ) 11 11 ··· 20 20 logger := workflow.GetLogger(ctx) 21 21 logger.Info("Platform workflow started", "platform", input) 22 22 23 - var path string 23 + var workspace string 24 24 if err := workflow.ExecuteActivity( 25 25 workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ 26 26 StartToCloseTimeout: 1 * time.Minute, 27 - RetryPolicy: &temporal.RetryPolicy{ 28 - MaximumAttempts: 3, 29 - }, 30 27 }), 31 28 activities.Clone, 32 29 input.Url, 33 30 input.Revision, 34 - ).Get(ctx, &path); err != nil { 31 + ).Get(ctx, &workspace); err != nil { 35 32 return err 36 33 } 37 34 35 + defer os.RemoveAll(workspace) 36 + 38 37 var pushResult *activities.PushResult 39 38 if err := workflow.ExecuteActivity( 40 39 workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ 41 - StartToCloseTimeout: 5 * time.Minute, 42 - RetryPolicy: &temporal.RetryPolicy{ 43 - MaximumAttempts: 2, 44 - }, 40 + StartToCloseTimeout: 1 * time.Minute, 45 41 }), 46 42 activities.PushManifests, 47 - path+"/platform/"+input.Cluster, 43 + workspace+"/platform/"+input.Cluster, 48 44 input.Registry+"/platform:"+input.Cluster, 49 45 ).Get(ctx, &pushResult); err != nil { 50 46 return err