Skip to content

Commit 1e1a9b9

Browse files
authored
Merge pull request #15 from andrewsykim/consistent-sidecars
Refactor external-resizer to use csi-lib-utils/rpc
2 parents 237ba95 + 54266cb commit 1e1a9b9

File tree

9 files changed

+861
-337
lines changed

9 files changed

+861
-337
lines changed

Gopkg.lock

Lines changed: 12 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
name = "k8s.io/klog"
4141
version = "0.1.0"
4242

43-
[[constraint]]
44-
branch = "master"
43+
[[override]]
4544
name = "github.com/container-storage-interface/spec"
45+
branch = "master"
4646

4747
[[constraint]]
4848
name = "github.com/kubernetes-csi/csi-lib-utils"
49-
version = "0.2.0"
49+
version = ">=0.4.0-rc1"
5050

5151
[prune]
5252
non-go = true

pkg/client/client.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package client
18+
19+
import (
20+
"context"
21+
22+
"github.com/container-storage-interface/spec/lib/go/csi"
23+
"google.golang.org/grpc"
24+
)
25+
26+
// Client is a gRPC client connect to remote CSI driver and abstracts all CSI calls.
27+
type Client interface {
28+
// Expand expands the volume to a new size at least as big as requestBytes.
29+
// It returns the new size and whether the volume need expand operation on the node.
30+
Expand(ctx context.Context, volumeID string, requestBytes int64, secrets map[string]string) (int64, bool, error)
31+
}
32+
33+
// New creates a new CSI client.
34+
func New(conn *grpc.ClientConn) Client {
35+
return &client{
36+
ctrlClient: csi.NewControllerClient(conn),
37+
}
38+
}
39+
40+
type client struct {
41+
ctrlClient csi.ControllerClient
42+
}
43+
44+
func (c *client) Expand(
45+
ctx context.Context,
46+
volumeID string,
47+
requestBytes int64,
48+
secrets map[string]string) (int64, bool, error) {
49+
req := &csi.ControllerExpandVolumeRequest{
50+
Secrets: secrets,
51+
VolumeId: volumeID,
52+
CapacityRange: &csi.CapacityRange{RequiredBytes: requestBytes},
53+
}
54+
resp, err := c.ctrlClient.ControllerExpandVolume(ctx, req)
55+
if err != nil {
56+
return 0, false, err
57+
}
58+
return resp.CapacityBytes, resp.NodeExpansionRequired, nil
59+
}

pkg/csi/client.go

Lines changed: 0 additions & 198 deletions
This file was deleted.

0 commit comments

Comments
 (0)