mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 13:14:05 +00:00
Make ResourceVersion a string internally instead of uint64
Allows us to define different watch versioning regimes in the future as well as to encode information with the resource version. This changes /watch/resources?resourceVersion=3 to start the watch at 4 instead of 3, which means clients can read a resource version and then send it back to the server. Clients should no longer do math on resource versions.
This commit is contained in:
@@ -116,13 +116,13 @@ func (lw *listWatch) List() (runtime.Object, error) {
|
||||
Get()
|
||||
}
|
||||
|
||||
func (lw *listWatch) Watch(resourceVersion uint64) (watch.Interface, error) {
|
||||
func (lw *listWatch) Watch(resourceVersion string) (watch.Interface, error) {
|
||||
return lw.client.
|
||||
Get().
|
||||
Path("watch").
|
||||
Path(lw.resource).
|
||||
SelectorParam("fields", lw.fieldSelector).
|
||||
UintParam("resourceVersion", resourceVersion).
|
||||
Param("resourceVersion", resourceVersion).
|
||||
Watch()
|
||||
}
|
||||
|
||||
|
@@ -85,37 +85,41 @@ func TestCreateLists(t *testing.T) {
|
||||
func TestCreateWatches(t *testing.T) {
|
||||
factory := ConfigFactory{nil}
|
||||
table := []struct {
|
||||
rv uint64
|
||||
rv string
|
||||
location string
|
||||
factory func() *listWatch
|
||||
}{
|
||||
// Minion watch
|
||||
{
|
||||
rv: 0,
|
||||
rv: "",
|
||||
location: "/api/" + testapi.Version() + "/watch/minions?fields=&resourceVersion=",
|
||||
factory: factory.createMinionLW,
|
||||
}, {
|
||||
rv: "0",
|
||||
location: "/api/" + testapi.Version() + "/watch/minions?fields=&resourceVersion=0",
|
||||
factory: factory.createMinionLW,
|
||||
}, {
|
||||
rv: 42,
|
||||
rv: "42",
|
||||
location: "/api/" + testapi.Version() + "/watch/minions?fields=&resourceVersion=42",
|
||||
factory: factory.createMinionLW,
|
||||
},
|
||||
// Assigned pod watches
|
||||
{
|
||||
rv: 0,
|
||||
location: "/api/" + testapi.Version() + "/watch/pods?fields=DesiredState.Host!%3D&resourceVersion=0",
|
||||
rv: "",
|
||||
location: "/api/" + testapi.Version() + "/watch/pods?fields=DesiredState.Host!%3D&resourceVersion=",
|
||||
factory: factory.createAssignedPodLW,
|
||||
}, {
|
||||
rv: 42,
|
||||
rv: "42",
|
||||
location: "/api/" + testapi.Version() + "/watch/pods?fields=DesiredState.Host!%3D&resourceVersion=42",
|
||||
factory: factory.createAssignedPodLW,
|
||||
},
|
||||
// Unassigned pod watches
|
||||
{
|
||||
rv: 0,
|
||||
location: "/api/" + testapi.Version() + "/watch/pods?fields=DesiredState.Host%3D&resourceVersion=0",
|
||||
rv: "",
|
||||
location: "/api/" + testapi.Version() + "/watch/pods?fields=DesiredState.Host%3D&resourceVersion=",
|
||||
factory: factory.createUnassignedPodLW,
|
||||
}, {
|
||||
rv: 42,
|
||||
rv: "42",
|
||||
location: "/api/" + testapi.Version() + "/watch/pods?fields=DesiredState.Host%3D&resourceVersion=42",
|
||||
factory: factory.createUnassignedPodLW,
|
||||
},
|
||||
|
Reference in New Issue
Block a user