Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add maximum replicas per node support to stack version 3.8 #1410

Merged
merged 2 commits into from
Feb 20, 2019

Conversation

olljanat
Copy link
Contributor

@olljanat olljanat commented Oct 2, 2018

- What I did
Added support for maximum replicas per node to docker stack deploy

Fourth step to be able solve:

- How I did it
Added new schema 3.8 version including max_replicas_per_node setting

- How to verify it

Use stack like this:

version: "3.8"
services:
  test:
    image: nginx
    networks:
      - test
    deploy:
      mode: replicated
      replicas: 2
      placement:
        max_replicas_per_node: 1

networks:
  test:
    driver: overlay

NOTE! Max replicas value from stack file does not work yet. More details in below.

- Description for the changelog

TODO:

@codecov-io
Copy link

codecov-io commented Oct 18, 2018

Codecov Report

Merging #1410 into master will decrease coverage by 0.79%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master    #1410     +/-   ##
=========================================
- Coverage   56.12%   55.32%   -0.8%     
=========================================
  Files         306      283     -23     
  Lines       20964    19331   -1633     
=========================================
- Hits        11766    10695   -1071     
+ Misses       8345     7939    -406     
+ Partials      853      697    -156

@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "replicas-max-per-node" [email protected]:olljanat/cli.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842354053072
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

@olljanat
Copy link
Contributor Author

olljanat commented Jan 4, 2019

@vdemeester @thaJeztah Rebased to latest state of master. I think that it would be nice to have first review round and I really would have use to good ideas why max replicas value is not read from stack file.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comment, but I'll have to dig into the compose issue as well

ping @vdemeester any clues?

docs/reference/commandline/service_create.md Outdated Show resolved Hide resolved
cli/compose/convert/service.go Show resolved Hide resolved
@thaJeztah
Copy link
Member

Oh, sorry, I probably didn't describe #1410 (comment) properly ☺️ 😓 😅

What I meant is; include the new schema in this PR, but split it in two; similar to;

  1. 787e30d (adding the new schema, which is a copy of the previous version with only the version changed)
  2. followed by 47cf2ea (which adds the new feature/field to the schema)

Both of the above are part of the same PR (#426), but having 2. separate makes it a) easier to review what exactly changed in the schema, and b) allows finding the PR that added the new feature (using "git blame")

@olljanat olljanat force-pushed the replicas-max-per-node branch 2 times, most recently from 36da368 to 5d3b3fe Compare January 10, 2019 20:40
@olljanat
Copy link
Contributor Author

@thaJeztah ahaa. No worries. Updated 😉

Signed-off-by: Olli Janatuinen <[email protected]>
@olljanat olljanat changed the title WIP: Added support for maximum replicas per node WIP: Add maximum replicas per node support to stack version 3.8 Jan 14, 2019
@olljanat olljanat changed the title WIP: Add maximum replicas per node support to stack version 3.8 Add maximum replicas per node support to stack version 3.8 Feb 19, 2019
@olljanat
Copy link
Contributor Author

Now this works correctly.
@silvin-lubecki @thaJeztah PTAL

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you @olljanat and sorry for the delay!

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

did a quick check if the latest schema changes in the 3.7 schema (#1657) were copied to the 3.8 format, and all looks well;

--- cli/compose/schema/data/config_schema_v3.7.json	2019-02-20 13:09:49.000000000 +0100
+++ cli/compose/schema/data/config_schema_v3.8.json	2019-02-20 13:09:49.000000000 +0100
@@ -1,6 +1,6 @@
 {
   "$schema": "http://json-schema.org/draft-04/schema#",
-  "id": "config_schema_v3.7.json",
+  "id": "config_schema_v3.8.json",
   "type": "object",
   "required": ["version"],
 
@@ -424,7 +424,8 @@
                 },
                 "additionalProperties": false
               }
-            }
+            },
+            "max_replicas_per_node": {"type": "integer"}
           },
           "additionalProperties": false
         }

@thaJeztah thaJeztah merged commit cfe12f4 into docker:master Feb 20, 2019
@GordonTheTurtle GordonTheTurtle added this to the 19.03.0 milestone Feb 20, 2019
@thaJeztah
Copy link
Member

So what's remaining after this;

@zcaudate
Copy link

Which version of docker should I be using to have this supported?

Currently I'm using the following version but it's not working for me

Version:           19.03.8
API version:       1.40
Docker Compose:  1.25.5

@olljanat
Copy link
Contributor Author

@zcaudate because you are listing docker compose version here it sounds that you are understood something wrong. This feature works only with docker stack deploy command on Swarm mode. Not with docker-compose.

@zcaudate
Copy link

zcaudate commented May 25, 2020 via email

@olljanat
Copy link
Contributor Author

@zcaudate Yea syntax which stack deploy uses have is based docker-compose but those works differently (for example docker-compose totally ignores deploy section from file).. However, if you do not get it working then please create new issue to https://github.com/moby/moby/issues with all asked details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants