From ac6ce1581c717328f8c6e126952d76c2dce648bf Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Thu, 6 Jun 2024 19:33:45 +0530 Subject: [PATCH] Add client side code for rpc calls Signed-off-by: Rewant Soni --- go.mod | 2 +- go.sum | 4 +- metrics/go.mod | 2 +- metrics/go.sum | 4 +- metrics/vendor/modules.txt | 2 +- services/provider/api/client/client.go | 64 ++++++ services/provider/api/go.mod | 1 + services/provider/api/go.sum | 2 + .../api/vendor/k8s.io/apimachinery/LICENSE | 202 ++++++++++++++++++ .../k8s.io/apimachinery/pkg/types/doc.go | 18 ++ .../apimachinery/pkg/types/namespacedname.go | 50 +++++ .../k8s.io/apimachinery/pkg/types/nodename.go | 43 ++++ .../k8s.io/apimachinery/pkg/types/patch.go | 29 +++ .../k8s.io/apimachinery/pkg/types/uid.go | 22 ++ services/provider/api/vendor/modules.txt | 3 + .../services/provider/api/v4/client/client.go | 64 ++++++ vendor/modules.txt | 2 +- 17 files changed, 506 insertions(+), 8 deletions(-) create mode 100644 services/provider/api/vendor/k8s.io/apimachinery/LICENSE create mode 100644 services/provider/api/vendor/k8s.io/apimachinery/pkg/types/doc.go create mode 100644 services/provider/api/vendor/k8s.io/apimachinery/pkg/types/namespacedname.go create mode 100644 services/provider/api/vendor/k8s.io/apimachinery/pkg/types/nodename.go create mode 100644 services/provider/api/vendor/k8s.io/apimachinery/pkg/types/patch.go create mode 100644 services/provider/api/vendor/k8s.io/apimachinery/pkg/types/uid.go diff --git a/go.mod b/go.mod index 9e0ad26d67..c3e231d4c3 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( gotest.tools/v3 v3.5.1 k8s.io/api v0.31.0 k8s.io/apiextensions-apiserver v0.31.0 - k8s.io/apimachinery v0.31.0 + k8s.io/apimachinery v0.31.1 k8s.io/client-go v0.31.0 k8s.io/klog/v2 v2.130.1 k8s.io/utils v0.0.0-20240821151609-f90d01438635 diff --git a/go.sum b/go.sum index 09b1681e5b..43b922d593 100644 --- a/go.sum +++ b/go.sum @@ -1599,8 +1599,8 @@ k8s.io/apimachinery v0.20.4/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRp k8s.io/apimachinery v0.23.3/go.mod h1:BEuFMMBaIbcOqVIJqNZJXGFTP4W6AycEpb5+m/97hrM= k8s.io/apimachinery v0.23.5/go.mod h1:BEuFMMBaIbcOqVIJqNZJXGFTP4W6AycEpb5+m/97hrM= k8s.io/apimachinery v0.26.0/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74= -k8s.io/apimachinery v0.31.0 h1:m9jOiSr3FoSSL5WO9bjm1n6B9KROYYgNZOb4tyZ1lBc= -k8s.io/apimachinery v0.31.0/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U= +k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= k8s.io/apiserver v0.18.3/go.mod h1:tHQRmthRPLUtwqsOnJJMoI8SW3lnoReZeE861lH8vUw= k8s.io/apiserver v0.20.1/go.mod h1:ro5QHeQkgMS7ZGpvf4tSMx6bBOgPfE+f52KwvXfScaU= k8s.io/apiserver v0.31.0 h1:p+2dgJjy+bk+B1Csz+mc2wl5gHwvNkC9QJV+w55LVrY= diff --git a/metrics/go.mod b/metrics/go.mod index 44ce2d1f95..f3feeb624f 100644 --- a/metrics/go.mod +++ b/metrics/go.mod @@ -37,7 +37,7 @@ require ( go.uber.org/zap v1.27.0 golang.org/x/net v0.28.0 k8s.io/api v0.31.0 - k8s.io/apimachinery v0.31.0 + k8s.io/apimachinery v0.31.1 k8s.io/client-go v0.31.0 k8s.io/klog/v2 v2.130.1 ) diff --git a/metrics/go.sum b/metrics/go.sum index d1b14b7bb6..0fab4b0417 100644 --- a/metrics/go.sum +++ b/metrics/go.sum @@ -1443,8 +1443,8 @@ k8s.io/apimachinery v0.20.4/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRp k8s.io/apimachinery v0.23.3/go.mod h1:BEuFMMBaIbcOqVIJqNZJXGFTP4W6AycEpb5+m/97hrM= k8s.io/apimachinery v0.23.5/go.mod h1:BEuFMMBaIbcOqVIJqNZJXGFTP4W6AycEpb5+m/97hrM= k8s.io/apimachinery v0.26.0/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74= -k8s.io/apimachinery v0.31.0 h1:m9jOiSr3FoSSL5WO9bjm1n6B9KROYYgNZOb4tyZ1lBc= -k8s.io/apimachinery v0.31.0/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U= +k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= k8s.io/apiserver v0.18.3/go.mod h1:tHQRmthRPLUtwqsOnJJMoI8SW3lnoReZeE861lH8vUw= k8s.io/apiserver v0.20.1/go.mod h1:ro5QHeQkgMS7ZGpvf4tSMx6bBOgPfE+f52KwvXfScaU= k8s.io/client-go v0.18.3/go.mod h1:4a/dpQEvzAhT1BbuWW09qvIaGw6Gbu1gZYiQZIi1DMw= diff --git a/metrics/vendor/modules.txt b/metrics/vendor/modules.txt index 5295a2fb29..c4d5ee3e82 100644 --- a/metrics/vendor/modules.txt +++ b/metrics/vendor/modules.txt @@ -503,7 +503,7 @@ k8s.io/api/storage/v1 k8s.io/api/storage/v1alpha1 k8s.io/api/storage/v1beta1 k8s.io/api/storagemigration/v1alpha1 -# k8s.io/apimachinery v0.31.0 +# k8s.io/apimachinery v0.31.1 ## explicit; go 1.22.0 k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/errors diff --git a/services/provider/api/client/client.go b/services/provider/api/client/client.go index fe05dff2e8..8c3a23cbe6 100644 --- a/services/provider/api/client/client.go +++ b/services/provider/api/client/client.go @@ -11,6 +11,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "k8s.io/apimachinery/pkg/types" ) type OCSProviderClient struct { @@ -211,3 +212,66 @@ func (cc *OCSProviderClient) ReportStatus(ctx context.Context, consumerUUID stri return cc.Client.ReportStatus(apiCtx, req) } + +func (cc *OCSProviderClient) OnboardStorageClusterPeer(ctx context.Context, onboardingTicket, storageClusterPeerUID string, remoteStorageCluster types.NamespacedName) (*pb.OnboardStorageClusterPeerResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.OnboardStorageClusterPeerRequest{ + OnboardingTicket: onboardingTicket, + StorageClusterPeerUID: storageClusterPeerUID, + RemoteStorageCluster: remoteStorageCluster.String(), + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.OnboardStorageClusterPeer(apiCtx, req) +} + +func (cc *OCSProviderClient) OffboardStorageClusterPeer(ctx context.Context, storageClusterPeerUID string) (*pb.OffboardStorageClusterPeerResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.OffboardStorageClusterPeerRequest{ + StorageClusterPeerUID: storageClusterPeerUID, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.OffboardStorageClusterPeer(apiCtx, req) +} + +func (cc *OCSProviderClient) AcknowledgeOnboardingStorageClusterPeer(ctx context.Context, storageClusterPeerUID string) (*pb.AcknowledgeOnboardingStorageClusterPeerResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("provider client is closed") + } + + req := &pb.AcknowledgeOnboardingStorageClusterPeerRequest{ + StorageClusterPeerUID: storageClusterPeerUID, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.AcknowledgeOnboardingStorageClusterPeer(apiCtx, req) +} + +func (cc *OCSProviderClient) GetMirroringInfo(ctx context.Context, storageClusterPeerUID string, blockPoolNames []string) (*pb.MirroringInfoResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.MirroringInfoRequest{ + StorageClusterPeerUID: storageClusterPeerUID, + BlockPoolNames: blockPoolNames, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.GetMirroringInfo(apiCtx, req) +} diff --git a/services/provider/api/go.mod b/services/provider/api/go.mod index 0c11692bbc..cb3364b8d1 100644 --- a/services/provider/api/go.mod +++ b/services/provider/api/go.mod @@ -5,6 +5,7 @@ go 1.22.5 require ( google.golang.org/grpc v1.66.0 google.golang.org/protobuf v1.34.2 + k8s.io/apimachinery v0.31.0 ) require ( diff --git a/services/provider/api/go.sum b/services/provider/api/go.sum index a7a0b60322..b3cb9facdb 100644 --- a/services/provider/api/go.sum +++ b/services/provider/api/go.sum @@ -12,3 +12,5 @@ google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +k8s.io/apimachinery v0.31.0 h1:m9jOiSr3FoSSL5WO9bjm1n6B9KROYYgNZOb4tyZ1lBc= +k8s.io/apimachinery v0.31.0/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= diff --git a/services/provider/api/vendor/k8s.io/apimachinery/LICENSE b/services/provider/api/vendor/k8s.io/apimachinery/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/services/provider/api/vendor/k8s.io/apimachinery/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/doc.go b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/doc.go new file mode 100644 index 0000000000..5667fa9921 --- /dev/null +++ b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2015 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 types implements various generic types used throughout kubernetes. +package types // import "k8s.io/apimachinery/pkg/types" diff --git a/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/namespacedname.go b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/namespacedname.go new file mode 100644 index 0000000000..db18ce1ce2 --- /dev/null +++ b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/namespacedname.go @@ -0,0 +1,50 @@ +/* +Copyright 2015 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 types + +// NamespacedName comprises a resource name, with a mandatory namespace, +// rendered as "/". Being a type captures intent and +// helps make sure that UIDs, namespaced names and non-namespaced names +// do not get conflated in code. For most use cases, namespace and name +// will already have been format validated at the API entry point, so we +// don't do that here. Where that's not the case (e.g. in testing), +// consider using NamespacedNameOrDie() in testing.go in this package. + +type NamespacedName struct { + Namespace string + Name string +} + +const ( + Separator = '/' +) + +// String returns the general purpose string representation +func (n NamespacedName) String() string { + return n.Namespace + string(Separator) + n.Name +} + +// MarshalLog emits a struct containing required key/value pair +func (n NamespacedName) MarshalLog() interface{} { + return struct { + Name string `json:"name"` + Namespace string `json:"namespace,omitempty"` + }{ + Name: n.Name, + Namespace: n.Namespace, + } +} diff --git a/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/nodename.go b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/nodename.go new file mode 100644 index 0000000000..cff9ca6717 --- /dev/null +++ b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/nodename.go @@ -0,0 +1,43 @@ +/* +Copyright 2015 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 types + +// NodeName is a type that holds a api.Node's Name identifier. +// Being a type captures intent and helps make sure that the node name +// is not confused with similar concepts (the hostname, the cloud provider id, +// the cloud provider name etc) +// +// To clarify the various types: +// +// - Node.Name is the Name field of the Node in the API. This should be stored in a NodeName. +// Unfortunately, because Name is part of ObjectMeta, we can't store it as a NodeName at the API level. +// +// - Hostname is the hostname of the local machine (from uname -n). +// However, some components allow the user to pass in a --hostname-override flag, +// which will override this in most places. In the absence of anything more meaningful, +// kubelet will use Hostname as the Node.Name when it creates the Node. +// +// * The cloudproviders have the own names: GCE has InstanceName, AWS has InstanceId. +// +// For GCE, InstanceName is the Name of an Instance object in the GCE API. On GCE, Instance.Name becomes the +// Hostname, and thus it makes sense also to use it as the Node.Name. But that is GCE specific, and it is up +// to the cloudprovider how to do this mapping. +// +// For AWS, the InstanceID is not yet suitable for use as a Node.Name, so we actually use the +// PrivateDnsName for the Node.Name. And this is _not_ always the same as the hostname: if +// we are using a custom DHCP domain it won't be. +type NodeName string diff --git a/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/patch.go b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/patch.go new file mode 100644 index 0000000000..fe8ecaaffa --- /dev/null +++ b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/patch.go @@ -0,0 +1,29 @@ +/* +Copyright 2015 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 types + +// Similarly to above, these are constants to support HTTP PATCH utilized by +// both the client and server that didn't make sense for a whole package to be +// dedicated to. +type PatchType string + +const ( + JSONPatchType PatchType = "application/json-patch+json" + MergePatchType PatchType = "application/merge-patch+json" + StrategicMergePatchType PatchType = "application/strategic-merge-patch+json" + ApplyPatchType PatchType = "application/apply-patch+yaml" +) diff --git a/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/uid.go b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/uid.go new file mode 100644 index 0000000000..869339222e --- /dev/null +++ b/services/provider/api/vendor/k8s.io/apimachinery/pkg/types/uid.go @@ -0,0 +1,22 @@ +/* +Copyright 2015 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 types + +// UID is a type that holds unique ID values, including UUIDs. Because we +// don't ONLY use UUIDs, this is an alias to string. Being a type captures +// intent and helps make sure that UIDs and names do not get conflated. +type UID string diff --git a/services/provider/api/vendor/modules.txt b/services/provider/api/vendor/modules.txt index b480f56702..69aaf416e5 100644 --- a/services/provider/api/vendor/modules.txt +++ b/services/provider/api/vendor/modules.txt @@ -111,3 +111,6 @@ google.golang.org/protobuf/types/descriptorpb google.golang.org/protobuf/types/known/anypb google.golang.org/protobuf/types/known/durationpb google.golang.org/protobuf/types/known/timestamppb +# k8s.io/apimachinery v0.31.0 +## explicit; go 1.22.0 +k8s.io/apimachinery/pkg/types diff --git a/vendor/github.com/red-hat-storage/ocs-operator/services/provider/api/v4/client/client.go b/vendor/github.com/red-hat-storage/ocs-operator/services/provider/api/v4/client/client.go index fe05dff2e8..8c3a23cbe6 100644 --- a/vendor/github.com/red-hat-storage/ocs-operator/services/provider/api/v4/client/client.go +++ b/vendor/github.com/red-hat-storage/ocs-operator/services/provider/api/v4/client/client.go @@ -11,6 +11,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "k8s.io/apimachinery/pkg/types" ) type OCSProviderClient struct { @@ -211,3 +212,66 @@ func (cc *OCSProviderClient) ReportStatus(ctx context.Context, consumerUUID stri return cc.Client.ReportStatus(apiCtx, req) } + +func (cc *OCSProviderClient) OnboardStorageClusterPeer(ctx context.Context, onboardingTicket, storageClusterPeerUID string, remoteStorageCluster types.NamespacedName) (*pb.OnboardStorageClusterPeerResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.OnboardStorageClusterPeerRequest{ + OnboardingTicket: onboardingTicket, + StorageClusterPeerUID: storageClusterPeerUID, + RemoteStorageCluster: remoteStorageCluster.String(), + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.OnboardStorageClusterPeer(apiCtx, req) +} + +func (cc *OCSProviderClient) OffboardStorageClusterPeer(ctx context.Context, storageClusterPeerUID string) (*pb.OffboardStorageClusterPeerResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.OffboardStorageClusterPeerRequest{ + StorageClusterPeerUID: storageClusterPeerUID, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.OffboardStorageClusterPeer(apiCtx, req) +} + +func (cc *OCSProviderClient) AcknowledgeOnboardingStorageClusterPeer(ctx context.Context, storageClusterPeerUID string) (*pb.AcknowledgeOnboardingStorageClusterPeerResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("provider client is closed") + } + + req := &pb.AcknowledgeOnboardingStorageClusterPeerRequest{ + StorageClusterPeerUID: storageClusterPeerUID, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.AcknowledgeOnboardingStorageClusterPeer(apiCtx, req) +} + +func (cc *OCSProviderClient) GetMirroringInfo(ctx context.Context, storageClusterPeerUID string, blockPoolNames []string) (*pb.MirroringInfoResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.MirroringInfoRequest{ + StorageClusterPeerUID: storageClusterPeerUID, + BlockPoolNames: blockPoolNames, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.GetMirroringInfo(apiCtx, req) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 0e025ee93f..e269198f51 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -704,7 +704,7 @@ k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1 k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1 -# k8s.io/apimachinery v0.31.0 +# k8s.io/apimachinery v0.31.1 ## explicit; go 1.22.0 k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/errors