diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 8069e5e7980..249e5ae1304 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -684,6 +684,170 @@ }, "type": "object" }, + "io.k8s.api.apiserverinternal.v1alpha1.ServerStorageVersion": { + "description": "An API server instance reports the version it can decode and the version it encodes objects to when persisting objects in the backend.", + "properties": { + "apiServerID": { + "description": "The ID of the reporting API server.", + "type": "string" + }, + "decodableVersions": { + "description": "The API server can decode objects encoded in these versions. The encodingVersion must be included in the decodableVersions.", + "items": { + "type": "string" + }, + "type": "array", + "x-kubernetes-list-type": "set" + }, + "encodingVersion": { + "description": "The API server encodes the object to this version when persisting it in the backend (e.g., etcd).", + "type": "string" + } + }, + "type": "object" + }, + "io.k8s.api.apiserverinternal.v1alpha1.StorageVersion": { + "description": "\n Storage version of a specific resource.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta", + "description": "The name is .." + }, + "spec": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersionSpec", + "description": "Spec is an empty spec. It is here to comply with Kubernetes API style." + }, + "status": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersionStatus", + "description": "API server instances report the version they can decode and the version they encode objects to when persisting objects in the backend." + } + }, + "required": [ + "spec", + "status" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + ] + }, + "io.k8s.api.apiserverinternal.v1alpha1.StorageVersionCondition": { + "description": "Describes the state of the storageVersion at a certain point.", + "properties": { + "lastTransitionTime": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time", + "description": "Last time the condition transitioned from one status to another." + }, + "message": { + "description": "A human readable message indicating details about the transition.", + "type": "string" + }, + "observedGeneration": { + "description": "If set, this represents the .metadata.generation that the condition was set based upon.", + "format": "int64", + "type": "integer" + }, + "reason": { + "description": "The reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of the condition.", + "type": "string" + } + }, + "required": [ + "type", + "status", + "reason" + ], + "type": "object" + }, + "io.k8s.api.apiserverinternal.v1alpha1.StorageVersionList": { + "description": "A list of StorageVersions.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "items": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + }, + "type": "array" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "required": [ + "items" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersionList", + "version": "v1alpha1" + } + ] + }, + "io.k8s.api.apiserverinternal.v1alpha1.StorageVersionSpec": { + "description": "StorageVersionSpec is an empty spec.", + "type": "object" + }, + "io.k8s.api.apiserverinternal.v1alpha1.StorageVersionStatus": { + "description": "API server instances report the versions they can decode and the version they encode objects to when persisting objects in the backend.", + "properties": { + "commonEncodingVersion": { + "description": "If all API server instances agree on the same encoding storage version, then this field is set to that version. Otherwise this field is left empty. API servers should finish updating its storageVersionStatus entry before serving write operations, so that this field will be in sync with the reality.", + "type": "string" + }, + "conditions": { + "description": "The latest available observations of the storageVersion's state.", + "items": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersionCondition" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map" + }, + "storageVersions": { + "description": "The reported versions per API server instance.", + "items": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.ServerStorageVersion" + }, + "type": "array", + "x-kubernetes-list-map-keys": [ + "apiServerID" + ], + "x-kubernetes-list-type": "map" + } + }, + "type": "object" + }, "io.k8s.api.apps.v1.ControllerRevision": { "description": "ControllerRevision implements an immutable snapshot of state data. Clients are responsible for serializing and deserializing the objects that contain their internal state. Once a ControllerRevision has been successfully created, it can not be updated. The API Server will fail validation of all requests that attempt to mutate the Data field. ControllerRevisions may, however, be deleted. Note that, due to its use by both the DaemonSet and StatefulSet controllers for update and rollback, this object is beta. However, it may be subject to name and representation changes in future releases, and clients should not depend on its stability. It is primarily for internal use by controllers.", "properties": { @@ -17568,6 +17732,11 @@ "kind": "DeleteOptions", "version": "v1alpha1" }, + { + "group": "internal.apiserver.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, { "group": "networking.k8s.io", "kind": "DeleteOptions", @@ -18219,6 +18388,11 @@ "kind": "WatchEvent", "version": "v1alpha1" }, + { + "group": "internal.apiserver.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, { "group": "networking.k8s.io", "kind": "WatchEvent", @@ -73046,6 +73220,1077 @@ } ] }, + "/apis/internal.apiserver.k8s.io/": { + "get": { + "consumes": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "description": "get information of a group", + "operationId": "getInternalApiserverAPIGroup", + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.APIGroup" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver" + ] + } + }, + "/apis/internal.apiserver.k8s.io/v1alpha1/": { + "get": { + "consumes": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "description": "get available resources", + "operationId": "getInternalApiserverV1alpha1APIResources", + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.APIResourceList" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ] + } + }, + "/apis/internal.apiserver.k8s.io/v1alpha1/storageversions": { + "delete": { + "consumes": [ + "*/*" + ], + "description": "delete collection of StorageVersion", + "operationId": "deleteInternalApiserverV1alpha1CollectionStorageVersion", + "parameters": [ + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions" + } + }, + { + "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.", + "in": "query", + "name": "continue", + "type": "string", + "uniqueItems": true + }, + { + "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", + "in": "query", + "name": "dryRun", + "type": "string", + "uniqueItems": true + }, + { + "description": "A selector to restrict the list of returned objects by their fields. Defaults to everything.", + "in": "query", + "name": "fieldSelector", + "type": "string", + "uniqueItems": true + }, + { + "description": "The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.", + "in": "query", + "name": "gracePeriodSeconds", + "type": "integer", + "uniqueItems": true + }, + { + "description": "A selector to restrict the list of returned objects by their labels. Defaults to everything.", + "in": "query", + "name": "labelSelector", + "type": "string", + "uniqueItems": true + }, + { + "description": "limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.\n\nThe server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.", + "in": "query", + "name": "limit", + "type": "integer", + "uniqueItems": true + }, + { + "description": "Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.", + "in": "query", + "name": "orphanDependents", + "type": "boolean", + "uniqueItems": true + }, + { + "description": "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.", + "in": "query", + "name": "propagationPolicy", + "type": "string", + "uniqueItems": true + }, + { + "description": "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + "in": "query", + "name": "resourceVersion", + "type": "string", + "uniqueItems": true + }, + { + "description": "resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + "in": "query", + "name": "resourceVersionMatch", + "type": "string", + "uniqueItems": true + }, + { + "description": "Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity.", + "in": "query", + "name": "timeoutSeconds", + "type": "integer", + "uniqueItems": true + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Status" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "deletecollection", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + }, + "get": { + "consumes": [ + "*/*" + ], + "description": "list or watch objects of kind StorageVersion", + "operationId": "listInternalApiserverV1alpha1StorageVersion", + "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. If the feature gate WatchBookmarks is not enabled in apiserver, this field is ignored.", + "in": "query", + "name": "allowWatchBookmarks", + "type": "boolean", + "uniqueItems": true + }, + { + "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.", + "in": "query", + "name": "continue", + "type": "string", + "uniqueItems": true + }, + { + "description": "A selector to restrict the list of returned objects by their fields. Defaults to everything.", + "in": "query", + "name": "fieldSelector", + "type": "string", + "uniqueItems": true + }, + { + "description": "A selector to restrict the list of returned objects by their labels. Defaults to everything.", + "in": "query", + "name": "labelSelector", + "type": "string", + "uniqueItems": true + }, + { + "description": "limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.\n\nThe server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.", + "in": "query", + "name": "limit", + "type": "integer", + "uniqueItems": true + }, + { + "description": "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + "in": "query", + "name": "resourceVersion", + "type": "string", + "uniqueItems": true + }, + { + "description": "resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + "in": "query", + "name": "resourceVersionMatch", + "type": "string", + "uniqueItems": true + }, + { + "description": "Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity.", + "in": "query", + "name": "timeoutSeconds", + "type": "integer", + "uniqueItems": true + }, + { + "description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.", + "in": "query", + "name": "watch", + "type": "boolean", + "uniqueItems": true + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf", + "application/json;stream=watch", + "application/vnd.kubernetes.protobuf;stream=watch" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersionList" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "list", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + }, + "parameters": [ + { + "description": "If 'true', then the output is pretty printed.", + "in": "query", + "name": "pretty", + "type": "string", + "uniqueItems": true + } + ], + "post": { + "consumes": [ + "*/*" + ], + "description": "create a StorageVersion", + "operationId": "createInternalApiserverV1alpha1StorageVersion", + "parameters": [ + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + { + "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", + "in": "query", + "name": "dryRun", + "type": "string", + "uniqueItems": true + }, + { + "description": "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.", + "in": "query", + "name": "fieldManager", + "type": "string", + "uniqueItems": true + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "202": { + "description": "Accepted", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "post", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + } + }, + "/apis/internal.apiserver.k8s.io/v1alpha1/storageversions/{name}": { + "delete": { + "consumes": [ + "*/*" + ], + "description": "delete a StorageVersion", + "operationId": "deleteInternalApiserverV1alpha1StorageVersion", + "parameters": [ + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions" + } + }, + { + "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", + "in": "query", + "name": "dryRun", + "type": "string", + "uniqueItems": true + }, + { + "description": "The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.", + "in": "query", + "name": "gracePeriodSeconds", + "type": "integer", + "uniqueItems": true + }, + { + "description": "Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.", + "in": "query", + "name": "orphanDependents", + "type": "boolean", + "uniqueItems": true + }, + { + "description": "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.", + "in": "query", + "name": "propagationPolicy", + "type": "string", + "uniqueItems": true + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Status" + } + }, + "202": { + "description": "Accepted", + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Status" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "delete", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + }, + "get": { + "consumes": [ + "*/*" + ], + "description": "read the specified StorageVersion", + "operationId": "readInternalApiserverV1alpha1StorageVersion", + "parameters": [ + { + "description": "Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'. Deprecated. Planned for removal in 1.18.", + "in": "query", + "name": "exact", + "type": "boolean", + "uniqueItems": true + }, + { + "description": "Should this value be exported. Export strips fields that a user can not specify. Deprecated. Planned for removal in 1.18.", + "in": "query", + "name": "export", + "type": "boolean", + "uniqueItems": true + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "get", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + }, + "parameters": [ + { + "description": "name of the StorageVersion", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "uniqueItems": true + }, + { + "description": "If 'true', then the output is pretty printed.", + "in": "query", + "name": "pretty", + "type": "string", + "uniqueItems": true + } + ], + "patch": { + "consumes": [ + "application/json-patch+json", + "application/merge-patch+json", + "application/strategic-merge-patch+json", + "application/apply-patch+yaml" + ], + "description": "partially update the specified StorageVersion", + "operationId": "patchInternalApiserverV1alpha1StorageVersion", + "parameters": [ + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Patch" + } + }, + { + "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", + "in": "query", + "name": "dryRun", + "type": "string", + "uniqueItems": true + }, + { + "description": "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is required for apply requests (application/apply-patch) but optional for non-apply patch types (JsonPatch, MergePatch, StrategicMergePatch).", + "in": "query", + "name": "fieldManager", + "type": "string", + "uniqueItems": true + }, + { + "description": "Force is going to \"force\" Apply requests. It means user will re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply patch requests.", + "in": "query", + "name": "force", + "type": "boolean", + "uniqueItems": true + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "patch", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + }, + "put": { + "consumes": [ + "*/*" + ], + "description": "replace the specified StorageVersion", + "operationId": "replaceInternalApiserverV1alpha1StorageVersion", + "parameters": [ + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + { + "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", + "in": "query", + "name": "dryRun", + "type": "string", + "uniqueItems": true + }, + { + "description": "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.", + "in": "query", + "name": "fieldManager", + "type": "string", + "uniqueItems": true + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "put", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + } + }, + "/apis/internal.apiserver.k8s.io/v1alpha1/storageversions/{name}/status": { + "get": { + "consumes": [ + "*/*" + ], + "description": "read status of the specified StorageVersion", + "operationId": "readInternalApiserverV1alpha1StorageVersionStatus", + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "get", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + }, + "parameters": [ + { + "description": "name of the StorageVersion", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "uniqueItems": true + }, + { + "description": "If 'true', then the output is pretty printed.", + "in": "query", + "name": "pretty", + "type": "string", + "uniqueItems": true + } + ], + "patch": { + "consumes": [ + "application/json-patch+json", + "application/merge-patch+json", + "application/strategic-merge-patch+json", + "application/apply-patch+yaml" + ], + "description": "partially update status of the specified StorageVersion", + "operationId": "patchInternalApiserverV1alpha1StorageVersionStatus", + "parameters": [ + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Patch" + } + }, + { + "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", + "in": "query", + "name": "dryRun", + "type": "string", + "uniqueItems": true + }, + { + "description": "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is required for apply requests (application/apply-patch) but optional for non-apply patch types (JsonPatch, MergePatch, StrategicMergePatch).", + "in": "query", + "name": "fieldManager", + "type": "string", + "uniqueItems": true + }, + { + "description": "Force is going to \"force\" Apply requests. It means user will re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply patch requests.", + "in": "query", + "name": "force", + "type": "boolean", + "uniqueItems": true + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "patch", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + }, + "put": { + "consumes": [ + "*/*" + ], + "description": "replace status of the specified StorageVersion", + "operationId": "replaceInternalApiserverV1alpha1StorageVersionStatus", + "parameters": [ + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + { + "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", + "in": "query", + "name": "dryRun", + "type": "string", + "uniqueItems": true + }, + { + "description": "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.", + "in": "query", + "name": "fieldManager", + "type": "string", + "uniqueItems": true + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/io.k8s.api.apiserverinternal.v1alpha1.StorageVersion" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "put", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + } + }, + "/apis/internal.apiserver.k8s.io/v1alpha1/watch/storageversions": { + "get": { + "consumes": [ + "*/*" + ], + "description": "watch individual changes to a list of StorageVersion. deprecated: use the 'watch' parameter with a list operation instead.", + "operationId": "watchInternalApiserverV1alpha1StorageVersionList", + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf", + "application/json;stream=watch", + "application/vnd.kubernetes.protobuf;stream=watch" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.WatchEvent" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "watchlist", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + }, + "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. If the feature gate WatchBookmarks is not enabled in apiserver, this field is ignored.", + "in": "query", + "name": "allowWatchBookmarks", + "type": "boolean", + "uniqueItems": true + }, + { + "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.", + "in": "query", + "name": "continue", + "type": "string", + "uniqueItems": true + }, + { + "description": "A selector to restrict the list of returned objects by their fields. Defaults to everything.", + "in": "query", + "name": "fieldSelector", + "type": "string", + "uniqueItems": true + }, + { + "description": "A selector to restrict the list of returned objects by their labels. Defaults to everything.", + "in": "query", + "name": "labelSelector", + "type": "string", + "uniqueItems": true + }, + { + "description": "limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.\n\nThe server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.", + "in": "query", + "name": "limit", + "type": "integer", + "uniqueItems": true + }, + { + "description": "If 'true', then the output is pretty printed.", + "in": "query", + "name": "pretty", + "type": "string", + "uniqueItems": true + }, + { + "description": "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + "in": "query", + "name": "resourceVersion", + "type": "string", + "uniqueItems": true + }, + { + "description": "resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + "in": "query", + "name": "resourceVersionMatch", + "type": "string", + "uniqueItems": true + }, + { + "description": "Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity.", + "in": "query", + "name": "timeoutSeconds", + "type": "integer", + "uniqueItems": true + }, + { + "description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.", + "in": "query", + "name": "watch", + "type": "boolean", + "uniqueItems": true + } + ] + }, + "/apis/internal.apiserver.k8s.io/v1alpha1/watch/storageversions/{name}": { + "get": { + "consumes": [ + "*/*" + ], + "description": "watch changes to an object of kind StorageVersion. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.", + "operationId": "watchInternalApiserverV1alpha1StorageVersion", + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf", + "application/json;stream=watch", + "application/vnd.kubernetes.protobuf;stream=watch" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.WatchEvent" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "internalApiserver_v1alpha1" + ], + "x-kubernetes-action": "watch", + "x-kubernetes-group-version-kind": { + "group": "internal.apiserver.k8s.io", + "kind": "StorageVersion", + "version": "v1alpha1" + } + }, + "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. If the feature gate WatchBookmarks is not enabled in apiserver, this field is ignored.", + "in": "query", + "name": "allowWatchBookmarks", + "type": "boolean", + "uniqueItems": true + }, + { + "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.", + "in": "query", + "name": "continue", + "type": "string", + "uniqueItems": true + }, + { + "description": "A selector to restrict the list of returned objects by their fields. Defaults to everything.", + "in": "query", + "name": "fieldSelector", + "type": "string", + "uniqueItems": true + }, + { + "description": "A selector to restrict the list of returned objects by their labels. Defaults to everything.", + "in": "query", + "name": "labelSelector", + "type": "string", + "uniqueItems": true + }, + { + "description": "limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.\n\nThe server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.", + "in": "query", + "name": "limit", + "type": "integer", + "uniqueItems": true + }, + { + "description": "name of the StorageVersion", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "uniqueItems": true + }, + { + "description": "If 'true', then the output is pretty printed.", + "in": "query", + "name": "pretty", + "type": "string", + "uniqueItems": true + }, + { + "description": "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + "in": "query", + "name": "resourceVersion", + "type": "string", + "uniqueItems": true + }, + { + "description": "resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + "in": "query", + "name": "resourceVersionMatch", + "type": "string", + "uniqueItems": true + }, + { + "description": "Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity.", + "in": "query", + "name": "timeoutSeconds", + "type": "integer", + "uniqueItems": true + }, + { + "description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.", + "in": "query", + "name": "watch", + "type": "boolean", + "uniqueItems": true + } + ] + }, "/apis/networking.k8s.io/": { "get": { "consumes": [ diff --git a/cmd/kube-apiserver/app/aggregator.go b/cmd/kube-apiserver/app/aggregator.go index 14af4103ea5..f4a1bcc5a89 100644 --- a/cmd/kube-apiserver/app/aggregator.go +++ b/cmd/kube-apiserver/app/aggregator.go @@ -275,6 +275,7 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{ {Group: "discovery.k8s.io", Version: "v1beta1"}: {group: 16200, version: 12}, {Group: "discovery.k8s.io", Version: "v1alpha1"}: {group: 16200, version: 9}, {Group: "flowcontrol.apiserver.k8s.io", Version: "v1alpha1"}: {group: 16100, version: 9}, + {Group: "internal.apiserver.k8s.io", Version: "v1alpha1"}: {group: 16000, version: 9}, // Append a new group to the end of the list if unsure. // You can use min(existing group)-100 as the initial value for a group. // Version can be set to 9 (to have space around) for a new group. diff --git a/pkg/apis/apiserverinternal/install/BUILD b/pkg/apis/apiserverinternal/install/BUILD index 6b5d8498fd0..b71549916de 100644 --- a/pkg/apis/apiserverinternal/install/BUILD +++ b/pkg/apis/apiserverinternal/install/BUILD @@ -6,6 +6,7 @@ go_library( importpath = "k8s.io/kubernetes/pkg/apis/apiserverinternal/install", visibility = ["//visibility:public"], deps = [ + "//pkg/api/legacyscheme:go_default_library", "//pkg/apis/apiserverinternal:go_default_library", "//pkg/apis/apiserverinternal/v1alpha1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", diff --git a/pkg/apis/apiserverinternal/install/install.go b/pkg/apis/apiserverinternal/install/install.go index cf82ccfe730..9a3905644e0 100644 --- a/pkg/apis/apiserverinternal/install/install.go +++ b/pkg/apis/apiserverinternal/install/install.go @@ -21,10 +21,15 @@ package install import ( "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/apiserverinternal" "k8s.io/kubernetes/pkg/apis/apiserverinternal/v1alpha1" ) +func init() { + Install(legacyscheme.Scheme) +} + // Install registers the API group and adds types to a scheme func Install(scheme *runtime.Scheme) { utilruntime.Must(apiserverinternal.AddToScheme(scheme)) diff --git a/pkg/apis/apiserverinternal/validation/BUILD b/pkg/apis/apiserverinternal/validation/BUILD index b8b4a51f1d7..f7e6cef73ab 100644 --- a/pkg/apis/apiserverinternal/validation/BUILD +++ b/pkg/apis/apiserverinternal/validation/BUILD @@ -7,6 +7,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/apis/apiserverinternal:go_default_library", + "//pkg/apis/core/validation:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/validation:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", diff --git a/pkg/apis/apiserverinternal/validation/validation.go b/pkg/apis/apiserverinternal/validation/validation.go index b045d24ba70..6f2e73c91fe 100644 --- a/pkg/apis/apiserverinternal/validation/validation.go +++ b/pkg/apis/apiserverinternal/validation/validation.go @@ -25,10 +25,42 @@ import ( utilvalidation "k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/kubernetes/pkg/apis/apiserverinternal" + apivalidation "k8s.io/kubernetes/pkg/apis/core/validation" ) // ValidateStorageVersion validate the storage version object. func ValidateStorageVersion(sv *apiserverinternal.StorageVersion) field.ErrorList { + var allErrs field.ErrorList + allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&sv.ObjectMeta, false, ValidateStorageVersionName, field.NewPath("metadata"))...) + allErrs = append(allErrs, validateStorageVersionStatus(sv.Status, field.NewPath("status"))...) + return allErrs +} + +// ValidateStorageVersionName is a ValidateNameFunc for storage version names +func ValidateStorageVersionName(name string, prefix bool) []string { + var allErrs []string + idx := strings.LastIndex(name, ".") + if idx < 0 { + allErrs = append(allErrs, "name must be in the form of .") + } else { + for _, msg := range utilvalidation.IsDNS1123Subdomain(name[:idx]) { + allErrs = append(allErrs, "the group segment "+msg) + } + for _, msg := range utilvalidation.IsDNS1035Label(name[idx+1:]) { + allErrs = append(allErrs, "the resource segment "+msg) + } + } + return allErrs +} + +// ValidateStorageVersionUpdate tests if an update to a StorageVersion is valid. +func ValidateStorageVersionUpdate(sv, oldSV *apiserverinternal.StorageVersion) field.ErrorList { + // no error since StorageVersionSpec is an empty spec + return field.ErrorList{} +} + +// ValidateStorageVersionStatusUpdate tests if an update to a StorageVersionStatus is valid. +func ValidateStorageVersionStatusUpdate(sv, oldSV *apiserverinternal.StorageVersion) field.ErrorList { var allErrs field.ErrorList allErrs = append(allErrs, validateStorageVersionStatus(sv.Status, field.NewPath("status"))...) return allErrs diff --git a/pkg/apis/apiserverinternal/validation/validation_test.go b/pkg/apis/apiserverinternal/validation/validation_test.go index c349d1828cf..87b8cd7fe80 100644 --- a/pkg/apis/apiserverinternal/validation/validation_test.go +++ b/pkg/apis/apiserverinternal/validation/validation_test.go @@ -284,3 +284,66 @@ func TestValidateStorageVersionCondition(t *testing.T) { } } } + +func TestValidateStorageVersionName(t *testing.T) { + cases := []struct { + name string + expectedErr string + }{ + { + name: "", + expectedErr: `name must be in the form of .`, + }, + { + name: "pods", + expectedErr: `name must be in the form of .`, + }, + { + name: "core.pods", + expectedErr: "", + }, + { + name: "authentication.k8s.io.tokenreviews", + expectedErr: "", + }, + { + name: strings.Repeat("x", 253) + ".tokenreviews", + expectedErr: "", + }, + { + name: strings.Repeat("x", 254) + ".tokenreviews", + expectedErr: `the group segment must be no more than 253 characters`, + }, + { + name: "authentication.k8s.io." + strings.Repeat("x", 63), + expectedErr: "", + }, + { + name: "authentication.k8s.io." + strings.Repeat("x", 64), + expectedErr: `the resource segment must be no more than 63 characters`, + }, + } + for _, tc := range cases { + errs := ValidateStorageVersionName(tc.name, false) + if errs == nil && len(tc.expectedErr) == 0 { + continue + } + if errs != nil && len(tc.expectedErr) == 0 { + t.Errorf("unexpected error %v", errs) + continue + } + if errs == nil && len(tc.expectedErr) != 0 { + t.Errorf("unexpected empty error") + continue + } + found := false + for _, msg := range errs { + if msg == tc.expectedErr { + found = true + } + } + if !found { + t.Errorf("expected error to contain %s, got %v", tc.expectedErr, errs) + } + } +} diff --git a/pkg/controlplane/BUILD b/pkg/controlplane/BUILD index dad2be2ad92..0bb1de76813 100644 --- a/pkg/controlplane/BUILD +++ b/pkg/controlplane/BUILD @@ -44,6 +44,7 @@ go_library( "//pkg/kubeapiserver/options:go_default_library", "//pkg/kubelet/client:go_default_library", "//pkg/registry/admissionregistration/rest:go_default_library", + "//pkg/registry/apiserverinternal/rest:go_default_library", "//pkg/registry/apps/rest:go_default_library", "//pkg/registry/authentication/rest:go_default_library", "//pkg/registry/authorization/rest:go_default_library", @@ -72,6 +73,7 @@ go_library( "//pkg/util/node:go_default_library", "//staging/src/k8s.io/api/admissionregistration/v1:go_default_library", "//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library", + "//staging/src/k8s.io/api/apiserverinternal/v1alpha1:go_default_library", "//staging/src/k8s.io/api/apps/v1:go_default_library", "//staging/src/k8s.io/api/authentication/v1:go_default_library", "//staging/src/k8s.io/api/authentication/v1beta1:go_default_library", diff --git a/pkg/controlplane/master.go b/pkg/controlplane/master.go index cf53bdf4bb1..85be9a77946 100644 --- a/pkg/controlplane/master.go +++ b/pkg/controlplane/master.go @@ -27,6 +27,7 @@ import ( admissionregistrationv1 "k8s.io/api/admissionregistration/v1" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + apiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" appsv1 "k8s.io/api/apps/v1" authenticationv1 "k8s.io/api/authentication/v1" authenticationv1beta1 "k8s.io/api/authentication/v1beta1" @@ -93,6 +94,7 @@ import ( // RESTStorage installers admissionregistrationrest "k8s.io/kubernetes/pkg/registry/admissionregistration/rest" + apiserverinternalrest "k8s.io/kubernetes/pkg/registry/apiserverinternal/rest" appsrest "k8s.io/kubernetes/pkg/registry/apps/rest" authenticationrest "k8s.io/kubernetes/pkg/registry/authentication/rest" authorizationrest "k8s.io/kubernetes/pkg/registry/authorization/rest" @@ -415,6 +417,7 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget) // TODO: describe the priority all the way down in the RESTStorageProviders and plumb it back through the various discovery // handlers that we have. restStorageProviders := []RESTStorageProvider{ + apiserverinternalrest.StorageProvider{}, authenticationrest.RESTStorageProvider{Authenticator: c.GenericConfig.Authentication.Authenticator, APIAudiences: c.GenericConfig.Authentication.APIAudiences}, authorizationrest.RESTStorageProvider{Authorizer: c.GenericConfig.Authorization.Authorizer, RuleResolver: c.GenericConfig.RuleResolver}, autoscalingrest.RESTStorageProvider{}, @@ -633,6 +636,7 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig { ) // disable alpha versions explicitly so we have a full list of what's possible to serve ret.DisableVersions( + apiserverinternalv1alpha1.SchemeGroupVersion, batchapiv2alpha1.SchemeGroupVersion, nodev1alpha1.SchemeGroupVersion, rbacv1alpha1.SchemeGroupVersion, diff --git a/pkg/printers/internalversion/BUILD b/pkg/printers/internalversion/BUILD index dae3120f513..975c9a14815 100644 --- a/pkg/printers/internalversion/BUILD +++ b/pkg/printers/internalversion/BUILD @@ -14,6 +14,7 @@ go_test( ], embed = [":go_default_library"], deps = [ + "//pkg/apis/apiserverinternal:go_default_library", "//pkg/apis/apps:go_default_library", "//pkg/apis/autoscaling:go_default_library", "//pkg/apis/batch:go_default_library", @@ -47,6 +48,7 @@ go_library( importpath = "k8s.io/kubernetes/pkg/printers/internalversion", deps = [ "//pkg/apis/admissionregistration:go_default_library", + "//pkg/apis/apiserverinternal:go_default_library", "//pkg/apis/apps:go_default_library", "//pkg/apis/apps/install:go_default_library", "//pkg/apis/authentication/install:go_default_library", @@ -83,6 +85,7 @@ go_library( "//pkg/features:go_default_library", "//pkg/printers:go_default_library", "//pkg/util/node:go_default_library", + "//staging/src/k8s.io/api/apiserverinternal/v1alpha1:go_default_library", "//staging/src/k8s.io/api/apps/v1beta1:go_default_library", "//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library", "//staging/src/k8s.io/api/batch/v1:go_default_library", diff --git a/pkg/printers/internalversion/printers.go b/pkg/printers/internalversion/printers.go index 9aea4aee9f6..a5ad60763ae 100644 --- a/pkg/printers/internalversion/printers.go +++ b/pkg/printers/internalversion/printers.go @@ -25,6 +25,7 @@ import ( "strings" "time" + apiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" appsv1beta1 "k8s.io/api/apps/v1beta1" autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" batchv1 "k8s.io/api/batch/v1" @@ -48,6 +49,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/kubernetes/pkg/apis/admissionregistration" + "k8s.io/kubernetes/pkg/apis/apiserverinternal" "k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/batch" @@ -571,6 +573,15 @@ func AddHandlers(h printers.PrintHandler) { } h.TableHandler(priorityLevelColumnDefinitions, printPriorityLevelConfiguration) h.TableHandler(priorityLevelColumnDefinitions, printPriorityLevelConfigurationList) + + storageVersionColumnDefinitions := []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]}, + {Name: "CommonEncodingVersion", Type: "string", Description: apiserverinternalv1alpha1.StorageVersionStatus{}.SwaggerDoc()["commonEncodingVersion"]}, + {Name: "StorageVersions", Type: "string", Description: apiserverinternalv1alpha1.StorageVersionStatus{}.SwaggerDoc()["storageVersions"]}, + {Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]}, + } + h.TableHandler(storageVersionColumnDefinitions, printStorageVersion) + h.TableHandler(storageVersionColumnDefinitions, printStorageVersionList) } // Pass ports=nil for all ports. @@ -2477,6 +2488,46 @@ func printFlowSchemaList(list *flowcontrol.FlowSchemaList, options printers.Gene return rows, nil } +func printStorageVersion(obj *apiserverinternal.StorageVersion, options printers.GenerateOptions) ([]metav1.TableRow, error) { + row := metav1.TableRow{ + Object: runtime.RawExtension{Object: obj}, + } + commonEncodingVersion := "" + if obj.Status.CommonEncodingVersion != nil { + commonEncodingVersion = *obj.Status.CommonEncodingVersion + } + row.Cells = append(row.Cells, obj.Name, commonEncodingVersion, formatStorageVersions(obj.Status.StorageVersions), translateTimestampSince(obj.CreationTimestamp)) + return []metav1.TableRow{row}, nil +} + +func formatStorageVersions(storageVersions []apiserverinternal.ServerStorageVersion) string { + list := []string{} + max := 3 + more := false + count := 0 + for _, sv := range storageVersions { + if len(list) < max { + list = append(list, fmt.Sprintf("%s=%s", sv.APIServerID, sv.EncodingVersion)) + } else if len(list) == max { + more = true + } + count++ + } + return listWithMoreString(list, more, count, max) +} + +func printStorageVersionList(list *apiserverinternal.StorageVersionList, options printers.GenerateOptions) ([]metav1.TableRow, error) { + rows := make([]metav1.TableRow, 0, len(list.Items)) + for i := range list.Items { + r, err := printStorageVersion(&list.Items[i], options) + if err != nil { + return nil, err + } + rows = append(rows, r...) + } + return rows, nil +} + func printPriorityLevelConfiguration(obj *flowcontrol.PriorityLevelConfiguration, options printers.GenerateOptions) ([]metav1.TableRow, error) { row := metav1.TableRow{ Object: runtime.RawExtension{Object: obj}, diff --git a/pkg/printers/internalversion/printers_test.go b/pkg/printers/internalversion/printers_test.go index 1ecde89ad60..9765a88599e 100644 --- a/pkg/printers/internalversion/printers_test.go +++ b/pkg/printers/internalversion/printers_test.go @@ -27,6 +27,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/kubernetes/pkg/apis/apiserverinternal" "k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/batch" @@ -5311,3 +5312,125 @@ func TestPrintPriorityLevelConfiguration(t *testing.T) { } } } + +func TestPrintStorageVersion(t *testing.T) { + commonEncodingVersion := "v1" + tests := []struct { + sv apiserverinternal.StorageVersion + expected []metav1.TableRow + }{ + { + sv: apiserverinternal.StorageVersion{ + ObjectMeta: metav1.ObjectMeta{ + Name: "empty", + CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, + }, + Status: apiserverinternal.StorageVersionStatus{}, + }, + // Columns: Name, CommonEncodingVersion, StorageVersions, Age + expected: []metav1.TableRow{{Cells: []interface{}{"empty", "", "", "0s"}}}, + }, + { + sv: apiserverinternal.StorageVersion{ + ObjectMeta: metav1.ObjectMeta{ + Name: "valid", + CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, + }, + Status: apiserverinternal.StorageVersionStatus{ + StorageVersions: []apiserverinternal.ServerStorageVersion{ + { + APIServerID: "1", + EncodingVersion: "v1", + DecodableVersions: []string{"v1"}, + }, + { + APIServerID: "2", + EncodingVersion: "v1", + DecodableVersions: []string{"v1", "v2"}, + }, + }, + CommonEncodingVersion: &commonEncodingVersion, + }, + }, + // Columns: Name, CommonEncodingVersion, StorageVersions, Age + expected: []metav1.TableRow{{Cells: []interface{}{"valid", "v1", "1=v1,2=v1", "0s"}}}, + }, + { + sv: apiserverinternal.StorageVersion{ + ObjectMeta: metav1.ObjectMeta{ + Name: "disagree", + CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, + }, + Status: apiserverinternal.StorageVersionStatus{ + StorageVersions: []apiserverinternal.ServerStorageVersion{ + { + APIServerID: "1", + EncodingVersion: "v1", + DecodableVersions: []string{"v1"}, + }, + { + APIServerID: "2", + EncodingVersion: "v1", + DecodableVersions: []string{"v1", "v2"}, + }, + { + APIServerID: "3", + EncodingVersion: "v2", + DecodableVersions: []string{"v2"}, + }, + }, + }, + }, + // Columns: Name, CommonEncodingVersion, StorageVersions, Age + expected: []metav1.TableRow{{Cells: []interface{}{"disagree", "", "1=v1,2=v1,3=v2", "0s"}}}, + }, + { + sv: apiserverinternal.StorageVersion{ + ObjectMeta: metav1.ObjectMeta{ + Name: "agreeWithMore", + CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, + }, + Status: apiserverinternal.StorageVersionStatus{ + StorageVersions: []apiserverinternal.ServerStorageVersion{ + { + APIServerID: "1", + EncodingVersion: "v1", + DecodableVersions: []string{"v1"}, + }, + { + APIServerID: "2", + EncodingVersion: "v1", + DecodableVersions: []string{"v1", "v2"}, + }, + { + APIServerID: "3", + EncodingVersion: "v1", + DecodableVersions: []string{"v1", "v2"}, + }, + { + APIServerID: "4", + EncodingVersion: "v1", + DecodableVersions: []string{"v1", "v2", "v3alpha1"}, + }, + }, + CommonEncodingVersion: &commonEncodingVersion, + }, + }, + // Columns: Name, CommonEncodingVersion, StorageVersions, Age + expected: []metav1.TableRow{{Cells: []interface{}{"agreeWithMore", "v1", "1=v1,2=v1,3=v1 + 1 more...", "0s"}}}, + }, + } + + for i, test := range tests { + rows, err := printStorageVersion(&test.sv, printers.GenerateOptions{}) + if err != nil { + t.Fatal(err) + } + for i := range rows { + rows[i].Object.Object = nil + } + if !reflect.DeepEqual(test.expected, rows) { + t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) + } + } +} diff --git a/pkg/registry/BUILD b/pkg/registry/BUILD index 2ae4eb3cc14..1a0f3269e0b 100644 --- a/pkg/registry/BUILD +++ b/pkg/registry/BUILD @@ -25,6 +25,8 @@ filegroup( "//pkg/registry/admissionregistration/mutatingwebhookconfiguration:all-srcs", "//pkg/registry/admissionregistration/rest:all-srcs", "//pkg/registry/admissionregistration/validatingwebhookconfiguration:all-srcs", + "//pkg/registry/apiserverinternal/rest:all-srcs", + "//pkg/registry/apiserverinternal/storageversion:all-srcs", "//pkg/registry/apps/controllerrevision:all-srcs", "//pkg/registry/apps/daemonset:all-srcs", "//pkg/registry/apps/deployment:all-srcs", diff --git a/pkg/registry/apiserverinternal/rest/BUILD b/pkg/registry/apiserverinternal/rest/BUILD new file mode 100644 index 00000000000..9e081ef387e --- /dev/null +++ b/pkg/registry/apiserverinternal/rest/BUILD @@ -0,0 +1,32 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["storage.go"], + importpath = "k8s.io/kubernetes/pkg/registry/apiserverinternal/rest", + visibility = ["//visibility:public"], + deps = [ + "//pkg/api/legacyscheme:go_default_library", + "//pkg/apis/apiserverinternal:go_default_library", + "//pkg/registry/apiserverinternal/storageversion/storage:go_default_library", + "//staging/src/k8s.io/api/apiserverinternal/v1alpha1:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/server:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/server/storage:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/registry/apiserverinternal/rest/storage.go b/pkg/registry/apiserverinternal/rest/storage.go new file mode 100644 index 00000000000..e69e8cc56c1 --- /dev/null +++ b/pkg/registry/apiserverinternal/rest/storage.go @@ -0,0 +1,62 @@ +/* +Copyright 2020 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package rest + +import ( + apiserverv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" + "k8s.io/apiserver/pkg/registry/generic" + "k8s.io/apiserver/pkg/registry/rest" + genericapiserver "k8s.io/apiserver/pkg/server" + serverstorage "k8s.io/apiserver/pkg/server/storage" + "k8s.io/kubernetes/pkg/api/legacyscheme" + "k8s.io/kubernetes/pkg/apis/apiserverinternal" + storageversionstorage "k8s.io/kubernetes/pkg/registry/apiserverinternal/storageversion/storage" +) + +// StorageProvider is a REST storage provider for internal.apiserver.k8s.io +type StorageProvider struct{} + +// NewRESTStorage returns a StorageProvider +func (p StorageProvider) NewRESTStorage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (genericapiserver.APIGroupInfo, bool, error) { + apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(apiserverinternal.GroupName, legacyscheme.Scheme, legacyscheme.ParameterCodec, legacyscheme.Codecs) + + if apiResourceConfigSource.VersionEnabled(apiserverv1alpha1.SchemeGroupVersion) { + storageMap, err := p.v1alpha1Storage(apiResourceConfigSource, restOptionsGetter) + if err != nil { + return genericapiserver.APIGroupInfo{}, false, err + } + apiGroupInfo.VersionedResourcesStorageMap[apiserverv1alpha1.SchemeGroupVersion.Version] = storageMap + } + return apiGroupInfo, true, nil +} + +func (p StorageProvider) v1alpha1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (map[string]rest.Storage, error) { + storage := map[string]rest.Storage{} + s, status, err := storageversionstorage.NewREST(restOptionsGetter) + if err != nil { + return nil, err + } + storage["storageversions"] = s + storage["storageversions/status"] = status + + return storage, nil +} + +// GroupName is the group name for the storage provider +func (p StorageProvider) GroupName() string { + return apiserverinternal.GroupName +} diff --git a/pkg/registry/apiserverinternal/storageversion/BUILD b/pkg/registry/apiserverinternal/storageversion/BUILD new file mode 100644 index 00000000000..c9243163e7c --- /dev/null +++ b/pkg/registry/apiserverinternal/storageversion/BUILD @@ -0,0 +1,37 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "strategy.go", + ], + importpath = "k8s.io/kubernetes/pkg/registry/apiserverinternal/storageversion", + visibility = ["//visibility:public"], + deps = [ + "//pkg/api/legacyscheme:go_default_library", + "//pkg/apis/apiserverinternal:go_default_library", + "//pkg/apis/apiserverinternal/validation:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//pkg/registry/apiserverinternal/storageversion/storage:all-srcs", + ], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/registry/apiserverinternal/storageversion/doc.go b/pkg/registry/apiserverinternal/storageversion/doc.go new file mode 100644 index 00000000000..eb2775dc11f --- /dev/null +++ b/pkg/registry/apiserverinternal/storageversion/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2020 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package storageversion provides Registry interface and it's RESTStorage +// implementation for storing StorageVersion api objects. +package storageversion // import "k8s.io/kubernetes/pkg/registry/apiserverinternal/storageversion" diff --git a/pkg/registry/apiserverinternal/storageversion/storage/BUILD b/pkg/registry/apiserverinternal/storageversion/storage/BUILD new file mode 100644 index 00000000000..e6df631f1de --- /dev/null +++ b/pkg/registry/apiserverinternal/storageversion/storage/BUILD @@ -0,0 +1,34 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["storage.go"], + importpath = "k8s.io/kubernetes/pkg/registry/apiserverinternal/storageversion/storage", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/apiserverinternal:go_default_library", + "//pkg/printers:go_default_library", + "//pkg/printers/internalversion:go_default_library", + "//pkg/printers/storage:go_default_library", + "//pkg/registry/apiserverinternal/storageversion:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/registry/apiserverinternal/storageversion/storage/storage.go b/pkg/registry/apiserverinternal/storageversion/storage/storage.go new file mode 100644 index 00000000000..a6157b7b5a3 --- /dev/null +++ b/pkg/registry/apiserverinternal/storageversion/storage/storage.go @@ -0,0 +1,83 @@ +/* +Copyright 2020 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package storage + +import ( + "context" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/registry/generic" + genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" + "k8s.io/apiserver/pkg/registry/rest" + "k8s.io/kubernetes/pkg/apis/apiserverinternal" + "k8s.io/kubernetes/pkg/printers" + printersinternal "k8s.io/kubernetes/pkg/printers/internalversion" + printerstorage "k8s.io/kubernetes/pkg/printers/storage" + strategy "k8s.io/kubernetes/pkg/registry/apiserverinternal/storageversion" +) + +// REST implements a RESTStorage for storage version against etcd +type REST struct { + *genericregistry.Store +} + +// NewREST returns a RESTStorage object that will work against storageVersions +func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) { + store := &genericregistry.Store{ + NewFunc: func() runtime.Object { return &apiserverinternal.StorageVersion{} }, + NewListFunc: func() runtime.Object { return &apiserverinternal.StorageVersionList{} }, + ObjectNameFunc: func(obj runtime.Object) (string, error) { + return obj.(*apiserverinternal.StorageVersion).Name, nil + }, + DefaultQualifiedResource: apiserverinternal.Resource("storageversions"), + + CreateStrategy: strategy.Strategy, + UpdateStrategy: strategy.Strategy, + DeleteStrategy: strategy.Strategy, + TableConvertor: printerstorage.TableConvertor{TableGenerator: printers.NewTableGenerator().With(printersinternal.AddHandlers)}, + } + options := &generic.StoreOptions{RESTOptions: optsGetter} + if err := store.CompleteWithOptions(options); err != nil { + return nil, nil, err + } + statusStore := *store + statusStore.UpdateStrategy = strategy.StatusStrategy + return &REST{store}, &StatusREST{store: &statusStore}, nil +} + +// StatusREST implements the REST endpoint for changing the status of a storageVersion +type StatusREST struct { + store *genericregistry.Store +} + +// New creates a new StorageVersion object. +func (r *StatusREST) New() runtime.Object { + return &apiserverinternal.StorageVersion{} +} + +// Get retrieves the object from the storage. It is required to support Patch. +func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { + return r.store.Get(ctx, name, options) +} + +// Update alters the status subset of an object. +func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + // We are explicitly setting forceAllowCreate to false in the call to the underlying storage because + // subresources should never allow create on update. + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} diff --git a/pkg/registry/apiserverinternal/storageversion/strategy.go b/pkg/registry/apiserverinternal/storageversion/strategy.go new file mode 100644 index 00000000000..5a1f2982760 --- /dev/null +++ b/pkg/registry/apiserverinternal/storageversion/strategy.go @@ -0,0 +1,103 @@ +/* +Copyright 2020 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package storageversion + +import ( + "context" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/storage/names" + "k8s.io/kubernetes/pkg/api/legacyscheme" + "k8s.io/kubernetes/pkg/apis/apiserverinternal" + "k8s.io/kubernetes/pkg/apis/apiserverinternal/validation" +) + +// storageVersionStrategy implements verification logic for StorageVersion. +type storageVersionStrategy struct { + runtime.ObjectTyper + names.NameGenerator +} + +// Strategy is the default logic that applies when creating and updating StorageVersion objects. +var Strategy = storageVersionStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} + +// NamespaceScoped returns false because all StorageVersion's need to be cluster scoped +func (storageVersionStrategy) NamespaceScoped() bool { + return false +} + +// PrepareForCreate clears the status of an StorageVersion before creation. +func (storageVersionStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { + sv := obj.(*apiserverinternal.StorageVersion) + sv.Status = apiserverinternal.StorageVersionStatus{} +} + +// PrepareForUpdate clears fields that are not allowed to be set by end users on update. +func (storageVersionStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + sv := obj.(*apiserverinternal.StorageVersion) + sv.Status = old.(*apiserverinternal.StorageVersion).Status +} + +// Validate validates a new storageVersion. +func (storageVersionStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { + sv := obj.(*apiserverinternal.StorageVersion) + return validation.ValidateStorageVersion(sv) +} + +// Canonicalize normalizes the object after validation. +func (storageVersionStrategy) Canonicalize(obj runtime.Object) { +} + +// Does not allow creating a StorageVersion object with a PUT request. +func (storageVersionStrategy) AllowCreateOnUpdate() bool { + return false +} + +// ValidateUpdate is the default update validation for an end user. +func (storageVersionStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + newStorageVersion := obj.(*apiserverinternal.StorageVersion) + oldStorageVersion := old.(*apiserverinternal.StorageVersion) + validationErrorList := validation.ValidateStorageVersionUpdate(newStorageVersion, oldStorageVersion) + return validationErrorList +} + +// AllowUnconditionalUpdate is the default update policy for storageVersion objects. Status update should +// only be allowed if version match. +func (storageVersionStrategy) AllowUnconditionalUpdate() bool { + return false +} + +type storageVersionStatusStrategy struct { + storageVersionStrategy +} + +// StatusStrategy is the default logic invoked when updating object status. +var StatusStrategy = storageVersionStatusStrategy{Strategy} + +func (storageVersionStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { + newSV := obj.(*apiserverinternal.StorageVersion) + oldSV := old.(*apiserverinternal.StorageVersion) + + newSV.Spec = oldSV.Spec + metav1.ResetObjectMetaForStatus(&newSV.ObjectMeta, &oldSV.ObjectMeta) +} + +func (storageVersionStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { + return validation.ValidateStorageVersionStatusUpdate(obj.(*apiserverinternal.StorageVersion), old.(*apiserverinternal.StorageVersion)) +} diff --git a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/generated.proto b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/generated.proto index 0d499cf1432..539c8c9e2b2 100644 --- a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/generated.proto +++ b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/generated.proto @@ -102,7 +102,7 @@ message StorageVersionStatus { // The reported versions per API server instance. // +optional // +listType=map - // +listMapKey=apiserverID + // +listMapKey=apiServerID repeated ServerStorageVersion storageVersions = 1; // If all API server instances agree on the same encoding storage version, diff --git a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go index 0d80fcfb9fb..880091b6f82 100644 --- a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go +++ b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go @@ -47,7 +47,7 @@ type StorageVersionStatus struct { // The reported versions per API server instance. // +optional // +listType=map - // +listMapKey=apiserverID + // +listMapKey=apiServerID StorageVersions []ServerStorageVersion `json:"storageVersions,omitempty" protobuf:"bytes,1,opt,name=storageVersions"` // If all API server instances agree on the same encoding storage version, // then this field is set to that version. Otherwise this field is left empty. diff --git a/test/integration/apiserver/BUILD b/test/integration/apiserver/BUILD index bd02def97b2..b81f0486896 100644 --- a/test/integration/apiserver/BUILD +++ b/test/integration/apiserver/BUILD @@ -28,6 +28,7 @@ go_test( "//pkg/features:go_default_library", "//pkg/printers:go_default_library", "//pkg/printers/internalversion:go_default_library", + "//staging/src/k8s.io/api/apiserverinternal/v1alpha1:go_default_library", "//staging/src/k8s.io/api/apps/v1:go_default_library", "//staging/src/k8s.io/api/batch/v2alpha1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", diff --git a/test/integration/apiserver/apply/status_test.go b/test/integration/apiserver/apply/status_test.go index b23610db392..32b82735a3b 100644 --- a/test/integration/apiserver/apply/status_test.go +++ b/test/integration/apiserver/apply/status_test.go @@ -57,6 +57,7 @@ var statusData = map[schema.GroupVersionResource]string{ gvr("policy", "v1beta1", "poddisruptionbudgets"): `{"status": {"currentHealthy": 5}}`, gvr("certificates.k8s.io", "v1beta1", "certificatesigningrequests"): `{"status": {"conditions": [{"type": "MyStatus"}]}}`, gvr("certificates.k8s.io", "v1", "certificatesigningrequests"): `{"status": {"conditions": [{"type": "MyStatus", "status": "True"}]}}`, + gvr("internal.apiserver.k8s.io", "v1alpha1", "storageversions"): `{"status": {"commonEncodingVersion":"v1","storageVersions":[{"apiServerID":"1","decodableVersions":["v1","v2"],"encodingVersion":"v1"}],"conditions":[{"type":"AllEncodingVersionsEqual","status":"True","lastTransitionTime":"2020-01-01T00:00:00Z","reason":"allEncodingVersionsEqual","message":"all encoding versions are set to v1"}]}}`, } const statusDefault = `{"status": {"conditions": [{"type": "MyStatus", "status":"true"}]}}` @@ -69,6 +70,12 @@ var ignoreList = map[schema.GroupVersionResource]struct{}{ gvr("apiregistration.k8s.io", "v1", "apiservices"): {}, } +// Some status-only APIs have empty object on creation. Therefore we don't expect create_test +// managedFields for these APIs +var ignoreCreateManagementList = map[schema.GroupVersionResource]struct{}{ + gvr("internal.apiserver.k8s.io", "v1alpha1", "storageversions"): {}, +} + func gvr(g, v, r string) schema.GroupVersionResource { return schema.GroupVersionResource{Group: g, Version: v, Resource: r} } @@ -200,7 +207,11 @@ func TestApplyStatus(t *testing.T) { t.Fatalf("Couldn't find apply_status_test: %v", managedFields) } if !findManager(managedFields, "create_test") { - t.Fatalf("Couldn't find create_test: %v", managedFields) + if _, ok := ignoreCreateManagementList[mapping.Resource]; !ok { + t.Fatalf("Couldn't find create_test: %v", managedFields) + } + } else if _, ok := ignoreCreateManagementList[mapping.Resource]; ok { + t.Fatalf("found create_test in ignoreCreateManagementList resource: %v", managedFields) } if err := rsc.Delete(context.TODO(), name, *metav1.NewDeleteOptions(0)); err != nil { diff --git a/test/integration/apiserver/print_test.go b/test/integration/apiserver/print_test.go index 53f59dcaa1d..e0520200144 100644 --- a/test/integration/apiserver/print_test.go +++ b/test/integration/apiserver/print_test.go @@ -27,6 +27,7 @@ import ( "testing" "time" + apiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1" batchv2alpha1 "k8s.io/api/batch/v2alpha1" discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1" discoveryv1beta1 "k8s.io/api/discovery/v1beta1" @@ -172,6 +173,7 @@ func TestServerSidePrint(t *testing.T) { extensionsv1beta1.SchemeGroupVersion, nodev1alpha1.SchemeGroupVersion, flowcontrolv1alpha1.SchemeGroupVersion, + apiserverinternalv1alpha1.SchemeGroupVersion, }, []schema.GroupVersionResource{}, ) diff --git a/test/integration/etcd/data.go b/test/integration/etcd/data.go index c096ef7de62..b8525f4c3dd 100644 --- a/test/integration/etcd/data.go +++ b/test/integration/etcd/data.go @@ -508,6 +508,13 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes ExpectedEtcdPath: "/registry/runtimeclasses/rc2", }, // -- + + // k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1 + gvr("internal.apiserver.k8s.io", "v1alpha1", "storageversions"): { + Stub: `{"metadata":{"name":"sv1.test"},"spec":{}}`, + ExpectedEtcdPath: "/registry/storageversions/sv1.test", + }, + // -- } // add csinodes if CSINodeInfo feature gate is enabled