Docker.DotNet icon indicating copy to clipboard operation
Docker.DotNet copied to clipboard

What is the correct usage of client.Swarm.ListServicesAsync's parameters

Open ahmadidev opened this issue 5 years ago • 7 comments

What is the correct usage of client.Swarm.ListServicesAsync's parameters? The following code doesn't work. It's the same as this test code.

Output of dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.302
 Commit:    41faccf259

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.302/

Host (useful for support):
  Version: 3.1.6
  Commit:  3acd9b0cd1

.NET Core SDKs installed:
  3.1.302 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

What version of Docker.DotNet?:

3.125.4

Steps to reproduce the issue:

var client = new DockerClientConfiguration(new Uri("unix:///var/run/docker.sock")).CreateClient();
var parameters = new ServicesListParameters
{
    Filters = new ServiceFilter
    {
        Id = "7lvmyvtec0hk2133xumjuyjxq"
    }
};

//Throws exception
var r = await client.Swarm.ListServicesAsync(parameters);

What actually happened?: Throws this exception:

Docker API responded with status code=BadRequest, response={\"message\":\"json: cannot unmarshal string into Go value of type map[string]bool\"}

What did you expect to happen?: List of services, according to filters.

ahmadidev avatar Aug 13 '20 10:08 ahmadidev

Any ideas? I have the same issue

ilnardinio avatar Nov 30 '20 11:11 ilnardinio

https://github.com/docker/swarmkit/blob/ef128ab4f5d50ffe4851d937b2b296e55562d10f/api/control.proto#L393 looks like this is now supposed to be an array but we are treating it as a single string value in the dictionary https://github.com/dotnet/Docker.DotNet/blob/b13f78e6d037e474d63e89e1fc25ddf1220c85a8/src/Docker.DotNet/Models/ServiceFilter.cs#L7

jterry75 avatar Nov 30 '20 18:11 jterry75

Want to take a shot at submitting a fix here? We could just add an overload of properties that deal with List get/set and the current ones can just create an List with one entry and assign it. So no breaking changes

jterry75 avatar Nov 30 '20 18:11 jterry75

Any plans on fixing this issue?

I can use Linq when I get services, but direct filtering on Docker side would be better..

MedoDome avatar Jul 27 '21 08:07 MedoDome

filtering on the Docker side would be great. any progress on this subject?

malanoga avatar Jul 27 '21 09:07 malanoga

Want to take a shot at submitting a fix here? We could just add an overload of properties that deal with List get/set and the current ones can just create an List with one entry and assign it. So no breaking changes

@jterry75 , any movements here?

pedbih avatar Jul 29 '21 11:07 pedbih

any updates?

dazinator avatar Mar 26 '24 21:03 dazinator