Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.

Add more cases for API versions#2690

Merged
nishanttotla merged 2 commits intodocker-archive:masterfrom
nishanttotla:update-api-version-cases
Jun 29, 2017
Merged

Add more cases for API versions#2690
nishanttotla merged 2 commits intodocker-archive:masterfrom
nishanttotla:update-api-version-cases

Conversation

@nishanttotla
Copy link
Copy Markdown
Contributor

@nishanttotla nishanttotla commented May 2, 2017

Just making sure we're keeping up.

Ping @dongluochen @allencloud

Signed-off-by: Nishant Totla nishanttotla@gmail.com

@dongluochen
Copy link
Copy Markdown
Contributor

LGTM

default:
case versions.LessThan(serverVersion, "1.13.1"):
e.apiClient.UpdateClientVersion("1.25")
case versions.LessThan(serverVersion, "17.03.1"):
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.

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
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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?

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.

version is from moby/moby. How is it handled there?

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.

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll take a look at how version is handled in moby/moby.

@allencloud
Copy link
Copy Markdown
Contributor

Any update?
ping @nishanttotla

@nishanttotla
Copy link
Copy Markdown
Contributor Author

@allencloud thanks for checking. I haven't had time to get back to this, I will do it in a day or so.

@nishanttotla nishanttotla force-pushed the update-api-version-cases branch from d91e6f2 to f2d65dc Compare May 25, 2017 23:00
@nishanttotla nishanttotla force-pushed the update-api-version-cases branch 3 times, most recently from be9e595 to e536221 Compare June 23, 2017 19:13
@nishanttotla
Copy link
Copy Markdown
Contributor Author

@allencloud I've fixed this PR to take into account the new versions. PTAL.

default:
e.apiClient.UpdateClientVersion("1.30")
}
fmt.Println("FINAL CLIENT VERSION", e.apiClient.ClientVersion())
Copy link
Copy Markdown
Contributor

@allencloud allencloud Jun 24, 2017

Choose a reason for hiding this comment

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

Thanks for the improvement. And I hope to get more details of this line of code. What is the usage of this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My bad, this was for debugging. Removed it. @allencloud

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.

Thanks for the removal.

@nishanttotla nishanttotla force-pushed the update-api-version-cases branch from e536221 to 93285a9 Compare June 24, 2017 18:04
allencloud
allencloud previously approved these changes Jun 25, 2017
Copy link
Copy Markdown
Contributor

@allencloud allencloud left a comment

Choose a reason for hiding this comment

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

LGTM

@allencloud allencloud dismissed their stale review June 25, 2017 04:35

Still something to review.

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.
Copy link
Copy Markdown
Contributor

@allencloud allencloud Jun 25, 2017

Choose a reason for hiding this comment

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

I think in comment there should be 17.06.x-ce not 17.06-ce, otherwise LGTM.

@nishanttotla
Copy link
Copy Markdown
Contributor Author

Thanks @allencloud for the review. It seems like some tests are repeatedly failing, must be something changed with new APIs. I'll investigate.

@nishanttotla nishanttotla force-pushed the update-api-version-cases branch from 93285a9 to 9ab08f1 Compare June 27, 2017 18:23
@nishanttotla
Copy link
Copy Markdown
Contributor Author

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

time="2017-06-27T18:39:52Z" level=debug msg="HTTP request received" method=GET uri="/v1.24/networks/node-0/bridge" 

@nishanttotla
Copy link
Copy Markdown
Contributor Author

Figured out that the issue is #2750

Updating PR to fix #2750

Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
@nishanttotla nishanttotla force-pushed the update-api-version-cases branch 2 times, most recently from 0bad821 to 42a39ae Compare June 28, 2017 21:39
@nishanttotla nishanttotla force-pushed the update-api-version-cases branch 3 times, most recently from e2d8442 to 61bd893 Compare June 29, 2017 18:34
@nishanttotla
Copy link
Copy Markdown
Contributor Author

@allencloud I've finally fixed the issue. It was a notable one.

default:
case versions.LessThan(serverVersion, "1.13.1"):
e.apiClient.UpdateClientVersion("1.25")
case versions.LessThan(serverVersion, "17.03.1") || serverVersion == "1.13.1":
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.

You should probably use ... || versions.Equal(serverVersion, "1.13.1") here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!

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>
@nishanttotla nishanttotla force-pushed the update-api-version-cases branch from 61bd893 to 82d3319 Compare June 29, 2017 20:29
@nishanttotla
Copy link
Copy Markdown
Contributor Author

CI seems to have been reliably fixed with this PR 🎉 🎉

@nishanttotla nishanttotla merged commit 2a5cfd9 into docker-archive:master Jun 29, 2017
@nishanttotla nishanttotla deleted the update-api-version-cases branch June 29, 2017 21:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants