You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm migrating some code that was written using https://github.com/spotify/docker-client over to docker-java. I've found a part of the Docker API that was supported in the spotify client but I can't see a way to use it in docker-java: when creating a service I want to be able to define GenericResources (NamedResourceSpec or DiscreteResourceSpec) in ServiceSpec.TaskTemplate.Resources.Reservations.
Using the spotify client, this is the type of thing I could do
finalMap<String, String> genericResources; // Assume this is defined somewherefinalList<ResourceSpec> resourceSpecs = genericResources.entrySet().stream()
.map(entry -> StringUtils.isNumeric(entry.getValue()) ?
ResourceSpec.DiscreteResourceSpec.builder().kind(entry.getKey()).value(Integer.parseInt(entry.getValue())).build() :
ResourceSpec.NamedResourceSpec.builder().kind(entry.getKey()).value(entry.getValue()).build())
.collect(Collectors.toList());
finalResourceRequirementsresourceRequirements =
ResourceRequirements.builder()
.reservations(Reservations.builder()
.resources(resourceSpecs)
.build())
.build();
finalTaskSpectaskSpec = TaskSpec.builder()
.resources(resourceRequirements)
.build();
finalServiceSpecserviceSpec = ServiceSpec.builder()
.taskTemplate(taskSpec)
.build();
// then pass this to the client to create a service
In the docker-java client I can do similar things, but I can't see a way to pass generic resources to the task spec.
newTaskSpec().withResources(
newResourceRequirements().withReservations(
newResourceSpecs().with...? // There is nothing here that takes generic resources
)
);
I do see abstract class GenericResource<T> and its concrete implementations NamedResourceSpec and DiscreteResourceSpec in com.github.dockerjava.api.model. But it looks to me like those are only used to deserialize Task responses received from the API, not used to create new services in a TaskSpec.
Also NamedResourceSpec and DiscreteResourceSpec are both marked @Deprecated but I can't understand why. That annotation was added to those classes in #1635 but I can't see it mentioned in any of the commits or the discussion.
Is there some reason this isn't supported? It is part of the docker API and has been for quite some time. Alternatively, is there a workaround I could do to inject these generic resource specs directly into the API calls before they are sent? (I'm still getting used to the new(-to-me) way of working with docker-java, so I don't know what low-level tricks I can pull.)
The text was updated successfully, but these errors were encountered:
I'm migrating some code that was written using https://github.com/spotify/docker-client over to docker-java. I've found a part of the Docker API that was supported in the spotify client but I can't see a way to use it in docker-java: when creating a service I want to be able to define
GenericResource
s (NamedResourceSpec
orDiscreteResourceSpec
) inServiceSpec.TaskTemplate.Resources.Reservations
.Using the spotify client, this is the type of thing I could do
In the docker-java client I can do similar things, but I can't see a way to pass generic resources to the task spec.
I do see
abstract class GenericResource<T>
and its concrete implementationsNamedResourceSpec
andDiscreteResourceSpec
incom.github.dockerjava.api.model
. But it looks to me like those are only used to deserializeTask
responses received from the API, not used to create new services in aTaskSpec
.Also
NamedResourceSpec
andDiscreteResourceSpec
are both marked@Deprecated
but I can't understand why. That annotation was added to those classes in #1635 but I can't see it mentioned in any of the commits or the discussion.Is there some reason this isn't supported? It is part of the docker API and has been for quite some time. Alternatively, is there a workaround I could do to inject these generic resource specs directly into the API calls before they are sent? (I'm still getting used to the new(-to-me) way of working with docker-java, so I don't know what low-level tricks I can pull.)
The text was updated successfully, but these errors were encountered: