Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.github.dockerjava.api.model.ContainerConfig;
import com.github.dockerjava.api.model.HostConfig;
import com.github.dockerjava.api.model.NetworkSettings;
import com.github.dockerjava.api.model.Node;
import com.github.dockerjava.api.model.Volume;
import com.github.dockerjava.api.model.VolumeBind;
import com.github.dockerjava.api.model.VolumeBinds;
Expand Down Expand Up @@ -98,6 +99,9 @@ public class InspectContainerResponse {
@JsonProperty("Mounts")
private List<Mount> mounts;

@JsonProperty("Node")
private Node node;

public String getId() {
return id;
}
Expand Down Expand Up @@ -202,6 +206,10 @@ public String toString() {
return ToStringBuilder.reflectionToString(this);
}

public Node getNode() {
return node;
}

@JsonIgnoreProperties(ignoreUnknown = true)
public class ContainerState {

Expand Down
67 changes: 67 additions & 0 deletions src/main/java/com/github/dockerjava/api/model/Labels.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.github.dockerjava.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Labels {

@JsonProperty("executiondriver")
private String executiondriver;

@JsonProperty("kernelversion")
private String kernelversion;

@JsonProperty("operatingsystem")
private String operatingsystem;

@JsonProperty("provider")
private String provider;

@JsonProperty("storagedriver")
private String storagedriver;

public String getExecutiondriver() {
return executiondriver;
}

public void setExecutiondriver(String executiondriver) {
this.executiondriver = executiondriver;
}

public String getKernelversion() {
return kernelversion;
}

public void setKernelversion(String kernelversion) {
this.kernelversion = kernelversion;
}

public String getOperatingsystem() {
return operatingsystem;
}

public void setOperatingsystem(String operatingsystem) {
this.operatingsystem = operatingsystem;
}

public String getProvider() {
return provider;
}

public void setProvider(String provider) {
this.provider = provider;
}

public String getStoragedriver() {
return storagedriver;
}

public void setStoragedriver(String storagedriver) {
this.storagedriver = storagedriver;
}

}
20 changes: 18 additions & 2 deletions src/main/java/com/github/dockerjava/api/model/Node.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.dockerjava.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand All @@ -8,20 +9,30 @@
* A node as returned by the /events API, for instance, when Swarm is used.
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Node {

@JsonProperty("Name")
private String name;

@JsonProperty("Id")
@JsonProperty("ID")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That would break backward compatibility if this field was right and contains data for docker API before.

@suryagaddipati suryagaddipati Jun 20, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So Looks like Node is currently being used in Event response.

But I can't seem to find where event response sends a node. I looked at 1.23 and 1.18 none of those events have Node.

I am confused 1. why its there 2. what kind of backward compatibility this would be breaking.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It may happen that different calls has different internals in the same Node object, then it should be splitted.
If Id exists in docker api, then you can't just remove it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@suryagaddipati A node as returned by the /events API, for instance, when Swarm is used.
then it may be that swarm changed API. You should try get responces from 2 different swarm versions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Swarm Node always had the same api response, there is no difference between versions.

Can you link me to where swarm node api changed? I can't seem to find it, perhaps I missed it.

@KostyaSha KostyaSha Jun 20, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

https://docs.docker.com/swarm/swarm-api/

"Node": {
    "Id": "ODAI:IC6Q:MSBL:TPB5:HIEE:6IKC:VCAM:QRNH:PRGX:ERZT:OK46:PMFX",
    "Ip": "0.0.0.0",

Smells like Node is reused... will verify and think on creating ITs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hi @KostyaSha those docs seem out of date

https://github.com/docker/swarm/blob/master/scheduler/node/node.go#L11-L12

the case did indeed seems to have been changed by this commit, like you suspected.

probably a good idea to change Node class to have both fields and return the one that is not null. what do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@KostyaSha i created an issue on docker swarm docker-archive/classicswarm#2378
to clarify the breaking changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like they fixed docs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So i would suggest to make new SwarmNode class as it seems that it fully other Node objects and current docker Node class shouldn't be changed.

private String id;

@JsonProperty("Addr")
private String addr;

@JsonProperty("Ip")
@JsonProperty("IP")
private String ip;

@JsonProperty("Cpus")
private String cpus;

@JsonProperty("Memory")
private String memory;

@JsonProperty("Labels")
private Labels labels;

public String getName() {
return name;
}
Expand All @@ -37,4 +48,9 @@ public String getAddr() {
public String getIp() {
return ip;
}

public Labels getLabels() {
return labels;
}

}