Added fixes towards new worker deployment
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
NAME=shuffle-orborus
|
||||
VERSION=0.9.34
|
||||
VERSION=0.9.35
|
||||
|
||||
echo "Running docker build with $NAME:$VERSION"
|
||||
#docker rmi frikky/shuffle:$NAME --force
|
||||
|
||||
@@ -236,7 +236,6 @@ func deployServiceWorkers(image string) {
|
||||
}
|
||||
|
||||
innerContainerName := fmt.Sprintf("shuffle-workers")
|
||||
parsedConcurrent := uint64(50)
|
||||
|
||||
cnt, _ := findActiveSwarmNodes()
|
||||
nodeCount := uint64(1)
|
||||
@@ -253,6 +252,10 @@ func deployServiceWorkers(image string) {
|
||||
|
||||
log.Printf("[DEBUG] Deploying %d containers for worker with swarm to each node. Service name: %s. Image: %s", replicas, innerContainerName, image)
|
||||
|
||||
if timezone == "" {
|
||||
timezone = "Europe/Amsterdam"
|
||||
}
|
||||
|
||||
// FIXME: May not need ingress ports. Could use internal services and DNS of swarm itself
|
||||
// https://github.com/moby/moby/blob/e2f740de442bac52b280bc485a3ca5b31567d938/api/types/swarm/service.go#L46
|
||||
serviceSpec := swarm.ServiceSpec{
|
||||
@@ -264,9 +267,6 @@ func deployServiceWorkers(image string) {
|
||||
Replicated: &swarm.ReplicatedService{
|
||||
Replicas: &replicatedJobs,
|
||||
},
|
||||
ReplicatedJob: &swarm.ReplicatedJob{
|
||||
MaxConcurrent: &parsedConcurrent,
|
||||
},
|
||||
},
|
||||
Networks: []swarm.NetworkAttachmentConfig{
|
||||
swarm.NetworkAttachmentConfig{
|
||||
@@ -294,6 +294,7 @@ func deployServiceWorkers(image string) {
|
||||
fmt.Sprintf("SHUFFLE_SWARM_CONFIG=%s", os.Getenv("SHUFFLE_SWARM_CONFIG")),
|
||||
fmt.Sprintf("SHUFFLE_SWARM_NETWORK_NAME=%s", networkName),
|
||||
fmt.Sprintf("SHUFFLE_APP_REPLICAS=%d", cnt),
|
||||
fmt.Sprintf("TZ=%s", timezone),
|
||||
},
|
||||
Mounts: []mount.Mount{
|
||||
mount.Mount{
|
||||
@@ -331,7 +332,7 @@ func deployServiceWorkers(image string) {
|
||||
)
|
||||
|
||||
if err == nil {
|
||||
log.Printf("[DEBUG] Successfully deployed workers with %d replica(s)", replicas)
|
||||
log.Printf("[DEBUG] Successfully deployed workers with %d replica(s) on %d nodes", replicas, cnt)
|
||||
//time.Sleep(time.Duration(10) * time.Second)
|
||||
//log.Printf("[DEBUG] Servicecreate request: %#v %#v", service, err)
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
NAME=shuffle-worker
|
||||
VERSION=0.9.34
|
||||
VERSION=0.9.35
|
||||
|
||||
echo "Running docker build with $NAME:$VERSION"
|
||||
#CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o worker.bin .
|
||||
|
||||
@@ -236,14 +236,17 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
|
||||
log.Printf("[INFO] New appname: %s, image: %s", appName, image)
|
||||
|
||||
if !shuffle.ArrayContains(downloadedImages, image) {
|
||||
log.Printf("[DEBUG] Downloading image %s from backend as it's first iteration", image)
|
||||
log.Printf("[DEBUG] Downloading image %s from backend as it's first iteration for this image on the worker.", image)
|
||||
// FIXME: Not caring if it's ok or not. Just continuing
|
||||
// This is working as intended, just designed to download an updated
|
||||
// image on every Orborus/new worker restart.
|
||||
downloadedImages = append(downloadedImages, image)
|
||||
|
||||
// Running as coroutine for eventual completeness
|
||||
go downloadDockerImageBackend(&http.Client{}, image)
|
||||
//go downloadDockerImageBackend(&http.Client{}, image)
|
||||
// FIXME: With goroutines it got too much trouble of deploying with an older version
|
||||
// Allowing slow startups, as long as it's eventually fast, and uses the same registry as on host.
|
||||
downloadDockerImageBackend(&http.Client{}, image)
|
||||
}
|
||||
|
||||
exposedPort, err := findAppInfo(image, appName)
|
||||
@@ -2246,7 +2249,6 @@ func deploySwarmService(dockercli *dockerclient.Client, name, image string, depl
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Deploying app with name %s with image %s", name, image)
|
||||
parsedConcurrent := uint64(50)
|
||||
|
||||
containerName := fmt.Sprintf(strings.Replace(name, ".", "-", -1))
|
||||
serviceSpec := swarm.ServiceSpec{
|
||||
@@ -2259,9 +2261,6 @@ func deploySwarmService(dockercli *dockerclient.Client, name, image string, depl
|
||||
// Max total
|
||||
Replicas: &replicatedJobs,
|
||||
},
|
||||
ReplicatedJob: &swarm.ReplicatedJob{
|
||||
MaxConcurrent: &parsedConcurrent,
|
||||
},
|
||||
},
|
||||
Networks: []swarm.NetworkAttachmentConfig{
|
||||
swarm.NetworkAttachmentConfig{
|
||||
@@ -2317,6 +2316,13 @@ func deploySwarmService(dockercli *dockerclient.Client, name, image string, depl
|
||||
serviceSpec.TaskTemplate.ContainerSpec.Env = append(serviceSpec.TaskTemplate.ContainerSpec.Env, fmt.Sprintf("DOCKER_API_VERSION=%s", dockerApiVersion))
|
||||
}
|
||||
|
||||
// Required for certain apps
|
||||
if timezone == "" {
|
||||
timezone = "Europe/Amsterdam"
|
||||
}
|
||||
|
||||
serviceSpec.TaskTemplate.ContainerSpec.Env = append(serviceSpec.TaskTemplate.ContainerSpec.Env, fmt.Sprintf("TZ=%s", timezone))
|
||||
|
||||
serviceOptions := types.ServiceCreateOptions{}
|
||||
service, err := dockercli.ServiceCreate(
|
||||
context.Background(),
|
||||
|
||||
Reference in New Issue
Block a user