Merge pull request #127857 from Jefftree/cle-v1alpha2

Coordinated Leader Election add v1alpha2
This commit is contained in:
Kubernetes Prow Robot 2024-11-08 07:10:43 +00:00 committed by GitHub
commit 45260fd76a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
100 changed files with 1094 additions and 1297 deletions

View file

@ -1622,7 +1622,7 @@
]
}
],
"version": "v1alpha1"
"version": "v1alpha2"
}
]
},

View file

@ -240,8 +240,8 @@
"version": "v1"
},
{
"groupVersion": "coordination.k8s.io/v1alpha1",
"version": "v1alpha1"
"groupVersion": "coordination.k8s.io/v1alpha2",
"version": "v1alpha2"
}
]
},

View file

@ -12,8 +12,8 @@
"version": "v1"
},
{
"groupVersion": "coordination.k8s.io/v1alpha1",
"version": "v1alpha1"
"groupVersion": "coordination.k8s.io/v1alpha2",
"version": "v1alpha2"
}
]
}

View file

@ -1,6 +1,6 @@
{
"apiVersion": "v1",
"groupVersion": "coordination.k8s.io/v1alpha1",
"groupVersion": "coordination.k8s.io/v1alpha2",
"kind": "APIResourceList",
"resources": [
{
@ -8,7 +8,7 @@
"name": "leasecandidates",
"namespaced": true,
"singularName": "leasecandidate",
"storageVersionHash": "VM2ILh8OBCI=",
"storageVersionHash": "RuOD9aJW3DI=",
"verbs": [
"create",
"delete",

View file

@ -5331,7 +5331,7 @@
},
"type": "object"
},
"io.k8s.api.coordination.v1alpha1.LeaseCandidate": {
"io.k8s.api.coordination.v1alpha2.LeaseCandidate": {
"description": "LeaseCandidate defines a candidate for a Lease object. Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.",
"properties": {
"apiVersion": {
@ -5347,7 +5347,7 @@
"description": "More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
},
"spec": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidateSpec",
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidateSpec",
"description": "spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status"
}
},
@ -5356,11 +5356,11 @@
{
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
]
},
"io.k8s.api.coordination.v1alpha1.LeaseCandidateList": {
"io.k8s.api.coordination.v1alpha2.LeaseCandidateList": {
"description": "LeaseCandidateList is a list of Lease objects.",
"properties": {
"apiVersion": {
@ -5370,7 +5370,7 @@
"items": {
"description": "items is a list of schema objects.",
"items": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
},
"type": "array"
},
@ -5391,15 +5391,15 @@
{
"group": "coordination.k8s.io",
"kind": "LeaseCandidateList",
"version": "v1alpha1"
"version": "v1alpha2"
}
]
},
"io.k8s.api.coordination.v1alpha1.LeaseCandidateSpec": {
"io.k8s.api.coordination.v1alpha2.LeaseCandidateSpec": {
"description": "LeaseCandidateSpec is a specification of a Lease.",
"properties": {
"binaryVersion": {
"description": "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required when strategy is \"OldestEmulationVersion\"",
"description": "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.",
"type": "string"
},
"emulationVersion": {
@ -5414,22 +5414,19 @@
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime",
"description": "PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime."
},
"preferredStrategies": {
"description": "PreferredStrategies indicates the list of strategies for picking the leader for coordinated leader election. The list is ordered, and the first strategy supersedes all other strategies. The list is used by coordinated leader election to make a decision about the final election strategy. This follows as - If all clients have strategy X as the first element in this list, strategy X will be used. - If a candidate has strategy [X] and another candidate has strategy [Y, X], Y supersedes X and strategy Y\n will be used.\n- If a candidate has strategy [X, Y] and another candidate has strategy [Y, X], this is a user error and leader\n election will not operate the Lease until resolved.\n(Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.",
"items": {
"type": "string"
},
"type": "array",
"x-kubernetes-list-type": "atomic"
},
"renewTime": {
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime",
"description": "RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates."
},
"strategy": {
"description": "Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved. (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.",
"type": "string"
}
},
"required": [
"leaseName",
"preferredStrategies"
"binaryVersion",
"strategy"
],
"type": "object"
},
@ -18325,7 +18322,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -19077,7 +19074,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -56932,7 +56929,7 @@
}
]
},
"/apis/coordination.k8s.io/v1alpha1/": {
"/apis/coordination.k8s.io/v1alpha2/": {
"get": {
"consumes": [
"application/json",
@ -56941,7 +56938,7 @@
"application/cbor"
],
"description": "get available resources",
"operationId": "getCoordinationV1alpha1APIResources",
"operationId": "getCoordinationV1alpha2APIResources",
"produces": [
"application/json",
"application/yaml",
@ -56963,17 +56960,17 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
]
}
},
"/apis/coordination.k8s.io/v1alpha1/leasecandidates": {
"/apis/coordination.k8s.io/v1alpha2/leasecandidates": {
"get": {
"consumes": [
"*/*"
],
"description": "list or watch objects of kind LeaseCandidate",
"operationId": "listCoordinationV1alpha1LeaseCandidateForAllNamespaces",
"operationId": "listCoordinationV1alpha2LeaseCandidateForAllNamespaces",
"produces": [
"application/json",
"application/yaml",
@ -56987,7 +56984,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"401": {
@ -56998,13 +56995,13 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "list",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -57043,13 +57040,13 @@
}
]
},
"/apis/coordination.k8s.io/v1alpha1/namespaces/{namespace}/leasecandidates": {
"/apis/coordination.k8s.io/v1alpha2/namespaces/{namespace}/leasecandidates": {
"delete": {
"consumes": [
"*/*"
],
"description": "delete collection of LeaseCandidate",
"operationId": "deleteCoordinationV1alpha1CollectionNamespacedLeaseCandidate",
"operationId": "deleteCoordinationV1alpha2CollectionNamespacedLeaseCandidate",
"parameters": [
{
"$ref": "#/parameters/body-2Y1dVQaQ"
@ -57119,13 +57116,13 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "deletecollection",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"get": {
@ -57133,7 +57130,7 @@
"*/*"
],
"description": "list or watch objects of kind LeaseCandidate",
"operationId": "listCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "listCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"$ref": "#/parameters/allowWatchBookmarks-HC2hJt-J"
@ -57179,7 +57176,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"401": {
@ -57190,13 +57187,13 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "list",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -57212,14 +57209,14 @@
"*/*"
],
"description": "create a LeaseCandidate",
"operationId": "createCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "createCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
{
@ -57250,19 +57247,19 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"202": {
"description": "Accepted",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"401": {
@ -57273,23 +57270,23 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "post",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
}
},
"/apis/coordination.k8s.io/v1alpha1/namespaces/{namespace}/leasecandidates/{name}": {
"/apis/coordination.k8s.io/v1alpha2/namespaces/{namespace}/leasecandidates/{name}": {
"delete": {
"consumes": [
"*/*"
],
"description": "delete a LeaseCandidate",
"operationId": "deleteCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "deleteCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"$ref": "#/parameters/body-2Y1dVQaQ"
@ -57341,13 +57338,13 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "delete",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"get": {
@ -57355,7 +57352,7 @@
"*/*"
],
"description": "read the specified LeaseCandidate",
"operationId": "readCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "readCoordinationV1alpha2NamespacedLeaseCandidate",
"produces": [
"application/json",
"application/yaml",
@ -57366,7 +57363,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"401": {
@ -57377,13 +57374,13 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "get",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -57411,7 +57408,7 @@
"application/apply-patch+cbor"
],
"description": "partially update the specified LeaseCandidate",
"operationId": "patchCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "patchCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"$ref": "#/parameters/body-78PwaGsr"
@ -57447,13 +57444,13 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"401": {
@ -57464,13 +57461,13 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "patch",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"put": {
@ -57478,14 +57475,14 @@
"*/*"
],
"description": "replace the specified LeaseCandidate",
"operationId": "replaceCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "replaceCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
{
@ -57516,13 +57513,13 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/definitions/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"401": {
@ -57533,23 +57530,23 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "put",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
}
},
"/apis/coordination.k8s.io/v1alpha1/watch/leasecandidates": {
"/apis/coordination.k8s.io/v1alpha2/watch/leasecandidates": {
"get": {
"consumes": [
"*/*"
],
"description": "watch individual changes to a list of LeaseCandidate. deprecated: use the 'watch' parameter with a list operation instead.",
"operationId": "watchCoordinationV1alpha1LeaseCandidateListForAllNamespaces",
"operationId": "watchCoordinationV1alpha2LeaseCandidateListForAllNamespaces",
"produces": [
"application/json",
"application/yaml",
@ -57574,13 +57571,13 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "watchlist",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -57619,13 +57616,13 @@
}
]
},
"/apis/coordination.k8s.io/v1alpha1/watch/namespaces/{namespace}/leasecandidates": {
"/apis/coordination.k8s.io/v1alpha2/watch/namespaces/{namespace}/leasecandidates": {
"get": {
"consumes": [
"*/*"
],
"description": "watch individual changes to a list of LeaseCandidate. deprecated: use the 'watch' parameter with a list operation instead.",
"operationId": "watchCoordinationV1alpha1NamespacedLeaseCandidateList",
"operationId": "watchCoordinationV1alpha2NamespacedLeaseCandidateList",
"produces": [
"application/json",
"application/yaml",
@ -57650,13 +57647,13 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "watchlist",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -57698,13 +57695,13 @@
}
]
},
"/apis/coordination.k8s.io/v1alpha1/watch/namespaces/{namespace}/leasecandidates/{name}": {
"/apis/coordination.k8s.io/v1alpha2/watch/namespaces/{namespace}/leasecandidates/{name}": {
"get": {
"consumes": [
"*/*"
],
"description": "watch changes to an object of kind LeaseCandidate. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.",
"operationId": "watchCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "watchCoordinationV1alpha2NamespacedLeaseCandidate",
"produces": [
"application/json",
"application/yaml",
@ -57729,13 +57726,13 @@
"https"
],
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "watch",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [

View file

@ -8988,7 +8988,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -9739,7 +9739,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -1450,7 +1450,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -2196,7 +2196,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -814,7 +814,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1560,7 +1560,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -964,7 +964,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1710,7 +1710,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -1173,7 +1173,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1862,7 +1862,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -306,7 +306,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -995,7 +995,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -5679,7 +5679,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -6425,7 +6425,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -499,7 +499,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1188,7 +1188,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -1151,7 +1151,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1897,7 +1897,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -4881,7 +4881,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -5627,7 +5627,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -535,7 +535,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1224,7 +1224,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -411,7 +411,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1100,7 +1100,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -434,7 +434,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1128,7 +1128,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -1,7 +1,7 @@
{
"components": {
"schemas": {
"io.k8s.api.coordination.v1alpha1.LeaseCandidate": {
"io.k8s.api.coordination.v1alpha2.LeaseCandidate": {
"description": "LeaseCandidate defines a candidate for a Lease object. Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.",
"properties": {
"apiVersion": {
@ -24,7 +24,7 @@
"spec": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateSpec"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateSpec"
}
],
"default": {},
@ -36,11 +36,11 @@
{
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
]
},
"io.k8s.api.coordination.v1alpha1.LeaseCandidateList": {
"io.k8s.api.coordination.v1alpha2.LeaseCandidateList": {
"description": "LeaseCandidateList is a list of Lease objects.",
"properties": {
"apiVersion": {
@ -52,7 +52,7 @@
"items": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
],
"default": {}
@ -81,15 +81,16 @@
{
"group": "coordination.k8s.io",
"kind": "LeaseCandidateList",
"version": "v1alpha1"
"version": "v1alpha2"
}
]
},
"io.k8s.api.coordination.v1alpha1.LeaseCandidateSpec": {
"io.k8s.api.coordination.v1alpha2.LeaseCandidateSpec": {
"description": "LeaseCandidateSpec is a specification of a Lease.",
"properties": {
"binaryVersion": {
"description": "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required when strategy is \"OldestEmulationVersion\"",
"default": "",
"description": "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.",
"type": "string"
},
"emulationVersion": {
@ -109,15 +110,6 @@
],
"description": "PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime."
},
"preferredStrategies": {
"description": "PreferredStrategies indicates the list of strategies for picking the leader for coordinated leader election. The list is ordered, and the first strategy supersedes all other strategies. The list is used by coordinated leader election to make a decision about the final election strategy. This follows as - If all clients have strategy X as the first element in this list, strategy X will be used. - If a candidate has strategy [X] and another candidate has strategy [Y, X], Y supersedes X and strategy Y\n will be used.\n- If a candidate has strategy [X, Y] and another candidate has strategy [Y, X], this is a user error and leader\n election will not operate the Lease until resolved.\n(Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.",
"items": {
"default": "",
"type": "string"
},
"type": "array",
"x-kubernetes-list-type": "atomic"
},
"renewTime": {
"allOf": [
{
@ -125,11 +117,16 @@
}
],
"description": "RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates."
},
"strategy": {
"description": "Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved. (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.",
"type": "string"
}
},
"required": [
"leaseName",
"preferredStrategies"
"binaryVersion",
"strategy"
],
"type": "object"
},
@ -438,7 +435,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1132,7 +1129,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1316,10 +1313,10 @@
},
"openapi": "3.0.0",
"paths": {
"/apis/coordination.k8s.io/v1alpha1/": {
"/apis/coordination.k8s.io/v1alpha2/": {
"get": {
"description": "get available resources",
"operationId": "getCoordinationV1alpha1APIResources",
"operationId": "getCoordinationV1alpha2APIResources",
"responses": {
"200": {
"content": {
@ -1351,50 +1348,50 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
]
}
},
"/apis/coordination.k8s.io/v1alpha1/leasecandidates": {
"/apis/coordination.k8s.io/v1alpha2/leasecandidates": {
"get": {
"description": "list or watch objects of kind LeaseCandidate",
"operationId": "listCoordinationV1alpha1LeaseCandidateForAllNamespaces",
"operationId": "listCoordinationV1alpha2LeaseCandidateForAllNamespaces",
"responses": {
"200": {
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/cbor-seq": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/json;stream=watch": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/vnd.kubernetes.protobuf;stream=watch": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
}
},
@ -1405,13 +1402,13 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "list",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -1516,10 +1513,10 @@
}
]
},
"/apis/coordination.k8s.io/v1alpha1/namespaces/{namespace}/leasecandidates": {
"/apis/coordination.k8s.io/v1alpha2/namespaces/{namespace}/leasecandidates": {
"delete": {
"description": "delete collection of LeaseCandidate",
"operationId": "deleteCoordinationV1alpha1CollectionNamespacedLeaseCandidate",
"operationId": "deleteCoordinationV1alpha2CollectionNamespacedLeaseCandidate",
"parameters": [
{
"description": "The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\".\n\nThis field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications.",
@ -1679,18 +1676,18 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "deletecollection",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"get": {
"description": "list or watch objects of kind LeaseCandidate",
"operationId": "listCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "listCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"description": "allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored.",
@ -1788,37 +1785,37 @@
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/cbor-seq": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/json;stream=watch": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/vnd.kubernetes.protobuf;stream=watch": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidateList"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidateList"
}
}
},
@ -1829,13 +1826,13 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "list",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -1861,7 +1858,7 @@
],
"post": {
"description": "create a LeaseCandidate",
"operationId": "createCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "createCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"description": "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed",
@ -1895,7 +1892,7 @@
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -1906,22 +1903,22 @@
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -1931,22 +1928,22 @@
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -1956,22 +1953,22 @@
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -1982,20 +1979,20 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "post",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
}
},
"/apis/coordination.k8s.io/v1alpha1/namespaces/{namespace}/leasecandidates/{name}": {
"/apis/coordination.k8s.io/v1alpha2/namespaces/{namespace}/leasecandidates/{name}": {
"delete": {
"description": "delete a LeaseCandidate",
"operationId": "deleteCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "deleteCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"description": "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed",
@ -2108,39 +2105,39 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "delete",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"get": {
"description": "read the specified LeaseCandidate",
"operationId": "readCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "readCoordinationV1alpha2NamespacedLeaseCandidate",
"responses": {
"200": {
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -2151,13 +2148,13 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "get",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -2193,7 +2190,7 @@
],
"patch": {
"description": "partially update the specified LeaseCandidate",
"operationId": "patchCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "patchCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"description": "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed",
@ -2267,22 +2264,22 @@
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -2292,22 +2289,22 @@
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -2318,18 +2315,18 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "patch",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"put": {
"description": "replace the specified LeaseCandidate",
"operationId": "replaceCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "replaceCoordinationV1alpha2NamespacedLeaseCandidate",
"parameters": [
{
"description": "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed",
@ -2363,7 +2360,7 @@
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -2374,22 +2371,22 @@
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -2399,22 +2396,22 @@
"content": {
"application/cbor": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha1.LeaseCandidate"
"$ref": "#/components/schemas/io.k8s.api.coordination.v1alpha2.LeaseCandidate"
}
}
},
@ -2425,20 +2422,20 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "put",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
}
},
"/apis/coordination.k8s.io/v1alpha1/watch/leasecandidates": {
"/apis/coordination.k8s.io/v1alpha2/watch/leasecandidates": {
"get": {
"description": "watch individual changes to a list of LeaseCandidate. deprecated: use the 'watch' parameter with a list operation instead.",
"operationId": "watchCoordinationV1alpha1LeaseCandidateListForAllNamespaces",
"operationId": "watchCoordinationV1alpha2LeaseCandidateListForAllNamespaces",
"responses": {
"200": {
"content": {
@ -2485,13 +2482,13 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "watchlist",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -2596,10 +2593,10 @@
}
]
},
"/apis/coordination.k8s.io/v1alpha1/watch/namespaces/{namespace}/leasecandidates": {
"/apis/coordination.k8s.io/v1alpha2/watch/namespaces/{namespace}/leasecandidates": {
"get": {
"description": "watch individual changes to a list of LeaseCandidate. deprecated: use the 'watch' parameter with a list operation instead.",
"operationId": "watchCoordinationV1alpha1NamespacedLeaseCandidateList",
"operationId": "watchCoordinationV1alpha2NamespacedLeaseCandidateList",
"responses": {
"200": {
"content": {
@ -2646,13 +2643,13 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "watchlist",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [
@ -2767,10 +2764,10 @@
}
]
},
"/apis/coordination.k8s.io/v1alpha1/watch/namespaces/{namespace}/leasecandidates/{name}": {
"/apis/coordination.k8s.io/v1alpha2/watch/namespaces/{namespace}/leasecandidates/{name}": {
"get": {
"description": "watch changes to an object of kind LeaseCandidate. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.",
"operationId": "watchCoordinationV1alpha1NamespacedLeaseCandidate",
"operationId": "watchCoordinationV1alpha2NamespacedLeaseCandidate",
"responses": {
"200": {
"content": {
@ -2817,13 +2814,13 @@
}
},
"tags": [
"coordination_v1alpha1"
"coordination_v1alpha2"
],
"x-kubernetes-action": "watch",
"x-kubernetes-group-version-kind": {
"group": "coordination.k8s.io",
"kind": "LeaseCandidate",
"version": "v1alpha1"
"version": "v1alpha2"
}
},
"parameters": [

View file

@ -589,7 +589,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1278,7 +1278,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -544,7 +544,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1238,7 +1238,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -1035,7 +1035,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1724,7 +1724,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -525,7 +525,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1214,7 +1214,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -1107,7 +1107,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1853,7 +1853,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -611,7 +611,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1300,7 +1300,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -484,7 +484,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1173,7 +1173,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -546,7 +546,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1292,7 +1292,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -819,7 +819,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1565,7 +1565,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -1511,7 +1511,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -2200,7 +2200,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -1533,7 +1533,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -2222,7 +2222,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -402,7 +402,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1091,7 +1091,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -2264,7 +2264,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -3010,7 +3010,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -397,7 +397,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1086,7 +1086,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -397,7 +397,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1086,7 +1086,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -509,7 +509,7 @@
{
"group": "coordination.k8s.io",
"kind": "DeleteOptions",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",
@ -1198,7 +1198,7 @@
{
"group": "coordination.k8s.io",
"kind": "WatchEvent",
"version": "v1alpha1"
"version": "v1alpha2"
},
{
"group": "coordination.k8s.io",

View file

@ -298,7 +298,7 @@ func Run(ctx context.Context, c *config.CompletedConfig) error {
"kube-controller-manager",
binaryVersion.FinalizeVersion(),
emulationVersion.FinalizeVersion(),
[]coordinationv1.CoordinatedLeaseStrategy{coordinationv1.OldestEmulationVersion},
coordinationv1.OldestEmulationVersion,
)
if err != nil {
return err

View file

@ -227,7 +227,7 @@ func Run(ctx context.Context, cc *schedulerserverconfig.CompletedConfig, sched *
"kube-scheduler",
binaryVersion.FinalizeVersion(),
emulationVersion.FinalizeVersion(),
[]coordinationv1.CoordinatedLeaseStrategy{coordinationv1.OldestEmulationVersion},
coordinationv1.OldestEmulationVersion,
)
if err != nil {
return err

View file

@ -89,7 +89,7 @@ batch/v1beta1 \
certificates.k8s.io/v1 \
certificates.k8s.io/v1beta1 \
certificates.k8s.io/v1alpha1 \
coordination.k8s.io/v1alpha1 \
coordination.k8s.io/v1alpha2 \
coordination.k8s.io/v1beta1 \
coordination.k8s.io/v1 \
discovery.k8s.io/v1 \

View file

@ -24,7 +24,7 @@ import (
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/coordination"
v1 "k8s.io/kubernetes/pkg/apis/coordination/v1"
"k8s.io/kubernetes/pkg/apis/coordination/v1alpha1"
"k8s.io/kubernetes/pkg/apis/coordination/v1alpha2"
"k8s.io/kubernetes/pkg/apis/coordination/v1beta1"
)
@ -35,8 +35,8 @@ func init() {
// Install registers the API group and adds types to a scheme
func Install(scheme *runtime.Scheme) {
utilruntime.Must(coordination.AddToScheme(scheme))
utilruntime.Must(v1alpha1.AddToScheme(scheme))
utilruntime.Must(v1alpha2.AddToScheme(scheme))
utilruntime.Must(v1beta1.AddToScheme(scheme))
utilruntime.Must(v1.AddToScheme(scheme))
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v1beta1.SchemeGroupVersion, v1alpha1.SchemeGroupVersion))
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v1beta1.SchemeGroupVersion, v1alpha2.SchemeGroupVersion))
}

View file

@ -126,27 +126,23 @@ type LeaseCandidateSpec struct {
// +optional
RenewTime *metav1.MicroTime
// BinaryVersion is the binary version. It must be in a semver format without leading `v`.
// This field is required when strategy is "OldestEmulationVersion"
// +optional
// This field is required.
// +required
BinaryVersion string
// EmulationVersion is the emulation version. It must be in a semver format without leading `v`.
// EmulationVersion must be less than or equal to BinaryVersion.
// This field is required when strategy is "OldestEmulationVersion"
// +optional
EmulationVersion string
// PreferredStrategies indicates the list of strategies for picking the leader for coordinated leader election.
// The list is ordered, and the first strategy supersedes all other strategies. The list is used by coordinated
// leader election to make a decision about the final election strategy. This follows as
// - If all clients have strategy X as the first element in this list, strategy X will be used.
// - If a candidate has strategy [X] and another candidate has strategy [Y, X], Y supersedes X and strategy Y
// will be used.
// - If a candidate has strategy [X, Y] and another candidate has strategy [Y, X], this is a user error and leader
// election will not operate the Lease until resolved.
// Strategy is the strategy that coordinated leader election will use for picking the leader.
// If multiple candidates for the same Lease return different strategies, the strategy provided
// by the candidate with the latest BinaryVersion will be used. If there is still conflict,
// this is a user error and coordinated leader election will not operate the Lease until resolved.
// (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.
// +featureGate=CoordinatedLeaderElection
// +listType=atomic
// +required
PreferredStrategies []CoordinatedLeaseStrategy
Strategy CoordinatedLeaseStrategy
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

View file

@ -15,10 +15,10 @@ limitations under the License.
*/
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/coordination
// +k8s:conversion-gen-external-types=k8s.io/api/coordination/v1alpha1
// +k8s:conversion-gen-external-types=k8s.io/api/coordination/v1alpha2
// +k8s:defaulter-gen=TypeMeta
// +k8s:defaulter-gen-input=k8s.io/api/coordination/v1alpha1
// +k8s:defaulter-gen-input=k8s.io/api/coordination/v1alpha2
// +groupName=coordination.k8s.io
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/coordination/v1alpha1"
package v1alpha2 // import "k8s.io/kubernetes/pkg/apis/coordination/v1alpha2"

View file

@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
package v1alpha2
import (
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
"k8s.io/apimachinery/pkg/runtime/schema"
)
@ -25,7 +25,7 @@ import (
const GroupName = "coordination.k8s.io"
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
@ -33,7 +33,7 @@ func Resource(resource string) schema.GroupResource {
}
var (
localSchemeBuilder = &coordinationv1alpha1.SchemeBuilder
localSchemeBuilder = &coordinationv1alpha2.SchemeBuilder
// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
AddToScheme = localSchemeBuilder.AddToScheme
)

View file

@ -19,13 +19,13 @@ limitations under the License.
// Code generated by conversion-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
unsafe "unsafe"
coordinationv1 "k8s.io/api/coordination/v1"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
@ -39,113 +39,113 @@ func init() {
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(s *runtime.Scheme) error {
if err := s.AddGeneratedConversionFunc((*coordinationv1alpha1.LeaseCandidate)(nil), (*coordination.LeaseCandidate)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_LeaseCandidate_To_coordination_LeaseCandidate(a.(*coordinationv1alpha1.LeaseCandidate), b.(*coordination.LeaseCandidate), scope)
if err := s.AddGeneratedConversionFunc((*coordinationv1alpha2.LeaseCandidate)(nil), (*coordination.LeaseCandidate)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_LeaseCandidate_To_coordination_LeaseCandidate(a.(*coordinationv1alpha2.LeaseCandidate), b.(*coordination.LeaseCandidate), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*coordination.LeaseCandidate)(nil), (*coordinationv1alpha1.LeaseCandidate)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_coordination_LeaseCandidate_To_v1alpha1_LeaseCandidate(a.(*coordination.LeaseCandidate), b.(*coordinationv1alpha1.LeaseCandidate), scope)
if err := s.AddGeneratedConversionFunc((*coordination.LeaseCandidate)(nil), (*coordinationv1alpha2.LeaseCandidate)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_coordination_LeaseCandidate_To_v1alpha2_LeaseCandidate(a.(*coordination.LeaseCandidate), b.(*coordinationv1alpha2.LeaseCandidate), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*coordinationv1alpha1.LeaseCandidateList)(nil), (*coordination.LeaseCandidateList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_LeaseCandidateList_To_coordination_LeaseCandidateList(a.(*coordinationv1alpha1.LeaseCandidateList), b.(*coordination.LeaseCandidateList), scope)
if err := s.AddGeneratedConversionFunc((*coordinationv1alpha2.LeaseCandidateList)(nil), (*coordination.LeaseCandidateList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_LeaseCandidateList_To_coordination_LeaseCandidateList(a.(*coordinationv1alpha2.LeaseCandidateList), b.(*coordination.LeaseCandidateList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*coordination.LeaseCandidateList)(nil), (*coordinationv1alpha1.LeaseCandidateList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_coordination_LeaseCandidateList_To_v1alpha1_LeaseCandidateList(a.(*coordination.LeaseCandidateList), b.(*coordinationv1alpha1.LeaseCandidateList), scope)
if err := s.AddGeneratedConversionFunc((*coordination.LeaseCandidateList)(nil), (*coordinationv1alpha2.LeaseCandidateList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_coordination_LeaseCandidateList_To_v1alpha2_LeaseCandidateList(a.(*coordination.LeaseCandidateList), b.(*coordinationv1alpha2.LeaseCandidateList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*coordinationv1alpha1.LeaseCandidateSpec)(nil), (*coordination.LeaseCandidateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(a.(*coordinationv1alpha1.LeaseCandidateSpec), b.(*coordination.LeaseCandidateSpec), scope)
if err := s.AddGeneratedConversionFunc((*coordinationv1alpha2.LeaseCandidateSpec)(nil), (*coordination.LeaseCandidateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(a.(*coordinationv1alpha2.LeaseCandidateSpec), b.(*coordination.LeaseCandidateSpec), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*coordination.LeaseCandidateSpec)(nil), (*coordinationv1alpha1.LeaseCandidateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_coordination_LeaseCandidateSpec_To_v1alpha1_LeaseCandidateSpec(a.(*coordination.LeaseCandidateSpec), b.(*coordinationv1alpha1.LeaseCandidateSpec), scope)
if err := s.AddGeneratedConversionFunc((*coordination.LeaseCandidateSpec)(nil), (*coordinationv1alpha2.LeaseCandidateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_coordination_LeaseCandidateSpec_To_v1alpha2_LeaseCandidateSpec(a.(*coordination.LeaseCandidateSpec), b.(*coordinationv1alpha2.LeaseCandidateSpec), scope)
}); err != nil {
return err
}
return nil
}
func autoConvert_v1alpha1_LeaseCandidate_To_coordination_LeaseCandidate(in *coordinationv1alpha1.LeaseCandidate, out *coordination.LeaseCandidate, s conversion.Scope) error {
func autoConvert_v1alpha2_LeaseCandidate_To_coordination_LeaseCandidate(in *coordinationv1alpha2.LeaseCandidate, out *coordination.LeaseCandidate, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1alpha1_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(&in.Spec, &out.Spec, s); err != nil {
if err := Convert_v1alpha2_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
return nil
}
// Convert_v1alpha1_LeaseCandidate_To_coordination_LeaseCandidate is an autogenerated conversion function.
func Convert_v1alpha1_LeaseCandidate_To_coordination_LeaseCandidate(in *coordinationv1alpha1.LeaseCandidate, out *coordination.LeaseCandidate, s conversion.Scope) error {
return autoConvert_v1alpha1_LeaseCandidate_To_coordination_LeaseCandidate(in, out, s)
// Convert_v1alpha2_LeaseCandidate_To_coordination_LeaseCandidate is an autogenerated conversion function.
func Convert_v1alpha2_LeaseCandidate_To_coordination_LeaseCandidate(in *coordinationv1alpha2.LeaseCandidate, out *coordination.LeaseCandidate, s conversion.Scope) error {
return autoConvert_v1alpha2_LeaseCandidate_To_coordination_LeaseCandidate(in, out, s)
}
func autoConvert_coordination_LeaseCandidate_To_v1alpha1_LeaseCandidate(in *coordination.LeaseCandidate, out *coordinationv1alpha1.LeaseCandidate, s conversion.Scope) error {
func autoConvert_coordination_LeaseCandidate_To_v1alpha2_LeaseCandidate(in *coordination.LeaseCandidate, out *coordinationv1alpha2.LeaseCandidate, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_coordination_LeaseCandidateSpec_To_v1alpha1_LeaseCandidateSpec(&in.Spec, &out.Spec, s); err != nil {
if err := Convert_coordination_LeaseCandidateSpec_To_v1alpha2_LeaseCandidateSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
return nil
}
// Convert_coordination_LeaseCandidate_To_v1alpha1_LeaseCandidate is an autogenerated conversion function.
func Convert_coordination_LeaseCandidate_To_v1alpha1_LeaseCandidate(in *coordination.LeaseCandidate, out *coordinationv1alpha1.LeaseCandidate, s conversion.Scope) error {
return autoConvert_coordination_LeaseCandidate_To_v1alpha1_LeaseCandidate(in, out, s)
// Convert_coordination_LeaseCandidate_To_v1alpha2_LeaseCandidate is an autogenerated conversion function.
func Convert_coordination_LeaseCandidate_To_v1alpha2_LeaseCandidate(in *coordination.LeaseCandidate, out *coordinationv1alpha2.LeaseCandidate, s conversion.Scope) error {
return autoConvert_coordination_LeaseCandidate_To_v1alpha2_LeaseCandidate(in, out, s)
}
func autoConvert_v1alpha1_LeaseCandidateList_To_coordination_LeaseCandidateList(in *coordinationv1alpha1.LeaseCandidateList, out *coordination.LeaseCandidateList, s conversion.Scope) error {
func autoConvert_v1alpha2_LeaseCandidateList_To_coordination_LeaseCandidateList(in *coordinationv1alpha2.LeaseCandidateList, out *coordination.LeaseCandidateList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]coordination.LeaseCandidate)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_v1alpha1_LeaseCandidateList_To_coordination_LeaseCandidateList is an autogenerated conversion function.
func Convert_v1alpha1_LeaseCandidateList_To_coordination_LeaseCandidateList(in *coordinationv1alpha1.LeaseCandidateList, out *coordination.LeaseCandidateList, s conversion.Scope) error {
return autoConvert_v1alpha1_LeaseCandidateList_To_coordination_LeaseCandidateList(in, out, s)
// Convert_v1alpha2_LeaseCandidateList_To_coordination_LeaseCandidateList is an autogenerated conversion function.
func Convert_v1alpha2_LeaseCandidateList_To_coordination_LeaseCandidateList(in *coordinationv1alpha2.LeaseCandidateList, out *coordination.LeaseCandidateList, s conversion.Scope) error {
return autoConvert_v1alpha2_LeaseCandidateList_To_coordination_LeaseCandidateList(in, out, s)
}
func autoConvert_coordination_LeaseCandidateList_To_v1alpha1_LeaseCandidateList(in *coordination.LeaseCandidateList, out *coordinationv1alpha1.LeaseCandidateList, s conversion.Scope) error {
func autoConvert_coordination_LeaseCandidateList_To_v1alpha2_LeaseCandidateList(in *coordination.LeaseCandidateList, out *coordinationv1alpha2.LeaseCandidateList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]coordinationv1alpha1.LeaseCandidate)(unsafe.Pointer(&in.Items))
out.Items = *(*[]coordinationv1alpha2.LeaseCandidate)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_coordination_LeaseCandidateList_To_v1alpha1_LeaseCandidateList is an autogenerated conversion function.
func Convert_coordination_LeaseCandidateList_To_v1alpha1_LeaseCandidateList(in *coordination.LeaseCandidateList, out *coordinationv1alpha1.LeaseCandidateList, s conversion.Scope) error {
return autoConvert_coordination_LeaseCandidateList_To_v1alpha1_LeaseCandidateList(in, out, s)
// Convert_coordination_LeaseCandidateList_To_v1alpha2_LeaseCandidateList is an autogenerated conversion function.
func Convert_coordination_LeaseCandidateList_To_v1alpha2_LeaseCandidateList(in *coordination.LeaseCandidateList, out *coordinationv1alpha2.LeaseCandidateList, s conversion.Scope) error {
return autoConvert_coordination_LeaseCandidateList_To_v1alpha2_LeaseCandidateList(in, out, s)
}
func autoConvert_v1alpha1_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(in *coordinationv1alpha1.LeaseCandidateSpec, out *coordination.LeaseCandidateSpec, s conversion.Scope) error {
func autoConvert_v1alpha2_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(in *coordinationv1alpha2.LeaseCandidateSpec, out *coordination.LeaseCandidateSpec, s conversion.Scope) error {
out.LeaseName = in.LeaseName
out.PingTime = (*v1.MicroTime)(unsafe.Pointer(in.PingTime))
out.RenewTime = (*v1.MicroTime)(unsafe.Pointer(in.RenewTime))
out.BinaryVersion = in.BinaryVersion
out.EmulationVersion = in.EmulationVersion
out.PreferredStrategies = *(*[]coordination.CoordinatedLeaseStrategy)(unsafe.Pointer(&in.PreferredStrategies))
out.Strategy = coordination.CoordinatedLeaseStrategy(in.Strategy)
return nil
}
// Convert_v1alpha1_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec is an autogenerated conversion function.
func Convert_v1alpha1_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(in *coordinationv1alpha1.LeaseCandidateSpec, out *coordination.LeaseCandidateSpec, s conversion.Scope) error {
return autoConvert_v1alpha1_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(in, out, s)
// Convert_v1alpha2_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec is an autogenerated conversion function.
func Convert_v1alpha2_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(in *coordinationv1alpha2.LeaseCandidateSpec, out *coordination.LeaseCandidateSpec, s conversion.Scope) error {
return autoConvert_v1alpha2_LeaseCandidateSpec_To_coordination_LeaseCandidateSpec(in, out, s)
}
func autoConvert_coordination_LeaseCandidateSpec_To_v1alpha1_LeaseCandidateSpec(in *coordination.LeaseCandidateSpec, out *coordinationv1alpha1.LeaseCandidateSpec, s conversion.Scope) error {
func autoConvert_coordination_LeaseCandidateSpec_To_v1alpha2_LeaseCandidateSpec(in *coordination.LeaseCandidateSpec, out *coordinationv1alpha2.LeaseCandidateSpec, s conversion.Scope) error {
out.LeaseName = in.LeaseName
out.PingTime = (*v1.MicroTime)(unsafe.Pointer(in.PingTime))
out.RenewTime = (*v1.MicroTime)(unsafe.Pointer(in.RenewTime))
out.BinaryVersion = in.BinaryVersion
out.EmulationVersion = in.EmulationVersion
out.PreferredStrategies = *(*[]coordinationv1.CoordinatedLeaseStrategy)(unsafe.Pointer(&in.PreferredStrategies))
out.Strategy = coordinationv1.CoordinatedLeaseStrategy(in.Strategy)
return nil
}
// Convert_coordination_LeaseCandidateSpec_To_v1alpha1_LeaseCandidateSpec is an autogenerated conversion function.
func Convert_coordination_LeaseCandidateSpec_To_v1alpha1_LeaseCandidateSpec(in *coordination.LeaseCandidateSpec, out *coordinationv1alpha1.LeaseCandidateSpec, s conversion.Scope) error {
return autoConvert_coordination_LeaseCandidateSpec_To_v1alpha1_LeaseCandidateSpec(in, out, s)
// Convert_coordination_LeaseCandidateSpec_To_v1alpha2_LeaseCandidateSpec is an autogenerated conversion function.
func Convert_coordination_LeaseCandidateSpec_To_v1alpha2_LeaseCandidateSpec(in *coordination.LeaseCandidateSpec, out *coordinationv1alpha2.LeaseCandidateSpec, s conversion.Scope) error {
return autoConvert_coordination_LeaseCandidateSpec_To_v1alpha2_LeaseCandidateSpec(in, out, s)
}

View file

@ -19,7 +19,7 @@ limitations under the License.
// Code generated by defaulter-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
runtime "k8s.io/apimachinery/pkg/runtime"

View file

@ -111,7 +111,9 @@ func ValidateLeaseCandidateSpec(spec *coordination.LeaseCandidateSpec, fldPath *
}
}
bv := semver.Version{}
if spec.BinaryVersion != "" {
if spec.BinaryVersion == "" {
allErrs = append(allErrs, field.Required(fldPath.Child("binaryVersion"), ""))
} else {
var err error
bv, err = semver.Parse(spec.BinaryVersion)
if err != nil {
@ -124,29 +126,18 @@ func ValidateLeaseCandidateSpec(spec *coordination.LeaseCandidateSpec, fldPath *
allErrs = append(allErrs, field.Invalid(fld, spec.BinaryVersion, "must be greater than or equal to `emulationVersion`"))
}
if len(spec.PreferredStrategies) > 0 {
for i, strategy := range spec.PreferredStrategies {
fld := fldPath.Child("preferredStrategies").Index(i)
strategySeen := make(map[coordination.CoordinatedLeaseStrategy]bool)
if _, ok := strategySeen[strategy]; ok {
allErrs = append(allErrs, field.Duplicate(fld, strategy))
} else {
strategySeen[strategy] = true
if spec.Strategy == "" {
allErrs = append(allErrs, field.Required(fldPath.Child("strategy"), ""))
} else {
fld := fldPath.Child("strategy")
if spec.Strategy == coordination.OldestEmulationVersion {
zeroVersion := semver.Version{}
if ev.EQ(zeroVersion) {
allErrs = append(allErrs, field.Required(fldPath.Child("emulationVersion"), "must be specified when `strategy` is 'OldestEmulationVersion'"))
}
if strategy == coordination.OldestEmulationVersion {
zeroVersion := semver.Version{}
if bv.EQ(zeroVersion) {
allErrs = append(allErrs, field.Required(fldPath.Child("binaryVersion"), "must be specified when `strategy` is 'OldestEmulationVersion'"))
}
if ev.EQ(zeroVersion) {
allErrs = append(allErrs, field.Required(fldPath.Child("emulationVersion"), "must be specified when `strategy` is 'OldestEmulationVersion'"))
}
}
allErrs = append(allErrs, ValidateCoordinatedLeaseStrategy(strategy, fld)...)
}
allErrs = append(allErrs, ValidateCoordinatedLeaseStrategy(spec.Strategy, fld)...)
}
// spec.PingTime is a MicroTime and doesn't need further validation
// spec.RenewTime is a MicroTime and doesn't need further validation

View file

@ -171,25 +171,34 @@ func TestValidateLeaseCandidateSpec(t *testing.T) {
"valid",
false,
&coordination.LeaseCandidateSpec{
BinaryVersion: "1.30.0",
EmulationVersion: "1.30.0",
LeaseName: "test",
PreferredStrategies: []coordination.CoordinatedLeaseStrategy{coordination.OldestEmulationVersion},
BinaryVersion: "1.30.0",
EmulationVersion: "1.30.0",
LeaseName: "test",
Strategy: coordination.OldestEmulationVersion,
},
},
{
"valid custom strategy should not require binaryVersion and emulationVersion",
"valid custom strategy should not require emulationVersion",
false,
&coordination.LeaseCandidateSpec{
LeaseName: "test",
PreferredStrategies: []coordination.CoordinatedLeaseStrategy{"custom.com/foo"},
LeaseName: "test",
BinaryVersion: "1.30.0",
Strategy: coordination.CoordinatedLeaseStrategy("custom.com/foo"),
},
},
{
"binaryVersion is required",
true,
&coordination.LeaseCandidateSpec{
LeaseName: "test",
Strategy: coordination.CoordinatedLeaseStrategy("custom.com/foo"),
},
},
{
"no lease name",
true,
&coordination.LeaseCandidateSpec{
BinaryVersion: "1.30.0",
EmulationVersion: "1.30.0",
},
},
@ -211,22 +220,31 @@ func TestValidateLeaseCandidateSpec(t *testing.T) {
},
},
{
"preferredStrategies bad",
"strategy bad",
true,
&coordination.LeaseCandidateSpec{
BinaryVersion: "1.30.1",
EmulationVersion: "1.30.1",
LeaseName: "test",
PreferredStrategies: []coordination.CoordinatedLeaseStrategy{"foo"},
BinaryVersion: "1.30.1",
EmulationVersion: "1.30.1",
LeaseName: "test",
Strategy: coordination.CoordinatedLeaseStrategy("foo"),
},
},
{
"preferredStrategies good but emulationVersion missing",
"strategy missing",
true,
&coordination.LeaseCandidateSpec{
BinaryVersion: "1.30.1",
LeaseName: "test",
PreferredStrategies: []coordination.CoordinatedLeaseStrategy{coordination.OldestEmulationVersion},
BinaryVersion: "1.30.1",
EmulationVersion: "1.30.1",
LeaseName: "test",
},
},
{
"strategy good but emulationVersion missing",
true,
&coordination.LeaseCandidateSpec{
BinaryVersion: "1.30.1",
LeaseName: "test",
Strategy: coordination.OldestEmulationVersion,
},
},
}
@ -255,6 +273,7 @@ func TestValidateLeaseCandidateUpdate(t *testing.T) {
BinaryVersion: "1.30.0",
EmulationVersion: "1.30.0",
LeaseName: "test",
Strategy: coordination.OldestEmulationVersion,
},
},
update: coordination.LeaseCandidate{
@ -262,6 +281,7 @@ func TestValidateLeaseCandidateUpdate(t *testing.T) {
BinaryVersion: "1.30.0",
EmulationVersion: "1.30.0",
LeaseName: "test",
Strategy: coordination.OldestEmulationVersion,
},
},
err: false,
@ -273,6 +293,7 @@ func TestValidateLeaseCandidateUpdate(t *testing.T) {
BinaryVersion: "1.30.0",
EmulationVersion: "1.30.0",
LeaseName: "test",
Strategy: coordination.OldestEmulationVersion,
},
},
update: coordination.LeaseCandidate{
@ -280,6 +301,7 @@ func TestValidateLeaseCandidateUpdate(t *testing.T) {
BinaryVersion: "1.30.0",
EmulationVersion: "1.30.0",
LeaseName: "test-update",
Strategy: coordination.OldestEmulationVersion,
},
},
err: true,

View file

@ -123,11 +123,6 @@ func (in *LeaseCandidateSpec) DeepCopyInto(out *LeaseCandidateSpec) {
in, out := &in.RenewTime, &out.RenewTime
*out = (*in).DeepCopy()
}
if in.PreferredStrategies != nil {
in, out := &in.PreferredStrategies, &out.PreferredStrategies
*out = make([]CoordinatedLeaseStrategy, len(*in))
copy(*out, *in)
}
return
}

View file

@ -284,7 +284,7 @@ func DefaultGenericAPIServicePriorities() map[schema.GroupVersion]APIServicePrio
{Group: "admissionregistration.k8s.io", Version: "v1beta1"}: {Group: 16700, Version: 12},
{Group: "admissionregistration.k8s.io", Version: "v1alpha1"}: {Group: 16700, Version: 9},
{Group: "coordination.k8s.io", Version: "v1"}: {Group: 16500, Version: 15},
{Group: "coordination.k8s.io", Version: "v1alpha1"}: {Group: 16500, Version: 9},
{Group: "coordination.k8s.io", Version: "v1alpha2"}: {Group: 16500, Version: 12},
{Group: "discovery.k8s.io", Version: "v1"}: {Group: 16200, Version: 15},
{Group: "discovery.k8s.io", Version: "v1beta1"}: {Group: 16200, Version: 12},
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1"}: {Group: 16100, Version: 21},

View file

@ -166,7 +166,7 @@ func (c completedConfig) New(name string, delegationTarget genericapiserver.Dele
if utilfeature.DefaultFeatureGate.Enabled(apiserverfeatures.CoordinatedLeaderElection) {
leaseInformer := s.VersionedInformers.Coordination().V1().Leases()
lcInformer := s.VersionedInformers.Coordination().V1alpha1().LeaseCandidates()
lcInformer := s.VersionedInformers.Coordination().V1alpha2().LeaseCandidates()
// Ensure that informers are registered before starting. Coordinated Leader Election leader-elected
// and may register informer handlers after they are started.
_ = leaseInformer.Informer()
@ -177,7 +177,7 @@ func (c completedConfig) New(name string, delegationTarget genericapiserver.Dele
leaseInformer,
lcInformer,
client.CoordinationV1(),
client.CoordinationV1alpha1(),
client.CoordinationV1alpha2(),
)
gccontroller := leaderelection.NewLeaseCandidateGC(
client,

View file

@ -22,12 +22,12 @@ import (
"github.com/blang/semver/v4"
v1 "k8s.io/api/coordination/v1"
v1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
"k8s.io/utils/clock"
)
func pickBestLeaderOldestEmulationVersion(candidates []*v1alpha1.LeaseCandidate) *v1alpha1.LeaseCandidate {
var electee *v1alpha1.LeaseCandidate
func pickBestLeaderOldestEmulationVersion(candidates []*v1alpha2.LeaseCandidate) *v1alpha2.LeaseCandidate {
var electee *v1alpha2.LeaseCandidate
for _, c := range candidates {
if !validLeaseCandidateForOldestEmulationVersion(c) {
continue
@ -39,72 +39,30 @@ func pickBestLeaderOldestEmulationVersion(candidates []*v1alpha1.LeaseCandidate)
return electee
}
// topologicalSortWithOneRoot has a caveat that there may only be one root (indegree=0) node in a valid ordering.
func topologicalSortWithOneRoot(graph map[v1.CoordinatedLeaseStrategy][]v1.CoordinatedLeaseStrategy) []v1.CoordinatedLeaseStrategy {
inDegree := make(map[v1.CoordinatedLeaseStrategy]int)
for node := range graph {
inDegree[node] = 0
}
for _, neighbors := range graph {
for _, neighbor := range neighbors {
inDegree[neighbor]++
}
}
var queue []v1.CoordinatedLeaseStrategy
for vertex, degree := range inDegree {
if degree == 0 {
queue = append(queue, vertex)
}
}
// If multiple nodes have indegree of 0, multiple strategies are non-superceding and is a conflict.
if len(queue) > 1 {
return nil
}
var sorted []v1.CoordinatedLeaseStrategy
for len(queue) > 0 {
vertex := queue[0]
queue = queue[1:]
sorted = append(sorted, vertex)
for _, neighbor := range graph[vertex] {
inDegree[neighbor]--
if inDegree[neighbor] == 0 {
queue = append(queue, neighbor)
}
}
}
if len(sorted) != len(graph) {
return nil // Cycle detected
}
return sorted
}
func pickBestStrategy(candidates []*v1alpha1.LeaseCandidate) (v1.CoordinatedLeaseStrategy, error) {
graph := make(map[v1.CoordinatedLeaseStrategy][]v1.CoordinatedLeaseStrategy)
func pickBestStrategy(candidates []*v1alpha2.LeaseCandidate) (v1.CoordinatedLeaseStrategy, error) {
nilStrategy := v1.CoordinatedLeaseStrategy("")
for _, c := range candidates {
for i := range len(c.Spec.PreferredStrategies) - 1 {
graph[c.Spec.PreferredStrategies[i]] = append(graph[c.Spec.PreferredStrategies[i]], c.Spec.PreferredStrategies[i+1])
}
if _, ok := graph[c.Spec.PreferredStrategies[len(c.Spec.PreferredStrategies)-1]]; !ok {
graph[c.Spec.PreferredStrategies[len(c.Spec.PreferredStrategies)-1]] = []v1.CoordinatedLeaseStrategy{}
if len(candidates) == 0 {
return nilStrategy, fmt.Errorf("no candidates")
}
candidateName := candidates[0].Name
strategy := candidates[0].Spec.Strategy
highestBV := getBinaryVersionOrZero(candidates[0])
for _, c := range candidates[1:] {
binVersion := getBinaryVersionOrZero(c)
result := highestBV.Compare(binVersion)
if result < 0 {
strategy = c.Spec.Strategy
highestBV = binVersion
candidateName = c.Name
} else if result == 0 && c.Spec.Strategy != strategy {
return nilStrategy, fmt.Errorf("candidates %q, %q at same binary version but received differing strategies %s, %s", candidateName, c.Name, strategy, c.Spec.Strategy)
}
}
sorted := topologicalSortWithOneRoot(graph)
if sorted == nil {
return nilStrategy, fmt.Errorf("invalid strategy")
}
return sorted[0], nil
return strategy, nil
}
func validLeaseCandidateForOldestEmulationVersion(l *v1alpha1.LeaseCandidate) bool {
func validLeaseCandidateForOldestEmulationVersion(l *v1alpha2.LeaseCandidate) bool {
_, err := semver.ParseTolerant(l.Spec.EmulationVersion)
if err != nil {
return false
@ -113,7 +71,7 @@ func validLeaseCandidateForOldestEmulationVersion(l *v1alpha1.LeaseCandidate) bo
return err == nil
}
func getEmulationVersionOrZero(l *v1alpha1.LeaseCandidate) semver.Version {
func getEmulationVersionOrZero(l *v1alpha2.LeaseCandidate) semver.Version {
value := l.Spec.EmulationVersion
v, err := semver.ParseTolerant(value)
if err != nil {
@ -122,7 +80,7 @@ func getEmulationVersionOrZero(l *v1alpha1.LeaseCandidate) semver.Version {
return v
}
func getBinaryVersionOrZero(l *v1alpha1.LeaseCandidate) semver.Version {
func getBinaryVersionOrZero(l *v1alpha2.LeaseCandidate) semver.Version {
value := l.Spec.BinaryVersion
v, err := semver.ParseTolerant(value)
if err != nil {
@ -132,7 +90,7 @@ func getBinaryVersionOrZero(l *v1alpha1.LeaseCandidate) semver.Version {
}
// -1: lhs better, 1: rhs better
func compare(lhs, rhs *v1alpha1.LeaseCandidate) int {
func compare(lhs, rhs *v1alpha2.LeaseCandidate) int {
l := getEmulationVersionOrZero(lhs)
r := getEmulationVersionOrZero(rhs)
result := l.Compare(r)
@ -157,7 +115,7 @@ func isLeaseExpired(clock clock.Clock, lease *v1.Lease) bool {
lease.Spec.RenewTime.Add(time.Duration(*lease.Spec.LeaseDurationSeconds)*time.Second).Before(currentTime)
}
func isLeaseCandidateExpired(clock clock.Clock, lease *v1alpha1.LeaseCandidate) bool {
func isLeaseCandidateExpired(clock clock.Clock, lease *v1alpha2.LeaseCandidate) bool {
currentTime := clock.Now()
return lease.Spec.RenewTime == nil ||
lease.Spec.RenewTime.Add(leaseCandidateValidDuration).Before(currentTime)

View file

@ -22,42 +22,42 @@ import (
"github.com/blang/semver/v4"
v1 "k8s.io/api/coordination/v1"
v1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func TestPickBestLeaderOldestEmulationVersion(t *testing.T) {
tests := []struct {
name string
candidates []*v1alpha1.LeaseCandidate
want *v1alpha1.LeaseCandidate
candidates []*v1alpha2.LeaseCandidate
want *v1alpha2.LeaseCandidate
}{
{
name: "empty",
candidates: []*v1alpha1.LeaseCandidate{},
candidates: []*v1alpha2.LeaseCandidate{},
want: nil,
},
{
name: "single candidate",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.1.0",
},
},
},
want: &v1alpha1.LeaseCandidate{
want: &v1alpha2.LeaseCandidate{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.1.0",
},
@ -65,14 +65,14 @@ func TestPickBestLeaderOldestEmulationVersion(t *testing.T) {
},
{
name: "multiple candidates, different emulation versions",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-1 * time.Hour)},
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.1.0",
},
@ -83,18 +83,18 @@ func TestPickBestLeaderOldestEmulationVersion(t *testing.T) {
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.2.0",
BinaryVersion: "0.2.0",
},
},
},
want: &v1alpha1.LeaseCandidate{
want: &v1alpha2.LeaseCandidate{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "v1",
BinaryVersion: "v1",
},
@ -102,14 +102,14 @@ func TestPickBestLeaderOldestEmulationVersion(t *testing.T) {
},
{
name: "multiple candidates, same emulation versions, different binary versions",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-1 * time.Hour)},
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.1.0",
},
@ -120,18 +120,18 @@ func TestPickBestLeaderOldestEmulationVersion(t *testing.T) {
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.2.0",
},
},
},
want: &v1alpha1.LeaseCandidate{
want: &v1alpha2.LeaseCandidate{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.1.0",
},
@ -139,14 +139,14 @@ func TestPickBestLeaderOldestEmulationVersion(t *testing.T) {
},
{
name: "multiple candidates, same emulation versions, same binary versions, different creation timestamps",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-1 * time.Hour)},
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.1.0",
},
@ -157,18 +157,18 @@ func TestPickBestLeaderOldestEmulationVersion(t *testing.T) {
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.1.0",
},
},
},
want: &v1alpha1.LeaseCandidate{
want: &v1alpha2.LeaseCandidate{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.1.0",
},
@ -192,13 +192,13 @@ func TestPickBestLeaderOldestEmulationVersion(t *testing.T) {
func TestValidLeaseCandidateForOldestEmulationVersion(t *testing.T) {
tests := []struct {
name string
candidate *v1alpha1.LeaseCandidate
candidate *v1alpha2.LeaseCandidate
want bool
}{
{
name: "valid emulation and binary versions",
candidate: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
candidate: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "0.1.0",
},
@ -207,8 +207,8 @@ func TestValidLeaseCandidateForOldestEmulationVersion(t *testing.T) {
},
{
name: "invalid emulation version",
candidate: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
candidate: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "invalid",
BinaryVersion: "0.1.0",
},
@ -217,8 +217,8 @@ func TestValidLeaseCandidateForOldestEmulationVersion(t *testing.T) {
},
{
name: "invalid binary version",
candidate: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
candidate: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
BinaryVersion: "invalid",
},
@ -239,13 +239,13 @@ func TestValidLeaseCandidateForOldestEmulationVersion(t *testing.T) {
func TestGetEmulationVersion(t *testing.T) {
tests := []struct {
name string
candidate *v1alpha1.LeaseCandidate
candidate *v1alpha2.LeaseCandidate
want semver.Version
}{
{
name: "valid emulation version",
candidate: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
candidate: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "0.1.0",
},
},
@ -265,13 +265,13 @@ func TestGetEmulationVersion(t *testing.T) {
func TestGetBinaryVersion(t *testing.T) {
tests := []struct {
name string
candidate *v1alpha1.LeaseCandidate
candidate *v1alpha2.LeaseCandidate
want semver.Version
}{
{
name: "valid binary version",
candidate: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
candidate: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
BinaryVersion: "0.3.0",
},
},
@ -292,14 +292,14 @@ func TestCompare(t *testing.T) {
nowTime := time.Now()
cases := []struct {
name string
lhs *v1alpha1.LeaseCandidate
rhs *v1alpha1.LeaseCandidate
lhs *v1alpha2.LeaseCandidate
rhs *v1alpha2.LeaseCandidate
expectedResult int
}{
{
name: "identical versions earlier timestamp",
lhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
lhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.20.0",
BinaryVersion: "1.21.0",
},
@ -307,8 +307,8 @@ func TestCompare(t *testing.T) {
CreationTimestamp: metav1.Time{Time: nowTime.Add(time.Duration(1))},
},
},
rhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
rhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.20.0",
BinaryVersion: "1.21.0",
},
@ -320,9 +320,9 @@ func TestCompare(t *testing.T) {
},
{
name: "no lhs version",
lhs: &v1alpha1.LeaseCandidate{},
rhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
lhs: &v1alpha2.LeaseCandidate{},
rhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.20.0",
BinaryVersion: "1.21.0",
},
@ -331,25 +331,25 @@ func TestCompare(t *testing.T) {
},
{
name: "no rhs version",
lhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
lhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.20.0",
BinaryVersion: "1.21.0",
},
},
rhs: &v1alpha1.LeaseCandidate{},
rhs: &v1alpha2.LeaseCandidate{},
expectedResult: 1,
},
{
name: "invalid lhs version",
lhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
lhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "xyz",
BinaryVersion: "xyz",
},
},
rhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
rhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.20.0",
BinaryVersion: "1.21.0",
},
@ -358,14 +358,14 @@ func TestCompare(t *testing.T) {
},
{
name: "invalid rhs version",
lhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
lhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.20.0",
BinaryVersion: "1.21.0",
},
},
rhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
rhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "xyz",
BinaryVersion: "xyz",
},
@ -374,14 +374,14 @@ func TestCompare(t *testing.T) {
},
{
name: "lhs less than rhs",
lhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
lhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.20.0",
},
},
rhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
rhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.20.0",
BinaryVersion: "1.20.0",
},
@ -390,14 +390,14 @@ func TestCompare(t *testing.T) {
},
{
name: "rhs less than lhs",
lhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
lhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.20.0",
BinaryVersion: "1.20.0",
},
},
rhs: &v1alpha1.LeaseCandidate{
Spec: v1alpha1.LeaseCandidateSpec{
rhs: &v1alpha2.LeaseCandidate{
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.20.0",
},
@ -418,93 +418,93 @@ func TestCompare(t *testing.T) {
func TestShouldReelect(t *testing.T) {
cases := []struct {
name string
candidates []*v1alpha1.LeaseCandidate
currentLeader *v1alpha1.LeaseCandidate
candidates []*v1alpha2.LeaseCandidate
currentLeader *v1alpha2.LeaseCandidate
expectResult bool
}{
{
name: "candidate with newer binary version",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
Strategy: v1.OldestEmulationVersion,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "component-identity-2",
},
Spec: v1alpha1.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.20.0",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.20.0",
Strategy: v1.OldestEmulationVersion,
},
},
},
currentLeader: &v1alpha1.LeaseCandidate{
currentLeader: &v1alpha2.LeaseCandidate{
ObjectMeta: metav1.ObjectMeta{
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
Strategy: v1.OldestEmulationVersion,
},
},
expectResult: false,
},
{
name: "no newer candidates",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
Strategy: v1.OldestEmulationVersion,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "component-identity-2",
},
Spec: v1alpha1.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
Strategy: v1.OldestEmulationVersion,
},
},
},
currentLeader: &v1alpha1.LeaseCandidate{
currentLeader: &v1alpha2.LeaseCandidate{
ObjectMeta: metav1.ObjectMeta{
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
Strategy: v1.OldestEmulationVersion,
},
},
expectResult: false,
},
{
name: "no candidates",
candidates: []*v1alpha1.LeaseCandidate{},
currentLeader: &v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{},
currentLeader: &v1alpha2.LeaseCandidate{
ObjectMeta: metav1.ObjectMeta{
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
Strategy: v1.OldestEmulationVersion,
},
},
expectResult: false,
@ -520,68 +520,24 @@ func TestShouldReelect(t *testing.T) {
}
}
func TestTopologicalSortWithOneRoot(t *testing.T) {
tests := []struct {
name string
graph map[v1.CoordinatedLeaseStrategy][]v1.CoordinatedLeaseStrategy
want []v1.CoordinatedLeaseStrategy
}{
{
name: "simple DAG",
graph: map[v1.CoordinatedLeaseStrategy][]v1.CoordinatedLeaseStrategy{
v1.OldestEmulationVersion: {"foo"},
"foo": {"bar"},
"bar": {},
},
want: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion, "foo", "bar"},
},
{
name: "cycle",
graph: map[v1.CoordinatedLeaseStrategy][]v1.CoordinatedLeaseStrategy{
v1.OldestEmulationVersion: {"foo"},
"foo": {v1.OldestEmulationVersion},
},
want: nil,
},
{
name: "multiple",
graph: map[v1.CoordinatedLeaseStrategy][]v1.CoordinatedLeaseStrategy{
v1.OldestEmulationVersion: {"foo", "baz"},
"foo": {"baz"},
"baz": {},
},
want: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion, "foo", "baz"},
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
got := topologicalSortWithOneRoot(tc.graph)
if !equalStrategies(got, tc.want) {
t.Errorf("topologicalSortWithOneRoot() = %v, want %v", got, tc.want)
}
})
}
}
func TestPickBestStrategy(t *testing.T) {
tests := []struct {
name string
candidates []*v1alpha1.LeaseCandidate
candidates []*v1alpha2.LeaseCandidate
wantStrategy v1.CoordinatedLeaseStrategy
wantError bool
}{
{
name: "single candidate, single preferred strategy",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -590,15 +546,15 @@ func TestPickBestStrategy(t *testing.T) {
},
{
name: "multiple candidates, different preferred strategies should fail",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -606,25 +562,26 @@ func TestPickBestStrategy(t *testing.T) {
Name: "candidate2",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{"foo.com/bar"},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
Strategy: v1.CoordinatedLeaseStrategy("foo.com/bar"),
},
},
},
wantError: true,
},
{
name: "multiple candidates, multiple resolved preferred strategy",
candidates: []*v1alpha1.LeaseCandidate{
name: "multiple candidates, different preferred strategy different binary version should resolve",
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion, "foo.com/bar"},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.32.0",
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -632,9 +589,10 @@ func TestPickBestStrategy(t *testing.T) {
Name: "candidate2",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{"foo.com/bar"},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.31.0",
Strategy: v1.CoordinatedLeaseStrategy("foo.com/bar"),
},
},
},
@ -642,16 +600,46 @@ func TestPickBestStrategy(t *testing.T) {
wantError: false,
},
{
name: "multiple candidates, same preferred strategy",
candidates: []*v1alpha1.LeaseCandidate{
name: "multiple candidates, different preferred strategy different binary version should resolve, order agnostic",
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate2",
Namespace: "default",
},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.31.0",
Strategy: v1.CoordinatedLeaseStrategy("foo.com/bar"),
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.32.0",
Strategy: v1.OldestEmulationVersion,
},
},
},
wantStrategy: v1.OldestEmulationVersion,
wantError: false,
},
{
name: "multiple candidates, different preferred strategy different binary version string comparison check",
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.1.10",
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -659,9 +647,40 @@ func TestPickBestStrategy(t *testing.T) {
Name: "candidate2",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.1.2",
Strategy: v1.CoordinatedLeaseStrategy("foo.com/bar"),
},
},
},
wantStrategy: v1.OldestEmulationVersion,
wantError: false,
},
{
name: "multiple candidates, same preferred strategy",
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.31.0",
Strategy: v1.OldestEmulationVersion,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate2",
Namespace: "default",
},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.31.0",
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -670,15 +689,16 @@ func TestPickBestStrategy(t *testing.T) {
},
{
name: "multiple candidates, conflicting preferred strategy",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.31.0",
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -686,41 +706,16 @@ func TestPickBestStrategy(t *testing.T) {
Name: "candidate2",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{"foo.com/bar"},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
BinaryVersion: "1.31.0",
Strategy: v1.CoordinatedLeaseStrategy("foo.com/bar"),
},
},
},
wantStrategy: "",
wantError: true,
},
{
name: "multiple candidates, cycle in preferred strategies",
candidates: []*v1alpha1.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{"foo.com/bar", v1.OldestEmulationVersion},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate2",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion, "foo.com/bar"},
},
},
},
wantError: true,
},
}
for _, tc := range tests {
@ -737,19 +732,7 @@ func TestPickBestStrategy(t *testing.T) {
}
}
func equalStrategies(s1, s2 []v1.CoordinatedLeaseStrategy) bool {
if len(s1) != len(s2) {
return false
}
for i := range s1 {
if s1[i] != s2[i] {
return false
}
}
return true
}
func shouldReelect(candidates []*v1alpha1.LeaseCandidate, currentLeader *v1alpha1.LeaseCandidate) bool {
func shouldReelect(candidates []*v1alpha2.LeaseCandidate, currentLeader *v1alpha2.LeaseCandidate) bool {
pickedLeader := pickBestLeaderOldestEmulationVersion(candidates)
if pickedLeader == nil {
return false

View file

@ -23,7 +23,7 @@ import (
"time"
v1 "k8s.io/api/coordination/v1"
v1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
@ -31,9 +31,9 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
coordinationv1informers "k8s.io/client-go/informers/coordination/v1"
coordinationv1alpha1 "k8s.io/client-go/informers/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/client-go/informers/coordination/v1alpha2"
coordinationv1client "k8s.io/client-go/kubernetes/typed/coordination/v1"
coordinationv1alpha1client "k8s.io/client-go/kubernetes/typed/coordination/v1alpha1"
coordinationv1alpha2client "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
@ -64,8 +64,8 @@ type Controller struct {
leaseClient coordinationv1client.CoordinationV1Interface
leaseRegistration cache.ResourceEventHandlerRegistration
leaseCandidateInformer coordinationv1alpha1.LeaseCandidateInformer
leaseCandidateClient coordinationv1alpha1client.CoordinationV1alpha1Interface
leaseCandidateInformer coordinationv1alpha2.LeaseCandidateInformer
leaseCandidateClient coordinationv1alpha2client.CoordinationV1alpha2Interface
leaseCandidateRegistration cache.ResourceEventHandlerRegistration
queue workqueue.TypedRateLimitingInterface[types.NamespacedName]
@ -109,7 +109,7 @@ func (c *Controller) Run(ctx context.Context, workers int) {
<-ctx.Done()
}
func NewController(leaseInformer coordinationv1informers.LeaseInformer, leaseCandidateInformer coordinationv1alpha1.LeaseCandidateInformer, leaseClient coordinationv1client.CoordinationV1Interface, leaseCandidateClient coordinationv1alpha1client.CoordinationV1alpha1Interface) (*Controller, error) {
func NewController(leaseInformer coordinationv1informers.LeaseInformer, leaseCandidateInformer coordinationv1alpha2.LeaseCandidateInformer, leaseClient coordinationv1client.CoordinationV1Interface, leaseCandidateClient coordinationv1alpha2client.CoordinationV1alpha2Interface) (*Controller, error) {
c := &Controller{
leaseInformer: leaseInformer,
leaseCandidateInformer: leaseCandidateInformer,
@ -174,7 +174,7 @@ func (c *Controller) processNextElectionItem(ctx context.Context) bool {
}
func (c *Controller) enqueueCandidate(obj any) {
lc, ok := obj.(*v1alpha1.LeaseCandidate)
lc, ok := obj.(*v1alpha2.LeaseCandidate)
if !ok {
return
}
@ -196,7 +196,7 @@ func (c *Controller) enqueueLease(obj any) {
c.queue.Add(types.NamespacedName{Namespace: lease.Namespace, Name: lease.Name})
}
func (c *Controller) electionNeeded(candidates []*v1alpha1.LeaseCandidate, leaseNN types.NamespacedName) (bool, error) {
func (c *Controller) electionNeeded(candidates []*v1alpha2.LeaseCandidate, leaseNN types.NamespacedName) (bool, error) {
lease, err := c.leaseInformer.Lister().Leases(leaseNN.Namespace).Get(leaseNN.Name)
if err != nil && !apierrors.IsNotFound(err) {
return false, fmt.Errorf("error reading lease: %w", err)
@ -313,7 +313,7 @@ func (c *Controller) reconcileElectionStep(ctx context.Context, leaseNN types.Na
}
}
var ackedCandidates []*v1alpha1.LeaseCandidate
var ackedCandidates []*v1alpha2.LeaseCandidate
for _, candidate := range candidates {
if candidate.Spec.RenewTime.Add(electionDuration).After(now) {
ackedCandidates = append(ackedCandidates, candidate)
@ -415,12 +415,12 @@ func (c *Controller) reconcileElectionStep(ctx context.Context, leaseNN types.Na
return defaultRequeueInterval, nil
}
func (c *Controller) listAdmissableCandidates(leaseNN types.NamespacedName) ([]*v1alpha1.LeaseCandidate, error) {
func (c *Controller) listAdmissableCandidates(leaseNN types.NamespacedName) ([]*v1alpha2.LeaseCandidate, error) {
leases, err := c.leaseCandidateInformer.Lister().LeaseCandidates(leaseNN.Namespace).List(labels.Everything())
if err != nil {
return nil, err
}
var results []*v1alpha1.LeaseCandidate
var results []*v1alpha2.LeaseCandidate
for _, l := range leases {
if l.Spec.LeaseName != leaseNN.Name {
continue

View file

@ -25,7 +25,7 @@ import (
"time"
v1 "k8s.io/api/coordination/v1"
v1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
@ -42,7 +42,7 @@ func TestReconcileElectionStep(t *testing.T) {
tests := []struct {
name string
leaseNN types.NamespacedName
candidates []*v1alpha1.LeaseCandidate
candidates []*v1alpha2.LeaseCandidate
existingLease *v1.Lease
expectLease bool
expectedHolderIdentity *string
@ -55,7 +55,7 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "no candidates, no lease, noop",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{},
candidates: []*v1alpha2.LeaseCandidate{},
existingLease: nil,
expectLease: false,
expectedHolderIdentity: nil,
@ -66,7 +66,7 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "no candidates, lease exists. noop, not managed by CLE",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{},
candidates: []*v1alpha2.LeaseCandidate{},
existingLease: &v1.Lease{},
expectLease: false,
expectedHolderIdentity: nil,
@ -77,18 +77,18 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "candidates exist, no existing lease should create lease",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -102,18 +102,18 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "candidates exist, lease exists, unoptimal should set preferredHolder",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -121,12 +121,12 @@ func TestReconcileElectionStep(t *testing.T) {
Namespace: "default",
Name: "component-identity-2",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.18.0",
BinaryVersion: "1.18.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.18.0",
BinaryVersion: "1.18.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -151,19 +151,19 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "candidates exist, should only elect leader from acked candidates",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PingTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-2 * electionDuration))),
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-4 * electionDuration))),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PingTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-2 * electionDuration))),
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-4 * electionDuration))),
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -171,13 +171,13 @@ func TestReconcileElectionStep(t *testing.T) {
Namespace: "default",
Name: "component-identity-2",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.20.0",
BinaryVersion: "1.20.0",
PingTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.20.0",
BinaryVersion: "1.20.0",
PingTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -191,18 +191,18 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "candidates exist, lease exists, lease expired",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -226,19 +226,19 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "candidates exist, no acked candidates should return error",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PingTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-1 * time.Minute))),
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-2 * time.Minute))),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PingTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-1 * time.Minute))),
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-2 * time.Minute))),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -251,18 +251,18 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "candidates exist, should ping on election",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-2 * electionDuration))),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-2 * electionDuration))),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -277,19 +277,19 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "candidate exist, pinged candidate should have until electionDuration until election decision is made",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PingTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-1 * time.Minute))),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
PingTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now().Add(-1 * time.Minute))),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -302,18 +302,18 @@ func TestReconcileElectionStep(t *testing.T) {
{
name: "candidates exist, lease exists, lease expired, 3rdparty strategy",
leaseNN: types.NamespacedName{Namespace: "default", Name: "component-A"},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{"foo.com/bar"},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(fakeClock.Now())),
Strategy: v1.CoordinatedLeaseStrategy("foo.com/bar"),
},
},
},
@ -344,9 +344,9 @@ func TestReconcileElectionStep(t *testing.T) {
controller, err := NewController(
informerFactory.Coordination().V1().Leases(),
informerFactory.Coordination().V1alpha1().LeaseCandidates(),
informerFactory.Coordination().V1alpha2().LeaseCandidates(),
client.CoordinationV1(),
client.CoordinationV1alpha1(),
client.CoordinationV1alpha2(),
)
controller.clock = fakeClock
if err != nil {
@ -363,7 +363,7 @@ func TestReconcileElectionStep(t *testing.T) {
// Set up the fake client with the candidates
for _, candidate := range tc.candidates {
_, err = client.CoordinationV1alpha1().LeaseCandidates(candidate.Namespace).Create(ctx, candidate, metav1.CreateOptions{})
_, err = client.CoordinationV1alpha2().LeaseCandidates(candidate.Namespace).Create(ctx, candidate, metav1.CreateOptions{})
if err != nil {
t.Fatal(err)
}
@ -414,11 +414,11 @@ func TestReconcileElectionStep(t *testing.T) {
// Verify that ping to candidate was issued
if tc.candidatesPinged {
pinged := false
candidatesList, err := client.CoordinationV1alpha1().LeaseCandidates(tc.leaseNN.Namespace).List(ctx, metav1.ListOptions{})
candidatesList, err := client.CoordinationV1alpha2().LeaseCandidates(tc.leaseNN.Namespace).List(ctx, metav1.ListOptions{})
if err != nil {
t.Fatal(err)
}
oldCandidateMap := make(map[string]*v1alpha1.LeaseCandidate)
oldCandidateMap := make(map[string]*v1alpha2.LeaseCandidate)
for _, candidate := range tc.candidates {
oldCandidateMap[candidate.Name] = candidate
}
@ -443,25 +443,25 @@ func TestController(t *testing.T) {
cases := []struct {
name string
leases []*v1.Lease
candidates []*v1alpha1.LeaseCandidate
createAfterControllerStart []*v1alpha1.LeaseCandidate
candidates []*v1alpha2.LeaseCandidate
createAfterControllerStart []*v1alpha2.LeaseCandidate
deleteLeaseAfterControllerStart []types.NamespacedName
expectedLeaderLeases []*v1.Lease
}{
{
name: "single candidate leader election",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -479,18 +479,18 @@ func TestController(t *testing.T) {
},
{
name: "multiple candidate leader election",
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -498,12 +498,12 @@ func TestController(t *testing.T) {
Namespace: "kube-system",
Name: "component-identity-2",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.20.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.20.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -511,12 +511,12 @@ func TestController(t *testing.T) {
Namespace: "kube-system",
Name: "component-identity-3",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.20.0",
BinaryVersion: "1.20.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.20.0",
BinaryVersion: "1.20.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -547,18 +547,18 @@ func TestController(t *testing.T) {
},
},
},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -593,18 +593,18 @@ func TestController(t *testing.T) {
},
},
},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -636,33 +636,33 @@ func TestController(t *testing.T) {
},
},
},
candidates: []*v1alpha1.LeaseCandidate{
candidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "component-identity-1",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.20.0",
BinaryVersion: "1.20.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.20.0",
BinaryVersion: "1.20.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
createAfterControllerStart: []*v1alpha1.LeaseCandidate{
createAfterControllerStart: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "component-identity-2",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -693,9 +693,9 @@ func TestController(t *testing.T) {
informerFactory := informers.NewSharedInformerFactory(client, 0)
controller, err := NewController(
informerFactory.Coordination().V1().Leases(),
informerFactory.Coordination().V1alpha1().LeaseCandidates(),
informerFactory.Coordination().V1alpha2().LeaseCandidates(),
client.CoordinationV1(),
client.CoordinationV1alpha1(),
client.CoordinationV1alpha2(),
)
if err != nil {
t.Fatal(err)
@ -710,7 +710,7 @@ func TestController(t *testing.T) {
}
for _, obj := range tc.candidates {
t.Logf("Pre-creating lease candidate %s/%s", obj.Namespace, obj.Name)
_, err := client.CoordinationV1alpha1().LeaseCandidates(obj.Namespace).Create(ctx, obj, metav1.CreateOptions{})
_, err := client.CoordinationV1alpha2().LeaseCandidates(obj.Namespace).Create(ctx, obj, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Error pre-creating lease candidate %s/%s: %v", obj.Namespace, obj.Name, err)
}
@ -748,7 +748,7 @@ func TestController(t *testing.T) {
if *ph == *l.Spec.HolderIdentity {
continue
}
if _, err := client.CoordinationV1alpha1().LeaseCandidates(expectedLease.Namespace).Get(ctx, *l.Spec.HolderIdentity, metav1.GetOptions{}); err != nil {
if _, err := client.CoordinationV1alpha2().LeaseCandidates(expectedLease.Namespace).Get(ctx, *l.Spec.HolderIdentity, metav1.GetOptions{}); err != nil {
continue // only candidate-aware controllers will follow preferredHolder
}
@ -772,7 +772,7 @@ func TestController(t *testing.T) {
case <-ctx.Done():
return
case <-ticker.C:
cs, err := client.CoordinationV1alpha1().LeaseCandidates("").List(ctx, metav1.ListOptions{})
cs, err := client.CoordinationV1alpha2().LeaseCandidates("").List(ctx, metav1.ListOptions{})
if err != nil {
t.Logf("Error listing lease candidates: %v", err)
continue
@ -781,7 +781,7 @@ func TestController(t *testing.T) {
if c.Spec.PingTime != nil && (c.Spec.RenewTime == nil || c.Spec.PingTime.Time.After(c.Spec.RenewTime.Time)) {
t.Logf("Answering ping for %s/%s", c.Namespace, c.Name)
c.Spec.RenewTime = &metav1.MicroTime{Time: time.Now()}
_, err = client.CoordinationV1alpha1().LeaseCandidates(c.Namespace).Update(ctx, &c, metav1.UpdateOptions{})
_, err = client.CoordinationV1alpha2().LeaseCandidates(c.Namespace).Update(ctx, &c, metav1.UpdateOptions{})
if err != nil {
t.Logf("Error updating lease candidate %s/%s: %v", c.Namespace, c.Name, err)
}
@ -793,7 +793,7 @@ func TestController(t *testing.T) {
for _, obj := range tc.createAfterControllerStart {
t.Logf("Post-creating lease candidate %s/%s", obj.Namespace, obj.Name)
_, err := client.CoordinationV1alpha1().LeaseCandidates(obj.Namespace).Create(ctx, obj, metav1.CreateOptions{})
_, err := client.CoordinationV1alpha2().LeaseCandidates(obj.Namespace).Create(ctx, obj, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Error post-creating lease candidate %s/%s: %v", obj.Namespace, obj.Name, err)
}

View file

@ -26,9 +26,9 @@ import (
"k8s.io/apimachinery/pkg/labels"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
coordinationv1alpha1informers "k8s.io/client-go/informers/coordination/v1alpha1"
coordinationv1alpha2informers "k8s.io/client-go/informers/coordination/v1alpha2"
"k8s.io/client-go/kubernetes"
listers "k8s.io/client-go/listers/coordination/v1alpha1"
listers "k8s.io/client-go/listers/coordination/v1alpha2"
"k8s.io/client-go/tools/cache"
"k8s.io/utils/clock"
@ -39,7 +39,7 @@ type LeaseCandidateGCController struct {
kubeclientset kubernetes.Interface
leaseCandidateLister listers.LeaseCandidateLister
leaseCandidateInformer coordinationv1alpha1informers.LeaseCandidateInformer
leaseCandidateInformer coordinationv1alpha2informers.LeaseCandidateInformer
leaseCandidatesSynced cache.InformerSynced
gcCheckPeriod time.Duration
@ -48,7 +48,7 @@ type LeaseCandidateGCController struct {
}
// NewLeaseCandidateGC creates a new LeaseCandidateGCController.
func NewLeaseCandidateGC(clientset kubernetes.Interface, gcCheckPeriod time.Duration, leaseCandidateInformer coordinationv1alpha1informers.LeaseCandidateInformer) *LeaseCandidateGCController {
func NewLeaseCandidateGC(clientset kubernetes.Interface, gcCheckPeriod time.Duration, leaseCandidateInformer coordinationv1alpha2informers.LeaseCandidateInformer) *LeaseCandidateGCController {
return &LeaseCandidateGCController{
kubeclientset: clientset,
leaseCandidateLister: leaseCandidateInformer.Lister(),
@ -87,7 +87,7 @@ func (c *LeaseCandidateGCController) gc(ctx context.Context) {
if !isLeaseCandidateExpired(c.clock, leaseCandidate) {
continue
}
lc, err := c.kubeclientset.CoordinationV1alpha1().LeaseCandidates(leaseCandidate.Namespace).Get(ctx, leaseCandidate.Name, metav1.GetOptions{})
lc, err := c.kubeclientset.CoordinationV1alpha2().LeaseCandidates(leaseCandidate.Namespace).Get(ctx, leaseCandidate.Name, metav1.GetOptions{})
if err != nil {
klog.ErrorS(err, "Error getting lc")
continue
@ -96,7 +96,7 @@ func (c *LeaseCandidateGCController) gc(ctx context.Context) {
if !isLeaseCandidateExpired(c.clock, lc) {
continue
}
if err := c.kubeclientset.CoordinationV1alpha1().LeaseCandidates(lc.Namespace).Delete(
if err := c.kubeclientset.CoordinationV1alpha2().LeaseCandidates(lc.Namespace).Delete(
ctx, lc.Name, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) {
klog.ErrorS(err, "Error deleting lease")
}

View file

@ -22,7 +22,7 @@ import (
"time"
v1 "k8s.io/api/coordination/v1"
v1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/informers"
@ -33,24 +33,24 @@ import (
func TestLeaseCandidateGCController(t *testing.T) {
tests := []struct {
name string
leaseCandidates []*v1alpha1.LeaseCandidate
leaseCandidates []*v1alpha2.LeaseCandidate
expectedDeletedCount int
}{
{
name: "delete expired lease candidates",
leaseCandidates: []*v1alpha1.LeaseCandidate{
leaseCandidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-1 * leaseCandidateValidDuration)},
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now().Add(-1 * leaseCandidateValidDuration))),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now().Add(-1 * leaseCandidateValidDuration))),
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -59,12 +59,12 @@ func TestLeaseCandidateGCController(t *testing.T) {
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-1 * leaseCandidateValidDuration)},
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-B",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now().Add(-1 * leaseCandidateValidDuration))),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-B",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now().Add(-1 * leaseCandidateValidDuration))),
Strategy: v1.OldestEmulationVersion,
},
},
{
@ -73,12 +73,12 @@ func TestLeaseCandidateGCController(t *testing.T) {
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-C",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-C",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -86,19 +86,19 @@ func TestLeaseCandidateGCController(t *testing.T) {
},
{
name: "no expired lease candidates",
leaseCandidates: []*v1alpha1.LeaseCandidate{
leaseCandidates: []*v1alpha2.LeaseCandidate{
{
ObjectMeta: metav1.ObjectMeta{
Name: "candidate1",
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "component-A",
EmulationVersion: "1.19.0",
BinaryVersion: "1.19.0",
RenewTime: ptr.To(metav1.NewMicroTime(time.Now())),
Strategy: v1.OldestEmulationVersion,
},
},
},
@ -111,12 +111,12 @@ func TestLeaseCandidateGCController(t *testing.T) {
ctx := context.Background()
client := fake.NewSimpleClientset()
informerFactory := informers.NewSharedInformerFactory(client, 0)
leaseCandidateInformer := informerFactory.Coordination().V1alpha1().LeaseCandidates()
leaseCandidateInformer := informerFactory.Coordination().V1alpha2().LeaseCandidates()
controller := NewLeaseCandidateGC(client, 10*time.Millisecond, leaseCandidateInformer)
// Create lease candidates
for _, lc := range tc.leaseCandidates {
_, err := client.CoordinationV1alpha1().LeaseCandidates(lc.Namespace).Create(ctx, lc, metav1.CreateOptions{})
_, err := client.CoordinationV1alpha2().LeaseCandidates(lc.Namespace).Create(ctx, lc, metav1.CreateOptions{})
if err != nil {
t.Fatal(err)
}
@ -127,7 +127,7 @@ func TestLeaseCandidateGCController(t *testing.T) {
go controller.Run(ctx)
err := wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, 600*time.Second, true, func(ctx context.Context) (done bool, err error) {
lcs, err := client.CoordinationV1alpha1().LeaseCandidates("default").List(ctx, metav1.ListOptions{})
lcs, err := client.CoordinationV1alpha2().LeaseCandidates("default").List(ctx, metav1.ListOptions{})
if err != nil {
return true, err
}

View file

@ -38,7 +38,7 @@ import (
certificatesapiv1 "k8s.io/api/certificates/v1"
certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1"
coordinationapiv1 "k8s.io/api/coordination/v1"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
apiv1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
eventsv1 "k8s.io/api/events/v1"
@ -471,7 +471,7 @@ var (
apiserverinternalv1alpha1.SchemeGroupVersion,
authenticationv1alpha1.SchemeGroupVersion,
apiserverinternalv1alpha1.SchemeGroupVersion,
coordinationv1alpha1.SchemeGroupVersion,
coordinationv1alpha2.SchemeGroupVersion,
resourcev1alpha3.SchemeGroupVersion,
certificatesv1alpha1.SchemeGroupVersion,
networkingapiv1alpha1.SchemeGroupVersion,

View file

@ -385,9 +385,9 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"k8s.io/api/coordination/v1.Lease": schema_k8sio_api_coordination_v1_Lease(ref),
"k8s.io/api/coordination/v1.LeaseList": schema_k8sio_api_coordination_v1_LeaseList(ref),
"k8s.io/api/coordination/v1.LeaseSpec": schema_k8sio_api_coordination_v1_LeaseSpec(ref),
"k8s.io/api/coordination/v1alpha1.LeaseCandidate": schema_k8sio_api_coordination_v1alpha1_LeaseCandidate(ref),
"k8s.io/api/coordination/v1alpha1.LeaseCandidateList": schema_k8sio_api_coordination_v1alpha1_LeaseCandidateList(ref),
"k8s.io/api/coordination/v1alpha1.LeaseCandidateSpec": schema_k8sio_api_coordination_v1alpha1_LeaseCandidateSpec(ref),
"k8s.io/api/coordination/v1alpha2.LeaseCandidate": schema_k8sio_api_coordination_v1alpha2_LeaseCandidate(ref),
"k8s.io/api/coordination/v1alpha2.LeaseCandidateList": schema_k8sio_api_coordination_v1alpha2_LeaseCandidateList(ref),
"k8s.io/api/coordination/v1alpha2.LeaseCandidateSpec": schema_k8sio_api_coordination_v1alpha2_LeaseCandidateSpec(ref),
"k8s.io/api/coordination/v1beta1.Lease": schema_k8sio_api_coordination_v1beta1_Lease(ref),
"k8s.io/api/coordination/v1beta1.LeaseList": schema_k8sio_api_coordination_v1beta1_LeaseList(ref),
"k8s.io/api/coordination/v1beta1.LeaseSpec": schema_k8sio_api_coordination_v1beta1_LeaseSpec(ref),
@ -19345,7 +19345,7 @@ func schema_k8sio_api_coordination_v1_LeaseSpec(ref common.ReferenceCallback) co
}
}
func schema_k8sio_api_coordination_v1alpha1_LeaseCandidate(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_k8sio_api_coordination_v1alpha2_LeaseCandidate(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -19377,18 +19377,18 @@ func schema_k8sio_api_coordination_v1alpha1_LeaseCandidate(ref common.ReferenceC
SchemaProps: spec.SchemaProps{
Description: "spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status",
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/coordination/v1alpha1.LeaseCandidateSpec"),
Ref: ref("k8s.io/api/coordination/v1alpha2.LeaseCandidateSpec"),
},
},
},
},
},
Dependencies: []string{
"k8s.io/api/coordination/v1alpha1.LeaseCandidateSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
"k8s.io/api/coordination/v1alpha2.LeaseCandidateSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_k8sio_api_coordination_v1alpha1_LeaseCandidateList(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_k8sio_api_coordination_v1alpha2_LeaseCandidateList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -19424,7 +19424,7 @@ func schema_k8sio_api_coordination_v1alpha1_LeaseCandidateList(ref common.Refere
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/coordination/v1alpha1.LeaseCandidate"),
Ref: ref("k8s.io/api/coordination/v1alpha2.LeaseCandidate"),
},
},
},
@ -19435,11 +19435,11 @@ func schema_k8sio_api_coordination_v1alpha1_LeaseCandidateList(ref common.Refere
},
},
Dependencies: []string{
"k8s.io/api/coordination/v1alpha1.LeaseCandidate", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
"k8s.io/api/coordination/v1alpha2.LeaseCandidate", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_k8sio_api_coordination_v1alpha1_LeaseCandidateSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_k8sio_api_coordination_v1alpha2_LeaseCandidateSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -19468,7 +19468,8 @@ func schema_k8sio_api_coordination_v1alpha1_LeaseCandidateSpec(ref common.Refere
},
"binaryVersion": {
SchemaProps: spec.SchemaProps{
Description: "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required when strategy is \"OldestEmulationVersion\"",
Description: "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.",
Default: "",
Type: []string{"string"},
Format: "",
},
@ -19480,28 +19481,15 @@ func schema_k8sio_api_coordination_v1alpha1_LeaseCandidateSpec(ref common.Refere
Format: "",
},
},
"preferredStrategies": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-list-type": "atomic",
},
},
"strategy": {
SchemaProps: spec.SchemaProps{
Description: "PreferredStrategies indicates the list of strategies for picking the leader for coordinated leader election. The list is ordered, and the first strategy supersedes all other strategies. The list is used by coordinated leader election to make a decision about the final election strategy. This follows as - If all clients have strategy X as the first element in this list, strategy X will be used. - If a candidate has strategy [X] and another candidate has strategy [Y, X], Y supersedes X and strategy Y\n will be used.\n- If a candidate has strategy [X, Y] and another candidate has strategy [Y, X], this is a user error and leader\n election will not operate the Lease until resolved.\n(Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Description: "Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved. (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"leaseName", "preferredStrategies"},
Required: []string{"leaseName", "binaryVersion", "strategy"},
},
},
Dependencies: []string{

View file

@ -73,7 +73,7 @@ func NewStorageFactoryConfig() *StorageFactoryConfig {
//
// TODO (https://github.com/kubernetes/kubernetes/issues/108451): remove the override in 1.25.
// apisstorage.Resource("csistoragecapacities").WithVersion("v1beta1"),
coordination.Resource("leasecandidates").WithVersion("v1alpha1"),
coordination.Resource("leasecandidates").WithVersion("v1alpha2"),
networking.Resource("ipaddresses").WithVersion("v1beta1"),
networking.Resource("servicecidrs").WithVersion("v1beta1"),
admissionregistration.Resource("mutatingadmissionpolicies").WithVersion("v1alpha1"),

View file

@ -34,7 +34,7 @@ import (
certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1"
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
coordinationv1 "k8s.io/api/coordination/v1"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
apiv1 "k8s.io/api/core/v1"
discoveryv1beta1 "k8s.io/api/discovery/v1beta1"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
@ -435,7 +435,7 @@ func AddHandlers(h printers.PrintHandler) {
leaseCandidateColumnDefinitions := []metav1.TableColumnDefinition{
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
{Name: "LeaseName", Type: "string", Description: coordinationv1alpha1.LeaseCandidateSpec{}.SwaggerDoc()["leaseName"]},
{Name: "LeaseName", Type: "string", Description: coordinationv1alpha2.LeaseCandidateSpec{}.SwaggerDoc()["leaseName"]},
{Name: "BinaryVersion", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["binaryVersion"]},
{Name: "EmulationVersion", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["emulationVersion"]},
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},

View file

@ -18,7 +18,7 @@ package rest
import (
coordinationv1 "k8s.io/api/coordination/v1"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
"k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest"
genericapiserver "k8s.io/apiserver/pkg/server"
@ -42,10 +42,10 @@ func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource serverstorag
apiGroupInfo.VersionedResourcesStorageMap[coordinationv1.SchemeGroupVersion.Version] = storageMap
}
if storageMap, err := p.v1alpha1Storage(apiResourceConfigSource, restOptionsGetter); err != nil {
if storageMap, err := p.v1alpha2Storage(apiResourceConfigSource, restOptionsGetter); err != nil {
return genericapiserver.APIGroupInfo{}, err
} else if len(storageMap) > 0 {
apiGroupInfo.VersionedResourcesStorageMap[coordinationv1alpha1.SchemeGroupVersion.Version] = storageMap
apiGroupInfo.VersionedResourcesStorageMap[coordinationv1alpha2.SchemeGroupVersion.Version] = storageMap
}
return apiGroupInfo, nil
@ -65,11 +65,11 @@ func (p RESTStorageProvider) v1Storage(apiResourceConfigSource serverstorage.API
return storage, nil
}
func (p RESTStorageProvider) v1alpha1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (map[string]rest.Storage, error) {
func (p RESTStorageProvider) v1alpha2Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (map[string]rest.Storage, error) {
storage := map[string]rest.Storage{}
// identity
if resource := "leasecandidates"; apiResourceConfigSource.ResourceEnabled(coordinationv1alpha1.SchemeGroupVersion.WithResource(resource)) {
if resource := "leasecandidates"; apiResourceConfigSource.ResourceEnabled(coordinationv1alpha2.SchemeGroupVersion.WithResource(resource)) {
leaseCandidateStorage, err := leasecandidatestorage.NewREST(restOptionsGetter)
if err != nil {
return storage, err

View file

@ -21,4 +21,4 @@ limitations under the License.
// +groupName=coordination.k8s.io
package v1alpha1 // import "k8s.io/api/coordination/v1alpha1"
package v1alpha2 // import "k8s.io/api/coordination/v1alpha2"

View file

@ -15,9 +15,9 @@ limitations under the License.
*/
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: k8s.io/api/coordination/v1alpha1/generated.proto
// source: k8s.io/api/coordination/v1alpha2/generated.proto
package v1alpha1
package v1alpha2
import (
fmt "fmt"
@ -49,7 +49,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
func (m *LeaseCandidate) Reset() { *m = LeaseCandidate{} }
func (*LeaseCandidate) ProtoMessage() {}
func (*LeaseCandidate) Descriptor() ([]byte, []int) {
return fileDescriptor_cb9e87df9da593c2, []int{0}
return fileDescriptor_c1ec5c989d262916, []int{0}
}
func (m *LeaseCandidate) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -77,7 +77,7 @@ var xxx_messageInfo_LeaseCandidate proto.InternalMessageInfo
func (m *LeaseCandidateList) Reset() { *m = LeaseCandidateList{} }
func (*LeaseCandidateList) ProtoMessage() {}
func (*LeaseCandidateList) Descriptor() ([]byte, []int) {
return fileDescriptor_cb9e87df9da593c2, []int{1}
return fileDescriptor_c1ec5c989d262916, []int{1}
}
func (m *LeaseCandidateList) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -105,7 +105,7 @@ var xxx_messageInfo_LeaseCandidateList proto.InternalMessageInfo
func (m *LeaseCandidateSpec) Reset() { *m = LeaseCandidateSpec{} }
func (*LeaseCandidateSpec) ProtoMessage() {}
func (*LeaseCandidateSpec) Descriptor() ([]byte, []int) {
return fileDescriptor_cb9e87df9da593c2, []int{2}
return fileDescriptor_c1ec5c989d262916, []int{2}
}
func (m *LeaseCandidateSpec) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -131,53 +131,52 @@ func (m *LeaseCandidateSpec) XXX_DiscardUnknown() {
var xxx_messageInfo_LeaseCandidateSpec proto.InternalMessageInfo
func init() {
proto.RegisterType((*LeaseCandidate)(nil), "k8s.io.api.coordination.v1alpha1.LeaseCandidate")
proto.RegisterType((*LeaseCandidateList)(nil), "k8s.io.api.coordination.v1alpha1.LeaseCandidateList")
proto.RegisterType((*LeaseCandidateSpec)(nil), "k8s.io.api.coordination.v1alpha1.LeaseCandidateSpec")
proto.RegisterType((*LeaseCandidate)(nil), "k8s.io.api.coordination.v1alpha2.LeaseCandidate")
proto.RegisterType((*LeaseCandidateList)(nil), "k8s.io.api.coordination.v1alpha2.LeaseCandidateList")
proto.RegisterType((*LeaseCandidateSpec)(nil), "k8s.io.api.coordination.v1alpha2.LeaseCandidateSpec")
}
func init() {
proto.RegisterFile("k8s.io/api/coordination/v1alpha1/generated.proto", fileDescriptor_cb9e87df9da593c2)
proto.RegisterFile("k8s.io/api/coordination/v1alpha2/generated.proto", fileDescriptor_c1ec5c989d262916)
}
var fileDescriptor_cb9e87df9da593c2 = []byte{
// 570 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcb, 0x6e, 0xd3, 0x4c,
0x14, 0xc7, 0xe3, 0x36, 0xf9, 0x94, 0xcc, 0xd7, 0xa0, 0x30, 0x15, 0x92, 0x95, 0x85, 0x13, 0x65,
0x55, 0x21, 0x31, 0x6e, 0xa0, 0x42, 0x48, 0xec, 0x5c, 0x40, 0x42, 0x4a, 0x4b, 0xe5, 0x42, 0x25,
0x50, 0x17, 0x4c, 0xec, 0x53, 0x67, 0x48, 0x7c, 0xd1, 0x78, 0x52, 0x94, 0x5d, 0x17, 0x3c, 0x00,
0x8f, 0x15, 0x58, 0x75, 0xd9, 0x55, 0x44, 0xcc, 0x5b, 0xb0, 0x42, 0x33, 0xb1, 0x73, 0x6d, 0x94,
0x88, 0x5d, 0xce, 0xe5, 0xf7, 0x3f, 0xe7, 0x7f, 0xac, 0x0c, 0x3a, 0xec, 0xbe, 0x88, 0x09, 0x0b,
0x4d, 0x1a, 0x31, 0xd3, 0x09, 0x43, 0xee, 0xb2, 0x80, 0x0a, 0x16, 0x06, 0xe6, 0x75, 0x93, 0xf6,
0xa2, 0x0e, 0x6d, 0x9a, 0x1e, 0x04, 0xc0, 0xa9, 0x00, 0x97, 0x44, 0x3c, 0x14, 0x21, 0xae, 0x4f,
0x08, 0x42, 0x23, 0x46, 0xe6, 0x09, 0x92, 0x11, 0xd5, 0x27, 0x1e, 0x13, 0x9d, 0x7e, 0x9b, 0x38,
0xa1, 0x6f, 0x7a, 0xa1, 0x17, 0x9a, 0x0a, 0x6c, 0xf7, 0xaf, 0x54, 0xa4, 0x02, 0xf5, 0x6b, 0x22,
0x58, 0x7d, 0xbc, 0x7e, 0x85, 0xe5, 0xe1, 0xd5, 0xa3, 0x59, 0xaf, 0x4f, 0x9d, 0x0e, 0x0b, 0x80,
0x0f, 0xcc, 0xa8, 0xeb, 0xc9, 0x44, 0x6c, 0xfa, 0x20, 0xe8, 0x7d, 0x94, 0xb9, 0x8e, 0xe2, 0xfd,
0x40, 0x30, 0x1f, 0x56, 0x80, 0xe7, 0x9b, 0x80, 0xd8, 0xe9, 0x80, 0x4f, 0x97, 0xb9, 0xc6, 0x4f,
0x0d, 0x3d, 0x68, 0x01, 0x8d, 0xe1, 0x98, 0x06, 0x2e, 0x73, 0xa9, 0x00, 0xfc, 0x19, 0x15, 0xe5,
0x5a, 0x2e, 0x15, 0x54, 0xd7, 0xea, 0xda, 0xc1, 0xff, 0x4f, 0x0f, 0xc9, 0xec, 0x82, 0x53, 0x75,
0x12, 0x75, 0x3d, 0x99, 0x88, 0x89, 0xec, 0x26, 0xd7, 0x4d, 0xf2, 0xae, 0xfd, 0x05, 0x1c, 0x71,
0x02, 0x82, 0x5a, 0x78, 0x38, 0xaa, 0xe5, 0x92, 0x51, 0x0d, 0xcd, 0x72, 0xf6, 0x54, 0x15, 0x5f,
0xa0, 0x7c, 0x1c, 0x81, 0xa3, 0xef, 0x28, 0xf5, 0x23, 0xb2, 0xe9, 0xfb, 0x90, 0xc5, 0x0d, 0xcf,
0x23, 0x70, 0xac, 0xbd, 0x74, 0x42, 0x5e, 0x46, 0xb6, 0xd2, 0x6b, 0xfc, 0xd0, 0x10, 0x5e, 0x6c,
0x6d, 0xb1, 0x58, 0xe0, 0xcb, 0x15, 0x43, 0x64, 0x3b, 0x43, 0x92, 0x56, 0x76, 0x2a, 0xe9, 0xb0,
0x62, 0x96, 0x99, 0x33, 0xf3, 0x01, 0x15, 0x98, 0x00, 0x3f, 0xd6, 0x77, 0xea, 0xbb, 0x4b, 0xb7,
0xda, 0xca, 0x8d, 0x55, 0x4e, 0xc5, 0x0b, 0x6f, 0xa5, 0x8c, 0x3d, 0x51, 0x6b, 0x7c, 0xcb, 0x2f,
0x7b, 0x91, 0x46, 0xb1, 0x89, 0x4a, 0x3d, 0x99, 0x3d, 0xa5, 0x3e, 0x28, 0x33, 0x25, 0xeb, 0x61,
0xca, 0x97, 0x5a, 0x59, 0xc1, 0x9e, 0xf5, 0xe0, 0x8f, 0xa8, 0x18, 0xb1, 0xc0, 0x7b, 0xcf, 0x7c,
0x48, 0xef, 0x6d, 0x6e, 0x67, 0xfe, 0x84, 0x39, 0x3c, 0x94, 0x98, 0xb5, 0x27, 0x9d, 0x9f, 0xa5,
0x22, 0xf6, 0x54, 0x0e, 0x5f, 0xa2, 0x12, 0x87, 0x00, 0xbe, 0x2a, 0xed, 0xdd, 0x7f, 0xd3, 0x2e,
0xcb, 0xc5, 0xed, 0x4c, 0xc5, 0x9e, 0x09, 0xe2, 0x97, 0xa8, 0xdc, 0x66, 0x01, 0xe5, 0x83, 0x0b,
0xe0, 0x31, 0x0b, 0x03, 0x3d, 0xaf, 0xdc, 0x3e, 0x4a, 0xdd, 0x96, 0xad, 0xf9, 0xa2, 0xbd, 0xd8,
0x8b, 0x5f, 0xa1, 0x0a, 0xf8, 0xfd, 0x9e, 0x3a, 0x7c, 0xc6, 0x17, 0x14, 0xaf, 0xa7, 0x7c, 0xe5,
0xf5, 0x52, 0xdd, 0x5e, 0x21, 0xf0, 0x8d, 0x86, 0xf6, 0x23, 0x0e, 0x57, 0xc0, 0x39, 0xb8, 0xe7,
0x42, 0xfe, 0x6f, 0x3c, 0x06, 0xb1, 0xfe, 0x5f, 0x7d, 0xf7, 0xa0, 0x64, 0x9d, 0x26, 0xa3, 0xda,
0xfe, 0xd9, 0x6a, 0xf9, 0xcf, 0xa8, 0xf6, 0x6c, 0xfd, 0x03, 0x41, 0x8e, 0xb3, 0x18, 0x5c, 0xf5,
0xc1, 0x52, 0x70, 0x60, 0xdf, 0x37, 0xca, 0x7a, 0x33, 0x1c, 0x1b, 0xb9, 0xdb, 0xb1, 0x91, 0xbb,
0x1b, 0x1b, 0xb9, 0x9b, 0xc4, 0xd0, 0x86, 0x89, 0xa1, 0xdd, 0x26, 0x86, 0x76, 0x97, 0x18, 0xda,
0xaf, 0xc4, 0xd0, 0xbe, 0xff, 0x36, 0x72, 0x9f, 0xea, 0x9b, 0xde, 0xc4, 0xbf, 0x01, 0x00, 0x00,
0xff, 0xff, 0x05, 0x28, 0x49, 0xd9, 0x36, 0x05, 0x00, 0x00,
var fileDescriptor_c1ec5c989d262916 = []byte{
// 555 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x8b, 0xd3, 0x4e,
0x18, 0xc7, 0x9b, 0xdd, 0xf6, 0x47, 0x3b, 0xbf, 0xad, 0xd4, 0x01, 0x21, 0xf4, 0x90, 0x96, 0x9e,
0x44, 0x70, 0x66, 0x77, 0x5d, 0x44, 0xf0, 0x96, 0xf5, 0x0f, 0x42, 0x57, 0x25, 0xab, 0x0b, 0xca,
0x1e, 0x9c, 0x26, 0x8f, 0xe9, 0xd8, 0x26, 0x13, 0x92, 0xe9, 0x4a, 0x6f, 0xbe, 0x04, 0x5f, 0x56,
0xf5, 0xb4, 0xc7, 0x3d, 0x15, 0x1b, 0xc1, 0x17, 0xe1, 0x49, 0x66, 0x9a, 0xf4, 0xaf, 0xa5, 0xc5,
0x5b, 0xe7, 0x99, 0xe7, 0xf3, 0x99, 0xf9, 0x3e, 0x69, 0x82, 0x0e, 0x7b, 0x8f, 0x12, 0xc2, 0x05,
0x65, 0x11, 0xa7, 0xae, 0x10, 0xb1, 0xc7, 0x43, 0x26, 0xb9, 0x08, 0xe9, 0xd5, 0x11, 0xeb, 0x47,
0x5d, 0x76, 0x4c, 0x7d, 0x08, 0x21, 0x66, 0x12, 0x3c, 0x12, 0xc5, 0x42, 0x0a, 0xdc, 0x9c, 0x12,
0x84, 0x45, 0x9c, 0x2c, 0x12, 0x24, 0x27, 0xea, 0xf7, 0x7d, 0x2e, 0xbb, 0x83, 0x0e, 0x71, 0x45,
0x40, 0x7d, 0xe1, 0x0b, 0xaa, 0xc1, 0xce, 0xe0, 0xa3, 0x5e, 0xe9, 0x85, 0xfe, 0x35, 0x15, 0xd6,
0xef, 0x6d, 0xbe, 0xc2, 0xea, 0xe1, 0xf5, 0x93, 0x79, 0x6f, 0xc0, 0xdc, 0x2e, 0x0f, 0x21, 0x1e,
0xd2, 0xa8, 0xe7, 0xab, 0x42, 0x42, 0x03, 0x90, 0xec, 0x6f, 0x14, 0xdd, 0x44, 0xc5, 0x83, 0x50,
0xf2, 0x00, 0xd6, 0x80, 0x87, 0xdb, 0x80, 0xc4, 0xed, 0x42, 0xc0, 0x56, 0xb9, 0xd6, 0x77, 0x03,
0xdd, 0x6a, 0x03, 0x4b, 0xe0, 0x94, 0x85, 0x1e, 0xf7, 0x98, 0x04, 0xfc, 0x01, 0x95, 0xd5, 0xb5,
0x3c, 0x26, 0x99, 0x69, 0x34, 0x8d, 0xbb, 0xff, 0x1f, 0x1f, 0x92, 0xf9, 0x04, 0x67, 0x76, 0x12,
0xf5, 0x7c, 0x55, 0x48, 0x88, 0xea, 0x26, 0x57, 0x47, 0xe4, 0x55, 0xe7, 0x13, 0xb8, 0xf2, 0x0c,
0x24, 0xb3, 0xf1, 0x68, 0xdc, 0x28, 0xa4, 0xe3, 0x06, 0x9a, 0xd7, 0x9c, 0x99, 0x15, 0x5f, 0xa0,
0x62, 0x12, 0x81, 0x6b, 0xee, 0x69, 0xfb, 0x09, 0xd9, 0xf6, 0x7c, 0xc8, 0xf2, 0x0d, 0xcf, 0x23,
0x70, 0xed, 0x83, 0xec, 0x84, 0xa2, 0x5a, 0x39, 0xda, 0xd7, 0xfa, 0x66, 0x20, 0xbc, 0xdc, 0xda,
0xe6, 0x89, 0xc4, 0x97, 0x6b, 0x81, 0xc8, 0x6e, 0x81, 0x14, 0xad, 0xe3, 0xd4, 0xb2, 0xc3, 0xca,
0x79, 0x65, 0x21, 0xcc, 0x5b, 0x54, 0xe2, 0x12, 0x82, 0xc4, 0xdc, 0x6b, 0xee, 0xaf, 0xcc, 0x6a,
0xa7, 0x34, 0x76, 0x35, 0x93, 0x97, 0x5e, 0x28, 0x8d, 0x33, 0xb5, 0xb5, 0x7e, 0xed, 0xaf, 0x66,
0x51, 0x41, 0x31, 0x45, 0x95, 0xbe, 0xaa, 0xbe, 0x64, 0x01, 0xe8, 0x30, 0x15, 0xfb, 0x76, 0xc6,
0x57, 0xda, 0xf9, 0x86, 0x33, 0xef, 0xc1, 0xef, 0x50, 0x39, 0xe2, 0xa1, 0xff, 0x86, 0x07, 0x90,
0xcd, 0x9b, 0xee, 0x16, 0xfe, 0x8c, 0xbb, 0xb1, 0x50, 0x98, 0x7d, 0xa0, 0x92, 0xbf, 0xce, 0x24,
0xce, 0x4c, 0x87, 0x2f, 0x51, 0x25, 0x86, 0x10, 0x3e, 0x6b, 0xf7, 0xfe, 0xbf, 0xb9, 0xab, 0xea,
0xe2, 0x4e, 0x6e, 0x71, 0xe6, 0x42, 0xfc, 0x18, 0x55, 0x3b, 0x3c, 0x64, 0xf1, 0xf0, 0x02, 0xe2,
0x84, 0x8b, 0xd0, 0x2c, 0xea, 0xb4, 0x77, 0xb2, 0xb4, 0x55, 0x7b, 0x71, 0xd3, 0x59, 0xee, 0xc5,
0x4f, 0x50, 0x0d, 0x82, 0x41, 0x5f, 0x0f, 0x3e, 0xe7, 0x4b, 0x9a, 0x37, 0x33, 0xbe, 0xf6, 0x74,
0x65, 0xdf, 0x59, 0x23, 0xb0, 0x8b, 0xca, 0x89, 0x54, 0x6f, 0x8b, 0x3f, 0x34, 0xff, 0xd3, 0xf4,
0xf3, 0xfc, 0x8f, 0x70, 0x9e, 0xd5, 0x7f, 0x8f, 0x1b, 0x0f, 0x36, 0x7f, 0x0d, 0xc8, 0x69, 0xbe,
0x06, 0x4f, 0x3f, 0x9d, 0x1c, 0x73, 0x66, 0x62, 0xfb, 0xd9, 0x68, 0x62, 0x15, 0xae, 0x27, 0x56,
0xe1, 0x66, 0x62, 0x15, 0xbe, 0xa4, 0x96, 0x31, 0x4a, 0x2d, 0xe3, 0x3a, 0xb5, 0x8c, 0x9b, 0xd4,
0x32, 0x7e, 0xa4, 0x96, 0xf1, 0xf5, 0xa7, 0x55, 0x78, 0xdf, 0xdc, 0xf6, 0xd5, 0xfb, 0x13, 0x00,
0x00, 0xff, 0xff, 0x7f, 0x15, 0x63, 0xd0, 0x18, 0x05, 0x00, 0x00,
}
func (m *LeaseCandidate) Marshal() (dAtA []byte, err error) {
@ -290,15 +289,11 @@ func (m *LeaseCandidateSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.PreferredStrategies) > 0 {
for iNdEx := len(m.PreferredStrategies) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.PreferredStrategies[iNdEx])
copy(dAtA[i:], m.PreferredStrategies[iNdEx])
i = encodeVarintGenerated(dAtA, i, uint64(len(m.PreferredStrategies[iNdEx])))
i--
dAtA[i] = 0x32
}
}
i -= len(m.Strategy)
copy(dAtA[i:], m.Strategy)
i = encodeVarintGenerated(dAtA, i, uint64(len(m.Strategy)))
i--
dAtA[i] = 0x32
i -= len(m.EmulationVersion)
copy(dAtA[i:], m.EmulationVersion)
i = encodeVarintGenerated(dAtA, i, uint64(len(m.EmulationVersion)))
@ -402,12 +397,8 @@ func (m *LeaseCandidateSpec) Size() (n int) {
n += 1 + l + sovGenerated(uint64(l))
l = len(m.EmulationVersion)
n += 1 + l + sovGenerated(uint64(l))
if len(m.PreferredStrategies) > 0 {
for _, s := range m.PreferredStrategies {
l = len(s)
n += 1 + l + sovGenerated(uint64(l))
}
}
l = len(m.Strategy)
n += 1 + l + sovGenerated(uint64(l))
return n
}
@ -454,7 +445,7 @@ func (this *LeaseCandidateSpec) String() string {
`RenewTime:` + strings.Replace(fmt.Sprintf("%v", this.RenewTime), "MicroTime", "v1.MicroTime", 1) + `,`,
`BinaryVersion:` + fmt.Sprintf("%v", this.BinaryVersion) + `,`,
`EmulationVersion:` + fmt.Sprintf("%v", this.EmulationVersion) + `,`,
`PreferredStrategies:` + fmt.Sprintf("%v", this.PreferredStrategies) + `,`,
`Strategy:` + fmt.Sprintf("%v", this.Strategy) + `,`,
`}`,
}, "")
return s
@ -899,7 +890,7 @@ func (m *LeaseCandidateSpec) Unmarshal(dAtA []byte) error {
iNdEx = postIndex
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field PreferredStrategies", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field Strategy", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
@ -927,7 +918,7 @@ func (m *LeaseCandidateSpec) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.PreferredStrategies = append(m.PreferredStrategies, k8s_io_api_coordination_v1.CoordinatedLeaseStrategy(dAtA[iNdEx:postIndex]))
m.Strategy = k8s_io_api_coordination_v1.CoordinatedLeaseStrategy(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex

View file

@ -19,7 +19,7 @@ limitations under the License.
syntax = "proto2";
package k8s.io.api.coordination.v1alpha1;
package k8s.io.api.coordination.v1alpha2;
import "k8s.io/api/coordination/v1/generated.proto";
import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
@ -27,7 +27,7 @@ import "k8s.io/apimachinery/pkg/runtime/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
// Package-wide variables from generator "generated".
option go_package = "k8s.io/api/coordination/v1alpha1";
option go_package = "k8s.io/api/coordination/v1alpha2";
// LeaseCandidate defines a candidate for a Lease object.
// Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.
@ -78,8 +78,8 @@ message LeaseCandidateSpec {
optional .k8s.io.apimachinery.pkg.apis.meta.v1.MicroTime renewTime = 3;
// BinaryVersion is the binary version. It must be in a semver format without leading `v`.
// This field is required when strategy is "OldestEmulationVersion"
// +optional
// This field is required.
// +required
optional string binaryVersion = 4;
// EmulationVersion is the emulation version. It must be in a semver format without leading `v`.
@ -88,18 +88,13 @@ message LeaseCandidateSpec {
// +optional
optional string emulationVersion = 5;
// PreferredStrategies indicates the list of strategies for picking the leader for coordinated leader election.
// The list is ordered, and the first strategy supersedes all other strategies. The list is used by coordinated
// leader election to make a decision about the final election strategy. This follows as
// - If all clients have strategy X as the first element in this list, strategy X will be used.
// - If a candidate has strategy [X] and another candidate has strategy [Y, X], Y supersedes X and strategy Y
// will be used.
// - If a candidate has strategy [X, Y] and another candidate has strategy [Y, X], this is a user error and leader
// election will not operate the Lease until resolved.
// Strategy is the strategy that coordinated leader election will use for picking the leader.
// If multiple candidates for the same Lease return different strategies, the strategy provided
// by the candidate with the latest BinaryVersion will be used. If there is still conflict,
// this is a user error and coordinated leader election will not operate the Lease until resolved.
// (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.
// +featureGate=CoordinatedLeaderElection
// +listType=atomic
// +required
repeated string preferredStrategies = 6;
optional string strategy = 6;
}

View file

@ -1,5 +1,5 @@
/*
Copyright 2018 The Kubernetes Authors.
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
package v1alpha2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -26,7 +26,7 @@ import (
const GroupName = "coordination.k8s.io"
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {

View file

@ -1,5 +1,5 @@
/*
Copyright 2018 The Kubernetes Authors.
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
package v1alpha2
import (
v1 "k8s.io/api/coordination/v1"
@ -23,7 +23,7 @@ import (
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.31
// +k8s:prerelease-lifecycle-gen:introduced=1.32
// LeaseCandidate defines a candidate for a Lease object.
// Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.
@ -61,31 +61,26 @@ type LeaseCandidateSpec struct {
// +optional
RenewTime *metav1.MicroTime `json:"renewTime,omitempty" protobuf:"bytes,3,opt,name=renewTime"`
// BinaryVersion is the binary version. It must be in a semver format without leading `v`.
// This field is required when strategy is "OldestEmulationVersion"
// +optional
BinaryVersion string `json:"binaryVersion,omitempty" protobuf:"bytes,4,opt,name=binaryVersion"`
// This field is required.
// +required
BinaryVersion string `json:"binaryVersion" protobuf:"bytes,4,name=binaryVersion"`
// EmulationVersion is the emulation version. It must be in a semver format without leading `v`.
// EmulationVersion must be less than or equal to BinaryVersion.
// This field is required when strategy is "OldestEmulationVersion"
// +optional
EmulationVersion string `json:"emulationVersion,omitempty" protobuf:"bytes,5,opt,name=emulationVersion"`
// PreferredStrategies indicates the list of strategies for picking the leader for coordinated leader election.
// The list is ordered, and the first strategy supersedes all other strategies. The list is used by coordinated
// leader election to make a decision about the final election strategy. This follows as
// - If all clients have strategy X as the first element in this list, strategy X will be used.
// - If a candidate has strategy [X] and another candidate has strategy [Y, X], Y supersedes X and strategy Y
// will be used.
// - If a candidate has strategy [X, Y] and another candidate has strategy [Y, X], this is a user error and leader
// election will not operate the Lease until resolved.
// Strategy is the strategy that coordinated leader election will use for picking the leader.
// If multiple candidates for the same Lease return different strategies, the strategy provided
// by the candidate with the latest BinaryVersion will be used. If there is still conflict,
// this is a user error and coordinated leader election will not operate the Lease until resolved.
// (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.
// +featureGate=CoordinatedLeaderElection
// +listType=atomic
// +required
PreferredStrategies []v1.CoordinatedLeaseStrategy `json:"preferredStrategies,omitempty" protobuf:"bytes,6,opt,name=preferredStrategies"`
Strategy v1.CoordinatedLeaseStrategy `json:"strategy,omitempty" protobuf:"bytes,6,opt,name=strategy"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.31
// +k8s:prerelease-lifecycle-gen:introduced=1.32
// LeaseCandidateList is a list of Lease objects.
type LeaseCandidateList struct {

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
package v1alpha2
// This file contains a collection of methods that can be used from go-restful to
// generate Swagger API documentation for its models. Please read this PR for more
@ -48,13 +48,13 @@ func (LeaseCandidateList) SwaggerDoc() map[string]string {
}
var map_LeaseCandidateSpec = map[string]string{
"": "LeaseCandidateSpec is a specification of a Lease.",
"leaseName": "LeaseName is the name of the lease for which this candidate is contending. This field is immutable.",
"pingTime": "PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime.",
"renewTime": "RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates.",
"binaryVersion": "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required when strategy is \"OldestEmulationVersion\"",
"emulationVersion": "EmulationVersion is the emulation version. It must be in a semver format without leading `v`. EmulationVersion must be less than or equal to BinaryVersion. This field is required when strategy is \"OldestEmulationVersion\"",
"preferredStrategies": "PreferredStrategies indicates the list of strategies for picking the leader for coordinated leader election. The list is ordered, and the first strategy supersedes all other strategies. The list is used by coordinated leader election to make a decision about the final election strategy. This follows as - If all clients have strategy X as the first element in this list, strategy X will be used. - If a candidate has strategy [X] and another candidate has strategy [Y, X], Y supersedes X and strategy Y\n will be used.\n- If a candidate has strategy [X, Y] and another candidate has strategy [Y, X], this is a user error and leader\n election will not operate the Lease until resolved.\n(Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.",
"": "LeaseCandidateSpec is a specification of a Lease.",
"leaseName": "LeaseName is the name of the lease for which this candidate is contending. This field is immutable.",
"pingTime": "PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime.",
"renewTime": "RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates.",
"binaryVersion": "BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.",
"emulationVersion": "EmulationVersion is the emulation version. It must be in a semver format without leading `v`. EmulationVersion must be less than or equal to BinaryVersion. This field is required when strategy is \"OldestEmulationVersion\"",
"strategy": "Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved. (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.",
}
func (LeaseCandidateSpec) SwaggerDoc() map[string]string {

View file

@ -19,10 +19,9 @@ limitations under the License.
// Code generated by deepcopy-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
v1 "k8s.io/api/coordination/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
@ -97,11 +96,6 @@ func (in *LeaseCandidateSpec) DeepCopyInto(out *LeaseCandidateSpec) {
in, out := &in.RenewTime, &out.RenewTime
*out = (*in).DeepCopy()
}
if in.PreferredStrategies != nil {
in, out := &in.PreferredStrategies, &out.PreferredStrategies
*out = make([]v1.CoordinatedLeaseStrategy, len(*in))
copy(*out, *in)
}
return
}

View file

@ -19,40 +19,40 @@ limitations under the License.
// Code generated by prerelease-lifecycle-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
// APILifecycleIntroduced is an autogenerated function, returning the release in which the API struct was introduced as int versions of major and minor for comparison.
// It is controlled by "k8s:prerelease-lifecycle-gen:introduced" tags in types.go.
func (in *LeaseCandidate) APILifecycleIntroduced() (major, minor int) {
return 1, 31
return 1, 32
}
// APILifecycleDeprecated is an autogenerated function, returning the release in which the API struct was or will be deprecated as int versions of major and minor for comparison.
// It is controlled by "k8s:prerelease-lifecycle-gen:deprecated" tags in types.go or "k8s:prerelease-lifecycle-gen:introduced" plus three minor.
func (in *LeaseCandidate) APILifecycleDeprecated() (major, minor int) {
return 1, 34
return 1, 35
}
// APILifecycleRemoved is an autogenerated function, returning the release in which the API is no longer served as int versions of major and minor for comparison.
// It is controlled by "k8s:prerelease-lifecycle-gen:removed" tags in types.go or "k8s:prerelease-lifecycle-gen:deprecated" plus three minor.
func (in *LeaseCandidate) APILifecycleRemoved() (major, minor int) {
return 1, 37
return 1, 38
}
// APILifecycleIntroduced is an autogenerated function, returning the release in which the API struct was introduced as int versions of major and minor for comparison.
// It is controlled by "k8s:prerelease-lifecycle-gen:introduced" tags in types.go.
func (in *LeaseCandidateList) APILifecycleIntroduced() (major, minor int) {
return 1, 31
return 1, 32
}
// APILifecycleDeprecated is an autogenerated function, returning the release in which the API struct was or will be deprecated as int versions of major and minor for comparison.
// It is controlled by "k8s:prerelease-lifecycle-gen:deprecated" tags in types.go or "k8s:prerelease-lifecycle-gen:introduced" plus three minor.
func (in *LeaseCandidateList) APILifecycleDeprecated() (major, minor int) {
return 1, 34
return 1, 35
}
// APILifecycleRemoved is an autogenerated function, returning the release in which the API is no longer served as int versions of major and minor for comparison.
// It is controlled by "k8s:prerelease-lifecycle-gen:removed" tags in types.go or "k8s:prerelease-lifecycle-gen:deprecated" plus three minor.
func (in *LeaseCandidateList) APILifecycleRemoved() (major, minor int) {
return 1, 37
return 1, 38
}

View file

@ -45,7 +45,7 @@ import (
certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1"
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
coordinationv1 "k8s.io/api/coordination/v1"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
@ -113,7 +113,7 @@ var groups = []runtime.SchemeBuilder{
certificatesv1alpha1.SchemeBuilder,
coordinationv1.SchemeBuilder,
coordinationv1beta1.SchemeBuilder,
coordinationv1alpha1.SchemeBuilder,
coordinationv1alpha2.SchemeBuilder,
corev1.SchemeBuilder,
discoveryv1.SchemeBuilder,
discoveryv1beta1.SchemeBuilder,

View file

@ -1,6 +1,6 @@
{
"kind": "LeaseCandidate",
"apiVersion": "coordination.k8s.io/v1alpha1",
"apiVersion": "coordination.k8s.io/v1alpha2",
"metadata": {
"name": "nameValue",
"generateName": "generateNameValue",
@ -49,8 +49,6 @@
"renewTime": "2003-01-01T01:01:01.000003Z",
"binaryVersion": "binaryVersionValue",
"emulationVersion": "emulationVersionValue",
"preferredStrategies": [
"preferredStrategiesValue"
]
"strategy": "strategyValue"
}
}

View file

@ -1,4 +1,4 @@
apiVersion: coordination.k8s.io/v1alpha1
apiVersion: coordination.k8s.io/v1alpha2
kind: LeaseCandidate
metadata:
annotations:
@ -37,6 +37,5 @@ spec:
emulationVersion: emulationVersionValue
leaseName: leaseNameValue
pingTime: "2002-01-01T01:01:01.000002Z"
preferredStrategies:
- preferredStrategiesValue
renewTime: "2003-01-01T01:01:01.000003Z"
strategy: strategyValue

View file

@ -1,56 +0,0 @@
{
"kind": "LeaseCandidate",
"apiVersion": "coordination.k8s.io/v1alpha1",
"metadata": {
"name": "nameValue",
"generateName": "generateNameValue",
"namespace": "namespaceValue",
"selfLink": "selfLinkValue",
"uid": "uidValue",
"resourceVersion": "resourceVersionValue",
"generation": 7,
"creationTimestamp": "2008-01-01T01:01:01Z",
"deletionTimestamp": "2009-01-01T01:01:01Z",
"deletionGracePeriodSeconds": 10,
"labels": {
"labelsKey": "labelsValue"
},
"annotations": {
"annotationsKey": "annotationsValue"
},
"ownerReferences": [
{
"apiVersion": "apiVersionValue",
"kind": "kindValue",
"name": "nameValue",
"uid": "uidValue",
"controller": true,
"blockOwnerDeletion": true
}
],
"finalizers": [
"finalizersValue"
],
"managedFields": [
{
"manager": "managerValue",
"operation": "operationValue",
"apiVersion": "apiVersionValue",
"time": "2004-01-01T01:01:01Z",
"fieldsType": "fieldsTypeValue",
"fieldsV1": {},
"subresource": "subresourceValue"
}
]
},
"spec": {
"leaseName": "leaseNameValue",
"pingTime": "2002-01-01T01:01:01.000002Z",
"renewTime": "2003-01-01T01:01:01.000003Z",
"binaryVersion": "binaryVersionValue",
"emulationVersion": "emulationVersionValue",
"preferredStrategies": [
"preferredStrategiesValue"
]
}
}

View file

@ -1,42 +0,0 @@
apiVersion: coordination.k8s.io/v1alpha1
kind: LeaseCandidate
metadata:
annotations:
annotationsKey: annotationsValue
creationTimestamp: "2008-01-01T01:01:01Z"
deletionGracePeriodSeconds: 10
deletionTimestamp: "2009-01-01T01:01:01Z"
finalizers:
- finalizersValue
generateName: generateNameValue
generation: 7
labels:
labelsKey: labelsValue
managedFields:
- apiVersion: apiVersionValue
fieldsType: fieldsTypeValue
fieldsV1: {}
manager: managerValue
operation: operationValue
subresource: subresourceValue
time: "2004-01-01T01:01:01Z"
name: nameValue
namespace: namespaceValue
ownerReferences:
- apiVersion: apiVersionValue
blockOwnerDeletion: true
controller: true
kind: kindValue
name: nameValue
uid: uidValue
resourceVersion: resourceVersionValue
selfLink: selfLinkValue
uid: uidValue
spec:
binaryVersion: binaryVersionValue
emulationVersion: emulationVersionValue
leaseName: leaseNameValue
pingTime: "2002-01-01T01:01:01.000002Z"
preferredStrategies:
- preferredStrategiesValue
renewTime: "2003-01-01T01:01:01.000003Z"

View file

@ -16,10 +16,10 @@ limitations under the License.
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
@ -42,7 +42,7 @@ func LeaseCandidate(name, namespace string) *LeaseCandidateApplyConfiguration {
b.WithName(name)
b.WithNamespace(namespace)
b.WithKind("LeaseCandidate")
b.WithAPIVersion("coordination.k8s.io/v1alpha1")
b.WithAPIVersion("coordination.k8s.io/v1alpha2")
return b
}
@ -57,20 +57,20 @@ func LeaseCandidate(name, namespace string) *LeaseCandidateApplyConfiguration {
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
// applied if another fieldManager has updated or force applied any of the previously applied fields.
// Experimental!
func ExtractLeaseCandidate(leaseCandidate *coordinationv1alpha1.LeaseCandidate, fieldManager string) (*LeaseCandidateApplyConfiguration, error) {
func ExtractLeaseCandidate(leaseCandidate *coordinationv1alpha2.LeaseCandidate, fieldManager string) (*LeaseCandidateApplyConfiguration, error) {
return extractLeaseCandidate(leaseCandidate, fieldManager, "")
}
// ExtractLeaseCandidateStatus is the same as ExtractLeaseCandidate except
// that it extracts the status subresource applied configuration.
// Experimental!
func ExtractLeaseCandidateStatus(leaseCandidate *coordinationv1alpha1.LeaseCandidate, fieldManager string) (*LeaseCandidateApplyConfiguration, error) {
func ExtractLeaseCandidateStatus(leaseCandidate *coordinationv1alpha2.LeaseCandidate, fieldManager string) (*LeaseCandidateApplyConfiguration, error) {
return extractLeaseCandidate(leaseCandidate, fieldManager, "status")
}
func extractLeaseCandidate(leaseCandidate *coordinationv1alpha1.LeaseCandidate, fieldManager string, subresource string) (*LeaseCandidateApplyConfiguration, error) {
func extractLeaseCandidate(leaseCandidate *coordinationv1alpha2.LeaseCandidate, fieldManager string, subresource string) (*LeaseCandidateApplyConfiguration, error) {
b := &LeaseCandidateApplyConfiguration{}
err := managedfields.ExtractInto(leaseCandidate, internal.Parser().Type("io.k8s.api.coordination.v1alpha1.LeaseCandidate"), fieldManager, b, subresource)
err := managedfields.ExtractInto(leaseCandidate, internal.Parser().Type("io.k8s.api.coordination.v1alpha2.LeaseCandidate"), fieldManager, b, subresource)
if err != nil {
return nil, err
}
@ -78,7 +78,7 @@ func extractLeaseCandidate(leaseCandidate *coordinationv1alpha1.LeaseCandidate,
b.WithNamespace(leaseCandidate.Namespace)
b.WithKind("LeaseCandidate")
b.WithAPIVersion("coordination.k8s.io/v1alpha1")
b.WithAPIVersion("coordination.k8s.io/v1alpha2")
return b, nil
}

View file

@ -16,7 +16,7 @@ limitations under the License.
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
coordinationv1 "k8s.io/api/coordination/v1"
@ -26,12 +26,12 @@ import (
// LeaseCandidateSpecApplyConfiguration represents a declarative configuration of the LeaseCandidateSpec type for use
// with apply.
type LeaseCandidateSpecApplyConfiguration struct {
LeaseName *string `json:"leaseName,omitempty"`
PingTime *v1.MicroTime `json:"pingTime,omitempty"`
RenewTime *v1.MicroTime `json:"renewTime,omitempty"`
BinaryVersion *string `json:"binaryVersion,omitempty"`
EmulationVersion *string `json:"emulationVersion,omitempty"`
PreferredStrategies []coordinationv1.CoordinatedLeaseStrategy `json:"preferredStrategies,omitempty"`
LeaseName *string `json:"leaseName,omitempty"`
PingTime *v1.MicroTime `json:"pingTime,omitempty"`
RenewTime *v1.MicroTime `json:"renewTime,omitempty"`
BinaryVersion *string `json:"binaryVersion,omitempty"`
EmulationVersion *string `json:"emulationVersion,omitempty"`
Strategy *coordinationv1.CoordinatedLeaseStrategy `json:"strategy,omitempty"`
}
// LeaseCandidateSpecApplyConfiguration constructs a declarative configuration of the LeaseCandidateSpec type for use with
@ -80,12 +80,10 @@ func (b *LeaseCandidateSpecApplyConfiguration) WithEmulationVersion(value string
return b
}
// WithPreferredStrategies adds the given value to the PreferredStrategies field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the PreferredStrategies field.
func (b *LeaseCandidateSpecApplyConfiguration) WithPreferredStrategies(values ...coordinationv1.CoordinatedLeaseStrategy) *LeaseCandidateSpecApplyConfiguration {
for i := range values {
b.PreferredStrategies = append(b.PreferredStrategies, values[i])
}
// WithStrategy sets the Strategy field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Strategy field is set to the value of the last call.
func (b *LeaseCandidateSpecApplyConfiguration) WithStrategy(value coordinationv1.CoordinatedLeaseStrategy) *LeaseCandidateSpecApplyConfiguration {
b.Strategy = &value
return b
}

View file

@ -4471,7 +4471,7 @@ var schemaYAML = typed.YAMLObject(`types:
- name: strategy
type:
scalar: string
- name: io.k8s.api.coordination.v1alpha1.LeaseCandidate
- name: io.k8s.api.coordination.v1alpha2.LeaseCandidate
map:
fields:
- name: apiVersion
@ -4486,14 +4486,15 @@ var schemaYAML = typed.YAMLObject(`types:
default: {}
- name: spec
type:
namedType: io.k8s.api.coordination.v1alpha1.LeaseCandidateSpec
namedType: io.k8s.api.coordination.v1alpha2.LeaseCandidateSpec
default: {}
- name: io.k8s.api.coordination.v1alpha1.LeaseCandidateSpec
- name: io.k8s.api.coordination.v1alpha2.LeaseCandidateSpec
map:
fields:
- name: binaryVersion
type:
scalar: string
default: ""
- name: emulationVersion
type:
scalar: string
@ -4504,15 +4505,12 @@ var schemaYAML = typed.YAMLObject(`types:
- name: pingTime
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime
- name: preferredStrategies
type:
list:
elementType:
scalar: string
elementRelationship: atomic
- name: renewTime
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime
- name: strategy
type:
scalar: string
- name: io.k8s.api.coordination.v1beta1.Lease
map:
fields:

View file

@ -36,7 +36,7 @@ import (
certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1"
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
coordinationv1 "k8s.io/api/coordination/v1"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
@ -89,7 +89,7 @@ import (
applyconfigurationscertificatesv1alpha1 "k8s.io/client-go/applyconfigurations/certificates/v1alpha1"
applyconfigurationscertificatesv1beta1 "k8s.io/client-go/applyconfigurations/certificates/v1beta1"
applyconfigurationscoordinationv1 "k8s.io/client-go/applyconfigurations/coordination/v1"
applyconfigurationscoordinationv1alpha1 "k8s.io/client-go/applyconfigurations/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/client-go/applyconfigurations/coordination/v1alpha2"
applyconfigurationscoordinationv1beta1 "k8s.io/client-go/applyconfigurations/coordination/v1beta1"
applyconfigurationscorev1 "k8s.io/client-go/applyconfigurations/core/v1"
applyconfigurationsdiscoveryv1 "k8s.io/client-go/applyconfigurations/discovery/v1"
@ -631,11 +631,11 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
case coordinationv1.SchemeGroupVersion.WithKind("LeaseSpec"):
return &applyconfigurationscoordinationv1.LeaseSpecApplyConfiguration{}
// Group=coordination.k8s.io, Version=v1alpha1
case coordinationv1alpha1.SchemeGroupVersion.WithKind("LeaseCandidate"):
return &applyconfigurationscoordinationv1alpha1.LeaseCandidateApplyConfiguration{}
case coordinationv1alpha1.SchemeGroupVersion.WithKind("LeaseCandidateSpec"):
return &applyconfigurationscoordinationv1alpha1.LeaseCandidateSpecApplyConfiguration{}
// Group=coordination.k8s.io, Version=v1alpha2
case v1alpha2.SchemeGroupVersion.WithKind("LeaseCandidate"):
return &coordinationv1alpha2.LeaseCandidateApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("LeaseCandidateSpec"):
return &coordinationv1alpha2.LeaseCandidateSpecApplyConfiguration{}
// Group=coordination.k8s.io, Version=v1beta1
case coordinationv1beta1.SchemeGroupVersion.WithKind("Lease"):

View file

@ -20,7 +20,7 @@ package coordination
import (
v1 "k8s.io/client-go/informers/coordination/v1"
v1alpha1 "k8s.io/client-go/informers/coordination/v1alpha1"
v1alpha2 "k8s.io/client-go/informers/coordination/v1alpha2"
v1beta1 "k8s.io/client-go/informers/coordination/v1beta1"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
)
@ -29,8 +29,8 @@ import (
type Interface interface {
// V1 provides access to shared informers for resources in V1.
V1() v1.Interface
// V1alpha1 provides access to shared informers for resources in V1alpha1.
V1alpha1() v1alpha1.Interface
// V1alpha2 provides access to shared informers for resources in V1alpha2.
V1alpha2() v1alpha2.Interface
// V1beta1 provides access to shared informers for resources in V1beta1.
V1beta1() v1beta1.Interface
}
@ -51,9 +51,9 @@ func (g *group) V1() v1.Interface {
return v1.New(g.factory, g.namespace, g.tweakListOptions)
}
// V1alpha1 returns a new v1alpha1.Interface.
func (g *group) V1alpha1() v1alpha1.Interface {
return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions)
// V1alpha2 returns a new v1alpha2.Interface.
func (g *group) V1alpha2() v1alpha2.Interface {
return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions)
}
// V1beta1 returns a new v1beta1.Interface.

View file

@ -16,7 +16,7 @@ limitations under the License.
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"

View file

@ -16,19 +16,19 @@ limitations under the License.
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
context "context"
time "time"
apicoordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
apicoordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
kubernetes "k8s.io/client-go/kubernetes"
coordinationv1alpha1 "k8s.io/client-go/listers/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/client-go/listers/coordination/v1alpha2"
cache "k8s.io/client-go/tools/cache"
)
@ -36,7 +36,7 @@ import (
// LeaseCandidates.
type LeaseCandidateInformer interface {
Informer() cache.SharedIndexInformer
Lister() coordinationv1alpha1.LeaseCandidateLister
Lister() coordinationv1alpha2.LeaseCandidateLister
}
type leaseCandidateInformer struct {
@ -62,16 +62,16 @@ func NewFilteredLeaseCandidateInformer(client kubernetes.Interface, namespace st
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.CoordinationV1alpha1().LeaseCandidates(namespace).List(context.TODO(), options)
return client.CoordinationV1alpha2().LeaseCandidates(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.CoordinationV1alpha1().LeaseCandidates(namespace).Watch(context.TODO(), options)
return client.CoordinationV1alpha2().LeaseCandidates(namespace).Watch(context.TODO(), options)
},
},
&apicoordinationv1alpha1.LeaseCandidate{},
&apicoordinationv1alpha2.LeaseCandidate{},
resyncPeriod,
indexers,
)
@ -82,9 +82,9 @@ func (f *leaseCandidateInformer) defaultInformer(client kubernetes.Interface, re
}
func (f *leaseCandidateInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&apicoordinationv1alpha1.LeaseCandidate{}, f.defaultInformer)
return f.factory.InformerFor(&apicoordinationv1alpha2.LeaseCandidate{}, f.defaultInformer)
}
func (f *leaseCandidateInformer) Lister() coordinationv1alpha1.LeaseCandidateLister {
return coordinationv1alpha1.NewLeaseCandidateLister(f.Informer().GetIndexer())
func (f *leaseCandidateInformer) Lister() coordinationv1alpha2.LeaseCandidateLister {
return coordinationv1alpha2.NewLeaseCandidateLister(f.Informer().GetIndexer())
}

View file

@ -38,7 +38,7 @@ import (
certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1"
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
coordinationv1 "k8s.io/api/coordination/v1"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
@ -204,9 +204,9 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
case coordinationv1.SchemeGroupVersion.WithResource("leases"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Coordination().V1().Leases().Informer()}, nil
// Group=coordination.k8s.io, Version=v1alpha1
case coordinationv1alpha1.SchemeGroupVersion.WithResource("leasecandidates"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Coordination().V1alpha1().LeaseCandidates().Informer()}, nil
// Group=coordination.k8s.io, Version=v1alpha2
case v1alpha2.SchemeGroupVersion.WithResource("leasecandidates"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Coordination().V1alpha2().LeaseCandidates().Informer()}, nil
// Group=coordination.k8s.io, Version=v1beta1
case coordinationv1beta1.SchemeGroupVersion.WithResource("leases"):

View file

@ -45,7 +45,7 @@ import (
certificatesv1alpha1 "k8s.io/client-go/kubernetes/typed/certificates/v1alpha1"
certificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
coordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1"
coordinationv1alpha1 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2"
coordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
discoveryv1 "k8s.io/client-go/kubernetes/typed/discovery/v1"
@ -104,7 +104,7 @@ type Interface interface {
CertificatesV1() certificatesv1.CertificatesV1Interface
CertificatesV1beta1() certificatesv1beta1.CertificatesV1beta1Interface
CertificatesV1alpha1() certificatesv1alpha1.CertificatesV1alpha1Interface
CoordinationV1alpha1() coordinationv1alpha1.CoordinationV1alpha1Interface
CoordinationV1alpha2() coordinationv1alpha2.CoordinationV1alpha2Interface
CoordinationV1beta1() coordinationv1beta1.CoordinationV1beta1Interface
CoordinationV1() coordinationv1.CoordinationV1Interface
CoreV1() corev1.CoreV1Interface
@ -163,7 +163,7 @@ type Clientset struct {
certificatesV1 *certificatesv1.CertificatesV1Client
certificatesV1beta1 *certificatesv1beta1.CertificatesV1beta1Client
certificatesV1alpha1 *certificatesv1alpha1.CertificatesV1alpha1Client
coordinationV1alpha1 *coordinationv1alpha1.CoordinationV1alpha1Client
coordinationV1alpha2 *coordinationv1alpha2.CoordinationV1alpha2Client
coordinationV1beta1 *coordinationv1beta1.CoordinationV1beta1Client
coordinationV1 *coordinationv1.CoordinationV1Client
coreV1 *corev1.CoreV1Client
@ -303,9 +303,9 @@ func (c *Clientset) CertificatesV1alpha1() certificatesv1alpha1.CertificatesV1al
return c.certificatesV1alpha1
}
// CoordinationV1alpha1 retrieves the CoordinationV1alpha1Client
func (c *Clientset) CoordinationV1alpha1() coordinationv1alpha1.CoordinationV1alpha1Interface {
return c.coordinationV1alpha1
// CoordinationV1alpha2 retrieves the CoordinationV1alpha2Client
func (c *Clientset) CoordinationV1alpha2() coordinationv1alpha2.CoordinationV1alpha2Interface {
return c.coordinationV1alpha2
}
// CoordinationV1beta1 retrieves the CoordinationV1beta1Client
@ -596,7 +596,7 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset,
if err != nil {
return nil, err
}
cs.coordinationV1alpha1, err = coordinationv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
cs.coordinationV1alpha2, err = coordinationv1alpha2.NewForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
@ -770,7 +770,7 @@ func New(c rest.Interface) *Clientset {
cs.certificatesV1 = certificatesv1.New(c)
cs.certificatesV1beta1 = certificatesv1beta1.New(c)
cs.certificatesV1alpha1 = certificatesv1alpha1.New(c)
cs.coordinationV1alpha1 = coordinationv1alpha1.New(c)
cs.coordinationV1alpha2 = coordinationv1alpha2.New(c)
cs.coordinationV1beta1 = coordinationv1beta1.New(c)
cs.coordinationV1 = coordinationv1.New(c)
cs.coreV1 = corev1.New(c)

View file

@ -69,8 +69,8 @@ import (
fakecertificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1/fake"
coordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1"
fakecoordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1/fake"
coordinationv1alpha1 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha1"
fakecoordinationv1alpha1 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha1/fake"
coordinationv1alpha2 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2"
fakecoordinationv1alpha2 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2/fake"
coordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1"
fakecoordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1/fake"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
@ -327,9 +327,9 @@ func (c *Clientset) CertificatesV1alpha1() certificatesv1alpha1.CertificatesV1al
return &fakecertificatesv1alpha1.FakeCertificatesV1alpha1{Fake: &c.Fake}
}
// CoordinationV1alpha1 retrieves the CoordinationV1alpha1Client
func (c *Clientset) CoordinationV1alpha1() coordinationv1alpha1.CoordinationV1alpha1Interface {
return &fakecoordinationv1alpha1.FakeCoordinationV1alpha1{Fake: &c.Fake}
// CoordinationV1alpha2 retrieves the CoordinationV1alpha2Client
func (c *Clientset) CoordinationV1alpha2() coordinationv1alpha2.CoordinationV1alpha2Interface {
return &fakecoordinationv1alpha2.FakeCoordinationV1alpha2{Fake: &c.Fake}
}
// CoordinationV1beta1 retrieves the CoordinationV1beta1Client

View file

@ -41,7 +41,7 @@ import (
certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1"
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
coordinationv1 "k8s.io/api/coordination/v1"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
@ -105,7 +105,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
certificatesv1.AddToScheme,
certificatesv1beta1.AddToScheme,
certificatesv1alpha1.AddToScheme,
coordinationv1alpha1.AddToScheme,
coordinationv1alpha2.AddToScheme,
coordinationv1beta1.AddToScheme,
coordinationv1.AddToScheme,
corev1.AddToScheme,

View file

@ -41,7 +41,7 @@ import (
certificatesv1alpha1 "k8s.io/api/certificates/v1alpha1"
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
coordinationv1 "k8s.io/api/coordination/v1"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
@ -105,7 +105,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
certificatesv1.AddToScheme,
certificatesv1beta1.AddToScheme,
certificatesv1alpha1.AddToScheme,
coordinationv1alpha1.AddToScheme,
coordinationv1alpha2.AddToScheme,
coordinationv1beta1.AddToScheme,
coordinationv1.AddToScheme,
corev1.AddToScheme,

View file

@ -16,34 +16,34 @@ limitations under the License.
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
http "net/http"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
scheme "k8s.io/client-go/kubernetes/scheme"
rest "k8s.io/client-go/rest"
)
type CoordinationV1alpha1Interface interface {
type CoordinationV1alpha2Interface interface {
RESTClient() rest.Interface
LeaseCandidatesGetter
}
// CoordinationV1alpha1Client is used to interact with features provided by the coordination.k8s.io group.
type CoordinationV1alpha1Client struct {
// CoordinationV1alpha2Client is used to interact with features provided by the coordination.k8s.io group.
type CoordinationV1alpha2Client struct {
restClient rest.Interface
}
func (c *CoordinationV1alpha1Client) LeaseCandidates(namespace string) LeaseCandidateInterface {
func (c *CoordinationV1alpha2Client) LeaseCandidates(namespace string) LeaseCandidateInterface {
return newLeaseCandidates(c, namespace)
}
// NewForConfig creates a new CoordinationV1alpha1Client for the given config.
// NewForConfig creates a new CoordinationV1alpha2Client for the given config.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).
func NewForConfig(c *rest.Config) (*CoordinationV1alpha1Client, error) {
func NewForConfig(c *rest.Config) (*CoordinationV1alpha2Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
@ -55,9 +55,9 @@ func NewForConfig(c *rest.Config) (*CoordinationV1alpha1Client, error) {
return NewForConfigAndClient(&config, httpClient)
}
// NewForConfigAndClient creates a new CoordinationV1alpha1Client for the given config and http client.
// NewForConfigAndClient creates a new CoordinationV1alpha2Client for the given config and http client.
// Note the http client provided takes precedence over the configured transport values.
func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CoordinationV1alpha1Client, error) {
func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CoordinationV1alpha2Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
@ -66,12 +66,12 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CoordinationV1alpha
if err != nil {
return nil, err
}
return &CoordinationV1alpha1Client{client}, nil
return &CoordinationV1alpha2Client{client}, nil
}
// NewForConfigOrDie creates a new CoordinationV1alpha1Client for the given config and
// NewForConfigOrDie creates a new CoordinationV1alpha2Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *CoordinationV1alpha1Client {
func NewForConfigOrDie(c *rest.Config) *CoordinationV1alpha2Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
@ -79,13 +79,13 @@ func NewForConfigOrDie(c *rest.Config) *CoordinationV1alpha1Client {
return client
}
// New creates a new CoordinationV1alpha1Client for the given RESTClient.
func New(c rest.Interface) *CoordinationV1alpha1Client {
return &CoordinationV1alpha1Client{c}
// New creates a new CoordinationV1alpha2Client for the given RESTClient.
func New(c rest.Interface) *CoordinationV1alpha2Client {
return &CoordinationV1alpha2Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := coordinationv1alpha1.SchemeGroupVersion
gv := coordinationv1alpha2.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion()
@ -99,7 +99,7 @@ func setConfigDefaults(config *rest.Config) error {
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *CoordinationV1alpha1Client) RESTClient() rest.Interface {
func (c *CoordinationV1alpha2Client) RESTClient() rest.Interface {
if c == nil {
return nil
}

View file

@ -17,4 +17,4 @@ limitations under the License.
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v1alpha1
package v1alpha2

View file

@ -19,22 +19,22 @@ limitations under the License.
package fake
import (
v1alpha1 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha1"
v1alpha2 "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2"
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
)
type FakeCoordinationV1alpha1 struct {
type FakeCoordinationV1alpha2 struct {
*testing.Fake
}
func (c *FakeCoordinationV1alpha1) LeaseCandidates(namespace string) v1alpha1.LeaseCandidateInterface {
func (c *FakeCoordinationV1alpha2) LeaseCandidates(namespace string) v1alpha2.LeaseCandidateInterface {
return &FakeLeaseCandidates{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeCoordinationV1alpha1) RESTClient() rest.Interface {
func (c *FakeCoordinationV1alpha2) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View file

@ -23,40 +23,40 @@ import (
json "encoding/json"
fmt "fmt"
v1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
coordinationv1alpha1 "k8s.io/client-go/applyconfigurations/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/client-go/applyconfigurations/coordination/v1alpha2"
testing "k8s.io/client-go/testing"
)
// FakeLeaseCandidates implements LeaseCandidateInterface
type FakeLeaseCandidates struct {
Fake *FakeCoordinationV1alpha1
Fake *FakeCoordinationV1alpha2
ns string
}
var leasecandidatesResource = v1alpha1.SchemeGroupVersion.WithResource("leasecandidates")
var leasecandidatesResource = v1alpha2.SchemeGroupVersion.WithResource("leasecandidates")
var leasecandidatesKind = v1alpha1.SchemeGroupVersion.WithKind("LeaseCandidate")
var leasecandidatesKind = v1alpha2.SchemeGroupVersion.WithKind("LeaseCandidate")
// Get takes name of the leaseCandidate, and returns the corresponding leaseCandidate object, and an error if there is any.
func (c *FakeLeaseCandidates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.LeaseCandidate, err error) {
emptyResult := &v1alpha1.LeaseCandidate{}
func (c *FakeLeaseCandidates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.LeaseCandidate, err error) {
emptyResult := &v1alpha2.LeaseCandidate{}
obj, err := c.Fake.
Invokes(testing.NewGetActionWithOptions(leasecandidatesResource, c.ns, name, options), emptyResult)
if obj == nil {
return emptyResult, err
}
return obj.(*v1alpha1.LeaseCandidate), err
return obj.(*v1alpha2.LeaseCandidate), err
}
// List takes label and field selectors, and returns the list of LeaseCandidates that match those selectors.
func (c *FakeLeaseCandidates) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.LeaseCandidateList, err error) {
emptyResult := &v1alpha1.LeaseCandidateList{}
func (c *FakeLeaseCandidates) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.LeaseCandidateList, err error) {
emptyResult := &v1alpha2.LeaseCandidateList{}
obj, err := c.Fake.
Invokes(testing.NewListActionWithOptions(leasecandidatesResource, leasecandidatesKind, c.ns, opts), emptyResult)
@ -68,8 +68,8 @@ func (c *FakeLeaseCandidates) List(ctx context.Context, opts v1.ListOptions) (re
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.LeaseCandidateList{ListMeta: obj.(*v1alpha1.LeaseCandidateList).ListMeta}
for _, item := range obj.(*v1alpha1.LeaseCandidateList).Items {
list := &v1alpha2.LeaseCandidateList{ListMeta: obj.(*v1alpha2.LeaseCandidateList).ListMeta}
for _, item := range obj.(*v1alpha2.LeaseCandidateList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
@ -85,33 +85,33 @@ func (c *FakeLeaseCandidates) Watch(ctx context.Context, opts v1.ListOptions) (w
}
// Create takes the representation of a leaseCandidate and creates it. Returns the server's representation of the leaseCandidate, and an error, if there is any.
func (c *FakeLeaseCandidates) Create(ctx context.Context, leaseCandidate *v1alpha1.LeaseCandidate, opts v1.CreateOptions) (result *v1alpha1.LeaseCandidate, err error) {
emptyResult := &v1alpha1.LeaseCandidate{}
func (c *FakeLeaseCandidates) Create(ctx context.Context, leaseCandidate *v1alpha2.LeaseCandidate, opts v1.CreateOptions) (result *v1alpha2.LeaseCandidate, err error) {
emptyResult := &v1alpha2.LeaseCandidate{}
obj, err := c.Fake.
Invokes(testing.NewCreateActionWithOptions(leasecandidatesResource, c.ns, leaseCandidate, opts), emptyResult)
if obj == nil {
return emptyResult, err
}
return obj.(*v1alpha1.LeaseCandidate), err
return obj.(*v1alpha2.LeaseCandidate), err
}
// Update takes the representation of a leaseCandidate and updates it. Returns the server's representation of the leaseCandidate, and an error, if there is any.
func (c *FakeLeaseCandidates) Update(ctx context.Context, leaseCandidate *v1alpha1.LeaseCandidate, opts v1.UpdateOptions) (result *v1alpha1.LeaseCandidate, err error) {
emptyResult := &v1alpha1.LeaseCandidate{}
func (c *FakeLeaseCandidates) Update(ctx context.Context, leaseCandidate *v1alpha2.LeaseCandidate, opts v1.UpdateOptions) (result *v1alpha2.LeaseCandidate, err error) {
emptyResult := &v1alpha2.LeaseCandidate{}
obj, err := c.Fake.
Invokes(testing.NewUpdateActionWithOptions(leasecandidatesResource, c.ns, leaseCandidate, opts), emptyResult)
if obj == nil {
return emptyResult, err
}
return obj.(*v1alpha1.LeaseCandidate), err
return obj.(*v1alpha2.LeaseCandidate), err
}
// Delete takes name of the leaseCandidate and deletes it. Returns an error if one occurs.
func (c *FakeLeaseCandidates) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteActionWithOptions(leasecandidatesResource, c.ns, name, opts), &v1alpha1.LeaseCandidate{})
Invokes(testing.NewDeleteActionWithOptions(leasecandidatesResource, c.ns, name, opts), &v1alpha2.LeaseCandidate{})
return err
}
@ -120,24 +120,24 @@ func (c *FakeLeaseCandidates) Delete(ctx context.Context, name string, opts v1.D
func (c *FakeLeaseCandidates) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionActionWithOptions(leasecandidatesResource, c.ns, opts, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.LeaseCandidateList{})
_, err := c.Fake.Invokes(action, &v1alpha2.LeaseCandidateList{})
return err
}
// Patch applies the patch and returns the patched leaseCandidate.
func (c *FakeLeaseCandidates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.LeaseCandidate, err error) {
emptyResult := &v1alpha1.LeaseCandidate{}
func (c *FakeLeaseCandidates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.LeaseCandidate, err error) {
emptyResult := &v1alpha2.LeaseCandidate{}
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceActionWithOptions(leasecandidatesResource, c.ns, name, pt, data, opts, subresources...), emptyResult)
if obj == nil {
return emptyResult, err
}
return obj.(*v1alpha1.LeaseCandidate), err
return obj.(*v1alpha2.LeaseCandidate), err
}
// Apply takes the given apply declarative configuration, applies it and returns the applied leaseCandidate.
func (c *FakeLeaseCandidates) Apply(ctx context.Context, leaseCandidate *coordinationv1alpha1.LeaseCandidateApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.LeaseCandidate, err error) {
func (c *FakeLeaseCandidates) Apply(ctx context.Context, leaseCandidate *coordinationv1alpha2.LeaseCandidateApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.LeaseCandidate, err error) {
if leaseCandidate == nil {
return nil, fmt.Errorf("leaseCandidate provided to Apply must not be nil")
}
@ -149,12 +149,12 @@ func (c *FakeLeaseCandidates) Apply(ctx context.Context, leaseCandidate *coordin
if name == nil {
return nil, fmt.Errorf("leaseCandidate.Name must be provided to Apply")
}
emptyResult := &v1alpha1.LeaseCandidate{}
emptyResult := &v1alpha2.LeaseCandidate{}
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceActionWithOptions(leasecandidatesResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult)
if obj == nil {
return emptyResult, err
}
return obj.(*v1alpha1.LeaseCandidate), err
return obj.(*v1alpha2.LeaseCandidate), err
}

View file

@ -16,6 +16,6 @@ limitations under the License.
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
type LeaseCandidateExpansion interface{}

View file

@ -16,16 +16,16 @@ limitations under the License.
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
context "context"
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
applyconfigurationscoordinationv1alpha1 "k8s.io/client-go/applyconfigurations/coordination/v1alpha1"
applyconfigurationscoordinationv1alpha2 "k8s.io/client-go/applyconfigurations/coordination/v1alpha2"
gentype "k8s.io/client-go/gentype"
scheme "k8s.io/client-go/kubernetes/scheme"
)
@ -38,34 +38,34 @@ type LeaseCandidatesGetter interface {
// LeaseCandidateInterface has methods to work with LeaseCandidate resources.
type LeaseCandidateInterface interface {
Create(ctx context.Context, leaseCandidate *coordinationv1alpha1.LeaseCandidate, opts v1.CreateOptions) (*coordinationv1alpha1.LeaseCandidate, error)
Update(ctx context.Context, leaseCandidate *coordinationv1alpha1.LeaseCandidate, opts v1.UpdateOptions) (*coordinationv1alpha1.LeaseCandidate, error)
Create(ctx context.Context, leaseCandidate *coordinationv1alpha2.LeaseCandidate, opts v1.CreateOptions) (*coordinationv1alpha2.LeaseCandidate, error)
Update(ctx context.Context, leaseCandidate *coordinationv1alpha2.LeaseCandidate, opts v1.UpdateOptions) (*coordinationv1alpha2.LeaseCandidate, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*coordinationv1alpha1.LeaseCandidate, error)
List(ctx context.Context, opts v1.ListOptions) (*coordinationv1alpha1.LeaseCandidateList, error)
Get(ctx context.Context, name string, opts v1.GetOptions) (*coordinationv1alpha2.LeaseCandidate, error)
List(ctx context.Context, opts v1.ListOptions) (*coordinationv1alpha2.LeaseCandidateList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *coordinationv1alpha1.LeaseCandidate, err error)
Apply(ctx context.Context, leaseCandidate *applyconfigurationscoordinationv1alpha1.LeaseCandidateApplyConfiguration, opts v1.ApplyOptions) (result *coordinationv1alpha1.LeaseCandidate, err error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *coordinationv1alpha2.LeaseCandidate, err error)
Apply(ctx context.Context, leaseCandidate *applyconfigurationscoordinationv1alpha2.LeaseCandidateApplyConfiguration, opts v1.ApplyOptions) (result *coordinationv1alpha2.LeaseCandidate, err error)
LeaseCandidateExpansion
}
// leaseCandidates implements LeaseCandidateInterface
type leaseCandidates struct {
*gentype.ClientWithListAndApply[*coordinationv1alpha1.LeaseCandidate, *coordinationv1alpha1.LeaseCandidateList, *applyconfigurationscoordinationv1alpha1.LeaseCandidateApplyConfiguration]
*gentype.ClientWithListAndApply[*coordinationv1alpha2.LeaseCandidate, *coordinationv1alpha2.LeaseCandidateList, *applyconfigurationscoordinationv1alpha2.LeaseCandidateApplyConfiguration]
}
// newLeaseCandidates returns a LeaseCandidates
func newLeaseCandidates(c *CoordinationV1alpha1Client, namespace string) *leaseCandidates {
func newLeaseCandidates(c *CoordinationV1alpha2Client, namespace string) *leaseCandidates {
return &leaseCandidates{
gentype.NewClientWithListAndApply[*coordinationv1alpha1.LeaseCandidate, *coordinationv1alpha1.LeaseCandidateList, *applyconfigurationscoordinationv1alpha1.LeaseCandidateApplyConfiguration](
gentype.NewClientWithListAndApply[*coordinationv1alpha2.LeaseCandidate, *coordinationv1alpha2.LeaseCandidateList, *applyconfigurationscoordinationv1alpha2.LeaseCandidateApplyConfiguration](
"leasecandidates",
c.RESTClient(),
scheme.ParameterCodec,
namespace,
func() *coordinationv1alpha1.LeaseCandidate { return &coordinationv1alpha1.LeaseCandidate{} },
func() *coordinationv1alpha1.LeaseCandidateList { return &coordinationv1alpha1.LeaseCandidateList{} },
gentype.PrefersProtobuf[*coordinationv1alpha1.LeaseCandidate](),
func() *coordinationv1alpha2.LeaseCandidate { return &coordinationv1alpha2.LeaseCandidate{} },
func() *coordinationv1alpha2.LeaseCandidateList { return &coordinationv1alpha2.LeaseCandidateList{} },
gentype.PrefersProtobuf[*coordinationv1alpha2.LeaseCandidate](),
),
}
}

View file

@ -16,7 +16,7 @@ limitations under the License.
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
// LeaseCandidateListerExpansion allows custom methods to be added to
// LeaseCandidateLister.

View file

@ -16,10 +16,10 @@ limitations under the License.
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
package v1alpha2
import (
coordinationv1alpha1 "k8s.io/api/coordination/v1alpha1"
coordinationv1alpha2 "k8s.io/api/coordination/v1alpha2"
labels "k8s.io/apimachinery/pkg/labels"
listers "k8s.io/client-go/listers"
cache "k8s.io/client-go/tools/cache"
@ -30,7 +30,7 @@ import (
type LeaseCandidateLister interface {
// List lists all LeaseCandidates in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*coordinationv1alpha1.LeaseCandidate, err error)
List(selector labels.Selector) (ret []*coordinationv1alpha2.LeaseCandidate, err error)
// LeaseCandidates returns an object that can list and get LeaseCandidates.
LeaseCandidates(namespace string) LeaseCandidateNamespaceLister
LeaseCandidateListerExpansion
@ -38,17 +38,17 @@ type LeaseCandidateLister interface {
// leaseCandidateLister implements the LeaseCandidateLister interface.
type leaseCandidateLister struct {
listers.ResourceIndexer[*coordinationv1alpha1.LeaseCandidate]
listers.ResourceIndexer[*coordinationv1alpha2.LeaseCandidate]
}
// NewLeaseCandidateLister returns a new LeaseCandidateLister.
func NewLeaseCandidateLister(indexer cache.Indexer) LeaseCandidateLister {
return &leaseCandidateLister{listers.New[*coordinationv1alpha1.LeaseCandidate](indexer, coordinationv1alpha1.Resource("leasecandidate"))}
return &leaseCandidateLister{listers.New[*coordinationv1alpha2.LeaseCandidate](indexer, coordinationv1alpha2.Resource("leasecandidate"))}
}
// LeaseCandidates returns an object that can list and get LeaseCandidates.
func (s *leaseCandidateLister) LeaseCandidates(namespace string) LeaseCandidateNamespaceLister {
return leaseCandidateNamespaceLister{listers.NewNamespaced[*coordinationv1alpha1.LeaseCandidate](s.ResourceIndexer, namespace)}
return leaseCandidateNamespaceLister{listers.NewNamespaced[*coordinationv1alpha2.LeaseCandidate](s.ResourceIndexer, namespace)}
}
// LeaseCandidateNamespaceLister helps list and get LeaseCandidates.
@ -56,15 +56,15 @@ func (s *leaseCandidateLister) LeaseCandidates(namespace string) LeaseCandidateN
type LeaseCandidateNamespaceLister interface {
// List lists all LeaseCandidates in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*coordinationv1alpha1.LeaseCandidate, err error)
List(selector labels.Selector) (ret []*coordinationv1alpha2.LeaseCandidate, err error)
// Get retrieves the LeaseCandidate from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*coordinationv1alpha1.LeaseCandidate, error)
Get(name string) (*coordinationv1alpha2.LeaseCandidate, error)
LeaseCandidateNamespaceListerExpansion
}
// leaseCandidateNamespaceLister implements the LeaseCandidateNamespaceLister
// interface.
type leaseCandidateNamespaceLister struct {
listers.ResourceIndexer[*coordinationv1alpha1.LeaseCandidate]
listers.ResourceIndexer[*coordinationv1alpha2.LeaseCandidate]
}

View file

@ -22,14 +22,14 @@ import (
"time"
v1 "k8s.io/api/coordination/v1"
v1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
coordinationv1alpha1client "k8s.io/client-go/kubernetes/typed/coordination/v1alpha1"
coordinationv1alpha2client "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
@ -43,7 +43,7 @@ type CacheSyncWaiter interface {
}
type LeaseCandidate struct {
leaseClient coordinationv1alpha1client.LeaseCandidateInterface
leaseClient coordinationv1alpha2client.LeaseCandidateInterface
leaseCandidateInformer cache.SharedIndexInformer
informerFactory informers.SharedInformerFactory
hasSynced cache.InformerSynced
@ -60,7 +60,7 @@ type LeaseCandidate struct {
clock clock.Clock
binaryVersion, emulationVersion string
preferredStrategies []v1.CoordinatedLeaseStrategy
strategy v1.CoordinatedLeaseStrategy
}
// NewCandidate creates new LeaseCandidate controller that creates a
@ -73,7 +73,7 @@ func NewCandidate(clientset kubernetes.Interface,
candidateName string,
targetLease string,
binaryVersion, emulationVersion string,
preferredStrategies []v1.CoordinatedLeaseStrategy,
strategy v1.CoordinatedLeaseStrategy,
) (*LeaseCandidate, CacheSyncWaiter, error) {
fieldSelector := fields.OneTermEqualSelector("metadata.name", candidateName).String()
// A separate informer factory is required because this must start before informerFactories
@ -84,10 +84,10 @@ func NewCandidate(clientset kubernetes.Interface,
options.FieldSelector = fieldSelector
}),
)
leaseCandidateInformer := informerFactory.Coordination().V1alpha1().LeaseCandidates().Informer()
leaseCandidateInformer := informerFactory.Coordination().V1alpha2().LeaseCandidates().Informer()
lc := &LeaseCandidate{
leaseClient: clientset.CoordinationV1alpha1().LeaseCandidates(candidateNamespace),
leaseClient: clientset.CoordinationV1alpha2().LeaseCandidates(candidateNamespace),
leaseCandidateInformer: leaseCandidateInformer,
informerFactory: informerFactory,
name: candidateName,
@ -96,13 +96,13 @@ func NewCandidate(clientset kubernetes.Interface,
clock: clock.RealClock{},
binaryVersion: binaryVersion,
emulationVersion: emulationVersion,
preferredStrategies: preferredStrategies,
strategy: strategy,
}
lc.queue = workqueue.NewTypedRateLimitingQueueWithConfig(workqueue.DefaultTypedControllerRateLimiter[int](), workqueue.TypedRateLimitingQueueConfig[int]{Name: "leasecandidate"})
h, err := leaseCandidateInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
UpdateFunc: func(oldObj, newObj interface{}) {
if leasecandidate, ok := newObj.(*v1alpha1.LeaseCandidate); ok {
if leasecandidate, ok := newObj.(*v1alpha2.LeaseCandidate); ok {
if leasecandidate.Spec.PingTime != nil && leasecandidate.Spec.PingTime.After(leasecandidate.Spec.RenewTime.Time) {
lc.enqueueLease()
}
@ -184,17 +184,17 @@ func (c *LeaseCandidate) ensureLease(ctx context.Context) error {
return nil
}
func (c *LeaseCandidate) newLeaseCandidate() *v1alpha1.LeaseCandidate {
lc := &v1alpha1.LeaseCandidate{
func (c *LeaseCandidate) newLeaseCandidate() *v1alpha2.LeaseCandidate {
lc := &v1alpha2.LeaseCandidate{
ObjectMeta: metav1.ObjectMeta{
Name: c.name,
Namespace: c.namespace,
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: c.leaseName,
BinaryVersion: c.binaryVersion,
EmulationVersion: c.emulationVersion,
PreferredStrategies: c.preferredStrategies,
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: c.leaseName,
BinaryVersion: c.binaryVersion,
EmulationVersion: c.emulationVersion,
Strategy: c.strategy,
},
}
lc.Spec.RenewTime = &metav1.MicroTime{Time: c.clock.Now()}

View file

@ -53,7 +53,7 @@ func TestLeaseCandidateCreation(t *testing.T) {
tc.leaseName,
tc.binaryVersion,
tc.emulationVersion,
[]v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
v1.OldestEmulationVersion,
)
if err != nil {
t.Fatal(err)
@ -87,7 +87,7 @@ func TestLeaseCandidateAck(t *testing.T) {
tc.leaseName,
tc.binaryVersion,
tc.emulationVersion,
[]v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
v1.OldestEmulationVersion,
)
if err != nil {
t.Fatal(err)
@ -101,12 +101,12 @@ func TestLeaseCandidateAck(t *testing.T) {
// Update PingTime and verify that the client renews
ensureAfter := &metav1.MicroTime{Time: time.Now()}
lc, err := client.CoordinationV1alpha1().LeaseCandidates(tc.candidateNamespace).Get(ctx, tc.candidateName, metav1.GetOptions{})
lc, err := client.CoordinationV1alpha2().LeaseCandidates(tc.candidateNamespace).Get(ctx, tc.candidateName, metav1.GetOptions{})
if err == nil {
if lc.Spec.PingTime == nil {
c := lc.DeepCopy()
c.Spec.PingTime = &metav1.MicroTime{Time: time.Now()}
_, err = client.CoordinationV1alpha1().LeaseCandidates(tc.candidateNamespace).Update(ctx, c, metav1.UpdateOptions{})
_, err = client.CoordinationV1alpha2().LeaseCandidates(tc.candidateNamespace).Update(ctx, c, metav1.UpdateOptions{})
if err != nil {
t.Error(err)
}
@ -120,7 +120,7 @@ func TestLeaseCandidateAck(t *testing.T) {
func pollForLease(ctx context.Context, tc testcase, client *fake.Clientset, t *metav1.MicroTime) error {
return wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, 10*time.Second, true, func(ctx context.Context) (done bool, err error) {
lc, err := client.CoordinationV1alpha1().LeaseCandidates(tc.candidateNamespace).Get(ctx, tc.candidateName, metav1.GetOptions{})
lc, err := client.CoordinationV1alpha2().LeaseCandidates(tc.candidateNamespace).Get(ctx, tc.candidateName, metav1.GetOptions{})
if err != nil {
if errors.IsNotFound(err) {
return false, nil

View file

@ -24,7 +24,7 @@ import (
"time"
v1 "k8s.io/api/coordination/v1"
v1alpha1 "k8s.io/api/coordination/v1alpha1"
v1alpha2 "k8s.io/api/coordination/v1alpha2"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
@ -144,28 +144,28 @@ func TestLeaseCandidateCleanup(t *testing.T) {
if err != nil {
t.Fatal(err)
}
expiredLC := &v1alpha1.LeaseCandidate{
expiredLC := &v1alpha2.LeaseCandidate{
ObjectMeta: metav1.ObjectMeta{
Name: "expired",
Namespace: "default",
},
Spec: v1alpha1.LeaseCandidateSpec{
LeaseName: "foobaz",
BinaryVersion: "0.1.0",
EmulationVersion: "0.1.0",
PreferredStrategies: []v1.CoordinatedLeaseStrategy{v1.OldestEmulationVersion},
RenewTime: &metav1.MicroTime{Time: time.Now().Add(-2 * time.Hour)},
PingTime: &metav1.MicroTime{Time: time.Now().Add(-1 * time.Hour)},
Spec: v1alpha2.LeaseCandidateSpec{
LeaseName: "foobaz",
BinaryVersion: "0.1.0",
EmulationVersion: "0.1.0",
Strategy: v1.OldestEmulationVersion,
RenewTime: &metav1.MicroTime{Time: time.Now().Add(-2 * time.Hour)},
PingTime: &metav1.MicroTime{Time: time.Now().Add(-1 * time.Hour)},
},
}
ctx := context.Background()
_, err = clientset.CoordinationV1alpha1().LeaseCandidates("default").Create(ctx, expiredLC, metav1.CreateOptions{})
_, err = clientset.CoordinationV1alpha2().LeaseCandidates("default").Create(ctx, expiredLC, metav1.CreateOptions{})
if err != nil {
t.Fatal(err)
}
err = wait.PollUntilContextTimeout(ctx, 1000*time.Millisecond, 5*time.Second, true, func(ctx context.Context) (done bool, err error) {
_, err = clientset.CoordinationV1alpha1().LeaseCandidates("default").Get(ctx, "expired", metav1.GetOptions{})
_, err = clientset.CoordinationV1alpha2().LeaseCandidates("default").Get(ctx, "expired", metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return true, nil
}
@ -218,7 +218,7 @@ func (t *cleTest) createAndRunFakeController(name string, namespace string, targ
targetLease,
binaryVersion,
compatibilityVersion,
[]v1.CoordinatedLeaseStrategy{"OldestEmulationVersion"},
v1.OldestEmulationVersion,
)
if err != nil {
t.t.Error(err)

View file

@ -172,10 +172,10 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
},
// --
// k8s.io/kubernetes/pkg/apis/coordination/v1alpha1
gvr("coordination.k8s.io", "v1alpha1", "leasecandidates"): {
Stub: `{"metadata": {"name": "leasecandidatev1alpha1"}, "spec": {"leaseName": "lease", "binaryVersion": "0.1.0", "emulationVersion": "0.1.0", "preferredStrategies": ["OldestEmulationVersion"]}}`,
ExpectedEtcdPath: "/registry/leasecandidates/" + namespace + "/leasecandidatev1alpha1",
// k8s.io/kubernetes/pkg/apis/coordination/v1alpha2
gvr("coordination.k8s.io", "v1alpha2", "leasecandidates"): {
Stub: `{"metadata": {"name": "leasecandidatev1alpha2"}, "spec": {"leaseName": "lease", "binaryVersion": "0.1.0", "emulationVersion": "0.1.0", "strategy": "OldestEmulationVersion"}}`,
ExpectedEtcdPath: "/registry/leasecandidates/" + namespace + "/leasecandidatev1alpha2",
},
// --