Skip to content

Commit

Permalink
Merge pull request #15 from andrewsykim/consistent-sidecars
Browse files Browse the repository at this point in the history
Refactor external-resizer to use csi-lib-utils/rpc
  • Loading branch information
k8s-ci-robot authored Feb 28, 2019
2 parents 237ba95 + 54266cb commit 1e1a9b9
Show file tree
Hide file tree
Showing 9 changed files with 861 additions and 337 deletions.
20 changes: 12 additions & 8 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
name = "k8s.io/klog"
version = "0.1.0"

[[constraint]]
branch = "master"
[[override]]
name = "github.com/container-storage-interface/spec"
branch = "master"

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

[prune]
non-go = true
Expand Down
59 changes: 59 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2019 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 client

import (
"context"

"github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/grpc"
)

// Client is a gRPC client connect to remote CSI driver and abstracts all CSI calls.
type Client interface {
// Expand expands the volume to a new size at least as big as requestBytes.
// It returns the new size and whether the volume need expand operation on the node.
Expand(ctx context.Context, volumeID string, requestBytes int64, secrets map[string]string) (int64, bool, error)
}

// New creates a new CSI client.
func New(conn *grpc.ClientConn) Client {
return &client{
ctrlClient: csi.NewControllerClient(conn),
}
}

type client struct {
ctrlClient csi.ControllerClient
}

func (c *client) Expand(
ctx context.Context,
volumeID string,
requestBytes int64,
secrets map[string]string) (int64, bool, error) {
req := &csi.ControllerExpandVolumeRequest{
Secrets: secrets,
VolumeId: volumeID,
CapacityRange: &csi.CapacityRange{RequiredBytes: requestBytes},
}
resp, err := c.ctrlClient.ControllerExpandVolume(ctx, req)
if err != nil {
return 0, false, err
}
return resp.CapacityBytes, resp.NodeExpansionRequired, nil
}
198 changes: 0 additions & 198 deletions pkg/csi/client.go

This file was deleted.

Loading

0 comments on commit 1e1a9b9

Please sign in to comment.