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

Fix service filtering by name on Kubernetes #1101

Merged
merged 1 commit into from
Jun 1, 2018

Conversation

silvin-lubecki
Copy link
Contributor

- What I did
Fix #1092 by filtering services by name but client side.

- How to verify it

# Deploy a stack with multiple services
$ docker stack deploy mystack -c docker-compose.yml --orchestrator=kubernetes

# Docker service matches exact name
$ docker stack service mystack --filter name=my-service --orchestrator=kubernetes
ID                  NAME                   MODE                REPLICAS            IMAGE                 PORTS
af5e0438-634        mystack_my-service     replicated          0/1                 docker-teaches-code   *:8080->8080/tcp

# But also prefix
$ docker stack service mystack --filter name=my-se --orchestrator=kubernetes
ID                  NAME                   MODE                REPLICAS            IMAGE                 PORTS
af5e0438-634        mystack_my-service     replicated          0/1                 docker-teaches-code   *:8080->8080/tcp

- Description for the changelog
Fix #1092 filtering stack service name by prefix

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

@@ -140,3 +133,27 @@ func RunServices(dockerCli *KubeCli, opts options.Services) error {
}
return formatter.ServiceListWrite(servicesCtx, services, info)
}

func filterServicesByName(services []swarm.Service, f filters.Args, stackName string) []swarm.Service {
names := f.Get("name")
Copy link
Member

Choose a reason for hiding this comment

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

Would it be clearer to pass names []string as argument instead of the filter-set?

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.

SGTM with @thaJeztah's comment taken care of :)

*  Kubernetes native filtering (server side) is an exact match, now filtering on name is made client-side to add prefix-matching

Signed-off-by: Silvin Lubecki <[email protected]>
@silvin-lubecki
Copy link
Contributor Author

PTAL

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

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 🐯

@vdemeester vdemeester merged commit 7db15a4 into docker:master Jun 1, 2018
@GordonTheTurtle GordonTheTurtle added this to the 18.06.0 milestone Jun 1, 2018
@silvin-lubecki silvin-lubecki deleted the filter-stack-service branch June 1, 2018 14:01
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.

Filtering on stack service name with Kubernetes should match prefix
5 participants