Skip to content

Commit

Permalink
Update efs to lib 4, fix klog vs glog crash
Browse files Browse the repository at this point in the history
  • Loading branch information
wongma7 committed Oct 24, 2019
1 parent e35bdf4 commit 56eb88c
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 28 deletions.
3 changes: 1 addition & 2 deletions aws/efs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.11.1-alpine AS builder
FROM golang:1.13.1-alpine AS builder

ENV CGO_ENABLED=0

COPY vendor /go/src/github.com/kubernetes-incubator/external-storage/vendor
COPY aws/efs /go/src/github.com/kubernetes-incubator/external-storage/aws/efs

WORKDIR /go/src/github.com/kubernetes-incubator/external-storage/aws/efs
Expand Down
16 changes: 1 addition & 15 deletions aws/efs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,7 @@ IMAGE = $(REGISTRY)efs-provisioner:$(VERSION)
MUTABLE_IMAGE = $(REGISTRY)efs-provisioner:latest

all build:
@mkdir -p .go/src/github.com/kubernetes-incubator/external-storage/aws/efs/vendor
@mkdir -p .go/bin
@mkdir -p .go/stdlib
docker run \
--rm \
-e "CGO_ENABLED=0" \
-u $$(id -u):$$(id -g) \
-v $$(pwd)/.go:/go \
-v $$(pwd):/go/src/github.com/kubernetes-incubator/external-storage/aws/efs \
-v "$${PWD%/*/*}/vendor":/go/src/github.com/kubernetes-incubator/external-storage/vendor \
-v $$(pwd):/go/bin \
-v $$(pwd)/.go/stdlib:/usr/local/go/pkg/linux_amd64_asdf \
-w /go/src/github.com/kubernetes-incubator/external-storage/aws/efs \
golang:1.11.1-alpine \
go install -installsuffix "asdf" ./cmd/efs-provisioner
go build ./cmd/efs-provisioner
.PHONY: all build

container: quick-container
Expand Down
22 changes: 11 additions & 11 deletions aws/efs/cmd/efs-provisioner/efs-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/efs"
"github.com/kubernetes-sigs/sig-storage-lib-external-provisioner/controller"
"github.com/kubernetes-sigs/sig-storage-lib-external-provisioner/gidallocator"
"github.com/kubernetes-sigs/sig-storage-lib-external-provisioner/mount"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/klog"
"sigs.k8s.io/sig-storage-lib-external-provisioner/controller"
"sigs.k8s.io/sig-storage-lib-external-provisioner/gidallocator"
"sigs.k8s.io/sig-storage-lib-external-provisioner/mount"
)

const (
Expand Down Expand Up @@ -124,13 +124,13 @@ func getMount(dnsName string) (string, string, error) {
var _ controller.Provisioner = &efsProvisioner{}

// Provision creates a storage asset and returns a PV object representing it.
func (p *efsProvisioner) Provision(options controller.VolumeOptions) (*v1.PersistentVolume, error) {
func (p *efsProvisioner) Provision(options controller.ProvisionOptions) (*v1.PersistentVolume, error) {
if options.PVC.Spec.Selector != nil {
return nil, fmt.Errorf("claim.Spec.Selector is not supported")
}

gidAllocate := true
for k, v := range options.Parameters {
for k, v := range options.StorageClass.Parameters {
switch strings.ToLower(k) {
case "gidmin":
// Let allocator handle
Expand Down Expand Up @@ -160,16 +160,16 @@ func (p *efsProvisioner) Provision(options controller.VolumeOptions) (*v1.Persis
}

mountOptions := []string{"vers=4.1"}
if options.MountOptions != nil {
mountOptions = options.MountOptions
if options.StorageClass.MountOptions != nil {
mountOptions = options.StorageClass.MountOptions
}

pv := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: options.PVName,
},
Spec: v1.PersistentVolumeSpec{
PersistentVolumeReclaimPolicy: options.PersistentVolumeReclaimPolicy,
PersistentVolumeReclaimPolicy: *options.StorageClass.ReclaimPolicy,
AccessModes: options.PVC.Spec.AccessModes,
Capacity: v1.ResourceList{
v1.ResourceName(v1.ResourceStorage): options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)],
Expand Down Expand Up @@ -222,16 +222,16 @@ func (p *efsProvisioner) createVolume(path string, gid *int) error {
return nil
}

func (p *efsProvisioner) getLocalPath(options controller.VolumeOptions) string {
func (p *efsProvisioner) getLocalPath(options controller.ProvisionOptions) string {
return path.Join(p.mountpoint, p.getDirectoryName(options))
}

func (p *efsProvisioner) getRemotePath(options controller.VolumeOptions) string {
func (p *efsProvisioner) getRemotePath(options controller.ProvisionOptions) string {
sourcePath := path.Clean(strings.Replace(p.source, p.dnsName+":", "", 1))
return path.Join(sourcePath, p.getDirectoryName(options))
}

func (p *efsProvisioner) getDirectoryName(options controller.VolumeOptions) string {
func (p *efsProvisioner) getDirectoryName(options controller.ProvisionOptions) string {
return options.PVC.Name + "-" + options.PVName
}

Expand Down
17 changes: 17 additions & 0 deletions aws/efs/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module github.com/kubernetes-incubator/external-storage/aws/efs

go 1.12

require (
github.com/aws/aws-sdk-go v1.25.8
github.com/miekg/dns v1.1.22 // indirect
github.com/prometheus/client_golang v1.1.0 // indirect
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc // indirect
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
k8s.io/api v0.0.0-20191003000013-35e20aa79eb8
k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655
k8s.io/client-go v0.0.0-20191003000419-f68efa97b39e
k8s.io/klog v1.0.0
k8s.io/utils v0.0.0-20190923111123-69764acb6e8e // indirect
sigs.k8s.io/sig-storage-lib-external-provisioner v4.0.1+incompatible
)
Loading

0 comments on commit 56eb88c

Please sign in to comment.