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 warnings client side before deployment on Kubernetes #903

Merged
merged 1 commit into from
Apr 30, 2018

Conversation

silvin-lubecki
Copy link
Contributor

- What I did
I added a bunch of warnings for all the compose features unsupported by the Kubernetes Stack API. They are printed on stderr like this:

> $ docker stack deploy -c docker-compose.yml mystack
top-level network "postgres_conn" is ignored
service postgres: network "postgres_conn" is ignored
service postgres: env_file are ignored
service import-osmborder: network "postgres_conn" is ignored
service import-osmborder: env_file are ignored
service import-osm: network "postgres_conn" is ignored
service import-osm: env_file are ignored
service import-osm-diff: network "postgres_conn" is ignored
service import-osm-diff: env_file are ignored
service update-osm: network "postgres_conn" is ignored
service update-osm: env_file are ignored
service openmaptiles-tools: network "postgres_conn" is ignored
service openmaptiles-tools: env_file are ignored
service import-lakelines: network "postgres_conn" is ignored
service import-lakelines: env_file are ignored
service import-sql: network "postgres_conn" is ignored
service import-sql: env_file are ignored
service generate-changed-vectortiles: network "postgres_conn" is ignored
service generate-changed-vectortiles: env_file are ignored
service postserve: network "postgres_conn" is ignored
service postserve: env_file are ignored
service mapbox-studio: network "postgres_conn" is ignored
service import-wikidata: network "postgres_conn" is ignored
service import-wikidata: env_file are ignored
service generate-vectortiles: network "postgres_conn" is ignored
service generate-vectortiles: env_file are ignored
service import-water: network "postgres_conn" is ignored
service import-water: env_file are ignored
service import-natural-earth: network "postgres_conn" is ignored
service import-natural-earth: env_file are ignored
Waiting for the stack to be stable and running...

⚠️ Depends on #899 ⚠️

- How I did it
Once the compose file is parsed, I iterate on all services to detect the unsupported features (which are filled) and print a warning on each.

- How to verify it
Find a compose file with some networks and deploy it. Some warnings should be printed on stderr.

- Description for the changelog
Print warnings on stderr for each unsupported features while parsing a compose file for deployment on Kubernetes.

- A picture of a cute animal (not mandatory but encouraged)
image

@codecov-io
Copy link

codecov-io commented Feb 26, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@7ad3036). Click here to learn what that means.
The diff coverage is 36.77%.

@@            Coverage Diff            @@
##             master     #903   +/-   ##
=========================================
  Coverage          ?   53.37%           
=========================================
  Files             ?      267           
  Lines             ?    16975           
  Branches          ?        0           
=========================================
  Hits              ?     9060           
  Misses            ?     7322           
  Partials          ?      593

Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

One nit, otherwise, one question : why doing that on its own instead of doing it while converting the types.Config to the stack struct ?

"github.com/docker/cli/cli/compose/loader"
composetypes "github.com/docker/cli/cli/compose/types"
yaml "gopkg.in/yaml.v2"
)

func loadStack(name string, cfg composetypes.Config) (stack, error) {
func loadStack(stderr io.Writer, name string, cfg *composetypes.Config) (stack, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: any reason for having stderr as first argument ? 😝

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@silvin-lubecki silvin-lubecki force-pushed the add-warnings-client-side branch from ccd068d to 897717d Compare February 27, 2018 15:44
@silvin-lubecki
Copy link
Contributor Author

There are two reasons why I separated it. First one is for separation of concerns, as it's not a little 5 lines function. Second one is that if you put the warning code in the conversion code, then you may get warnings while you are retrieving some stacks, during a docker stack ls for example. I think we only want warnings on stacks you are deploying.

var buf bytes.Buffer
warnUnsupportedFeatures(&buf, config)
warnings := buf.String()
assert.Contains(t, warnings, `top-level network "global" is ignored`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this use a golden.Assert() for all the warnings, or is it possible for the order to change? Maybe we could sort the output if the order changes?

@silvin-lubecki silvin-lubecki force-pushed the add-warnings-client-side branch from 897717d to fd995d5 Compare February 28, 2018 23:58
@silvin-lubecki
Copy link
Contributor Author

PTAL

@silvin-lubecki silvin-lubecki force-pushed the add-warnings-client-side branch from fd995d5 to 8023cba Compare March 27, 2018 14:03
This was referenced Mar 27, 2018
Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM on commits that differs from #899

@silvin-lubecki silvin-lubecki force-pushed the add-warnings-client-side branch from 8023cba to 87cce89 Compare March 30, 2018 13:08
@thaJeztah thaJeztah changed the title Add warnings client side before deployment on Kubernetes [WIP] Add warnings client side before deployment on Kubernetes Apr 26, 2018
@thaJeztah
Copy link
Member

Added [WIP] to the PR title until #899 is merged (reviewing that one)

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, but when rebasing can you quash the last two commits?

…a compose file for deployment on Kubernetes.

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
@mat007 mat007 force-pushed the add-warnings-client-side branch from 87cce89 to 36591a2 Compare April 30, 2018 09:56
@mat007
Copy link
Member

mat007 commented Apr 30, 2018

Rebase and squashing done.

@thaJeztah thaJeztah changed the title [WIP] Add warnings client side before deployment on Kubernetes Add warnings client side before deployment on Kubernetes Apr 30, 2018
@thaJeztah
Copy link
Member

Thanks! Still LGTM

@thaJeztah thaJeztah merged commit 8963ab9 into docker:master Apr 30, 2018
@GordonTheTurtle GordonTheTurtle added this to the 18.05.0 milestone Apr 30, 2018
@thaJeztah thaJeztah modified the milestones: 18.05.0, 18.06.0 Apr 30, 2018
@silvin-lubecki silvin-lubecki deleted the add-warnings-client-side branch May 18, 2018 12:27
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.

7 participants