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
verbose info is missing for partial overlay ID #35989
Conversation
@dani-docker can you add a simple test to avoid that this api will end up broken again? |
This part of the code has really become way too complex; we should have a look at rewriting/refactoring |
nwk = nwv | ||
} else if nwv, ok := listByFullName[nwk.ID]; ok { | ||
nwk = nwv | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to simplify these two conditions? The statements in these blocks are identical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thoughts, I think this code is fine.
7cb1c9e
to
e907c52
Compare
@fcrisciani integration test is added.
btw, the swarm/service part is code copied from the service integration test. |
@dani-docker there is an import issue |
e907c52
to
c2c73c2
Compare
@fcrisciani |
@@ -164,6 +164,13 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r | |||
// return the network. Skipped using isMatchingScope because it is true if the scope | |||
// is not set which would be case if the client API v1.30 | |||
if strings.HasPrefix(nwk.ID, term) || (netconst.SwarmScope == scope) { | |||
//If we have a previous match "backend", return it, we need verbose when enabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit, can you put a space after the // of the comment?
applies to both lines and also the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, PR updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small code style nits, rest LGTM
Signed-off-by: Dani Louca <dani.louca@docker.com>
c2c73c2
to
2e0990f
Compare
comment format adjusted and PR updated |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Signed-off-by: Dani Louca dani.louca@docker.com
The changes in 34302 ignores the network details already collected in the previous
backend
block and causesdocker network inspect -v <overlay_partial_ID
to miss the "extra details" provided by the verbose flag.The same issue exists with the network inspect API when querying a network overlay
name
andswarm
scope, ex:curl --unix-socket /var/run/docker.sock "http:/v1.30/networks/<overlay_name>?verbose=true&scope=swarm"
Steps To Reproduce:
docker network create -d overlay apps
docker service create --mode global --name runev --network apps alpine watch date
docker network ls -f driver=overlay -f name=apps -q
docker network inspect -v 6yiu2vo3obja
Expected Results:
return all the extra info provided by the verbose flag, including endpoints, services etc...
Actual Results:
verbose information is missing
Same behavior applies to:
curl --unix-socket /var/run/docker.sock "http:/v1.30/networks/apps?verbose=true&scope=swarm"
Fix:
The fix does not alter the behavior added in 34302, it checks if the networkID returned by
n.cluster.GetNetwork(term)
has an entry inlistByPartialID
orlistByFullName
and returns it, otherwise it returns the basic network detail.