Add more cases for API versions#2690
Conversation
|
LGTM |
cluster/engine.go
Outdated
| default: | ||
| case versions.LessThan(serverVersion, "1.13.1"): | ||
| e.apiClient.UpdateClientVersion("1.25") | ||
| case versions.LessThan(serverVersion, "17.03.1"): |
There was a problem hiding this comment.
Just one question, if the serverVersion is 17.03.1~ce, what will return from versions.LessThan(serverVersion, "17.03.1")? I think it will return true, am I right? Here is some code from:
// compare compares two version strings
// returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
func compare(v1, v2 string) int {
var (
currTab = strings.Split(v1, ".")
otherTab = strings.Split(v2, ".")
)
max := len(currTab)
if len(otherTab) > max {
max = len(otherTab)
}
for i := 0; i < max; i++ {
var currInt, otherInt int
if len(currTab) > i {
currInt, _ = strconv.Atoi(currTab[i])
}
if len(otherTab) > i {
otherInt, _ = strconv.Atoi(otherTab[i])
}
if currInt > otherInt {
return 1
}
if otherInt > currInt {
return -1
}
}
return 0
}
// LessThan checks if a version is less than another
func LessThan(v, other string) bool {
return compare(v, other) == -1
}
There was a problem hiding this comment.
@allencloud good point. I wonder if this is something we need to start checking for everywhere (stripping off the ~ce) at the end if it's going to be present.
WDYT @dongluochen?
There was a problem hiding this comment.
version is from moby/moby. How is it handled there?
There was a problem hiding this comment.
version is implemented here: https://github.com/moby/moby/blob/master/api/types/versions/compare.go#L10-L42
While I think it is better to strip off the suffix of -ce (maybe -ee as well, I have not experienced that yet).
There was a problem hiding this comment.
I'll take a look at how version is handled in moby/moby.
|
Any update? |
|
@allencloud thanks for checking. I haven't had time to get back to this, I will do it in a day or so. |
d91e6f2 to
f2d65dc
Compare
be9e595 to
e536221
Compare
|
@allencloud I've fixed this PR to take into account the new versions. PTAL. |
cluster/engine.go
Outdated
| default: | ||
| e.apiClient.UpdateClientVersion("1.30") | ||
| } | ||
| fmt.Println("FINAL CLIENT VERSION", e.apiClient.ClientVersion()) |
There was a problem hiding this comment.
Thanks for the improvement. And I hope to get more details of this line of code. What is the usage of this?
There was a problem hiding this comment.
My bad, this was for debugging. Removed it. @allencloud
There was a problem hiding this comment.
Thanks for the removal.
e536221 to
93285a9
Compare
cluster/engine.go
Outdated
| func (e *Engine) updateClientVersionFromServer(serverVersion string) { | ||
| // v will be >= 1.8, since this is checked earlier | ||
| // for server/API version reference, check https://docs.docker.com/engine/api/ | ||
| // new versions of Docker look like 17.06-ce etc. |
There was a problem hiding this comment.
I think in comment there should be 17.06.x-ce not 17.06-ce, otherwise LGTM.
|
Thanks @allencloud for the review. It seems like some tests are repeatedly failing, must be something changed with new APIs. I'll investigate. |
93285a9 to
9ab08f1
Compare
|
There's also another issue where the newer docker clients are downgrading version automatically. So actual requests that are sent seem to be using v1.24, for example |
f600afe to
7f4496b
Compare
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
0bad821 to
42a39ae
Compare
e2d8442 to
61bd893
Compare
|
@allencloud I've finally fixed the issue. It was a notable one. |
cluster/engine.go
Outdated
| default: | ||
| case versions.LessThan(serverVersion, "1.13.1"): | ||
| e.apiClient.UpdateClientVersion("1.25") | ||
| case versions.LessThan(serverVersion, "17.03.1") || serverVersion == "1.13.1": |
There was a problem hiding this comment.
You should probably use ... || versions.Equal(serverVersion, "1.13.1") here.
At some point, newer Docker versions stopped reporting container information on network ls. This caused a bug where the refresh loop was unable to get full network information (in particular container information). This commit fixes that by manually iterating over all containers and extracting network information from them. Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
61bd893 to
82d3319
Compare
|
CI seems to have been reliably fixed with this PR 🎉 🎉 |
Just making sure we're keeping up.
Ping @dongluochen @allencloud
Signed-off-by: Nishant Totla nishanttotla@gmail.com