Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete plugin function and rename NewPluginLogger function #226

Merged
merged 2 commits into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions pkg/cloudprovider/aws/block_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,6 @@ func (b *blockStore) IsVolumeReady(volumeID, volumeAZ string) (ready bool, err e
return *res.Volumes[0].State == ec2.VolumeStateAvailable, nil
}

func (b *blockStore) ListSnapshots(tagFilters map[string]string) ([]string, error) {
req := &ec2.DescribeSnapshotsInput{}

for k, v := range tagFilters {
filter := &ec2.Filter{}
filter.SetName(k)
filter.SetValues([]*string{&v})

req.Filters = append(req.Filters, filter)
}

var ret []string
err := b.ec2.DescribeSnapshotsPages(req, func(res *ec2.DescribeSnapshotsOutput, lastPage bool) bool {
for _, snapshot := range res.Snapshots {
ret = append(ret, *snapshot.SnapshotId)
}

return !lastPage
})
if err != nil {
return nil, errors.WithStack(err)
}

return ret, nil
}

func (b *blockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
req := &ec2.CreateSnapshotInput{
VolumeId: &volumeID,
Expand Down
34 changes: 0 additions & 34 deletions pkg/cloudprovider/azure/block_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,40 +200,6 @@ func (b *blockStore) IsVolumeReady(volumeID, volumeAZ string) (ready bool, err e
return *res.ProvisioningState == "Succeeded", nil
}

func (b *blockStore) ListSnapshots(tagFilters map[string]string) ([]string, error) {
res, err := b.snaps.ListByResourceGroup(b.resourceGroup)
if err != nil {
return nil, errors.WithStack(err)
}

if res.Value == nil {
return nil, errors.New("nil Value returned from ListByResourceGroup call")
}

ret := make([]string, 0, len(*res.Value))
Snapshot:
for _, snap := range *res.Value {
if snap.Tags == nil && len(tagFilters) > 0 {
continue
}
if snap.ID == nil {
continue
}

// Azure doesn't offer tag-filtering through the API so we have to manually
// filter results. Require all filter keys to be present, with matching vals.
for filterKey, filterVal := range tagFilters {
if val, ok := (*snap.Tags)[filterKey]; !ok || val == nil || *val != filterVal {
continue Snapshot
}
}

ret = append(ret, *snap.Name)
}

return ret, nil
}

func (b *blockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
fullDiskName := getFullDiskName(b.subscription, b.resourceGroup, volumeID)
// snapshot names must be <= 80 characters long
Expand Down
28 changes: 0 additions & 28 deletions pkg/cloudprovider/gcp/block_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package gcp

import (
"strings"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -115,33 +114,6 @@ func (b *blockStore) IsVolumeReady(volumeID, volumeAZ string) (ready bool, err e
return disk.Status == "READY", nil
}

func (b *blockStore) ListSnapshots(tagFilters map[string]string) ([]string, error) {
useParentheses := len(tagFilters) > 1
subFilters := make([]string, 0, len(tagFilters))

for k, v := range tagFilters {
fs := k + " eq " + v
if useParentheses {
fs = "(" + fs + ")"
}
subFilters = append(subFilters, fs)
}

filter := strings.Join(subFilters, " ")

res, err := b.gce.Snapshots.List(b.project).Filter(filter).Do()
if err != nil {
return nil, errors.WithStack(err)
}

ret := make([]string, 0, len(res.Items))
for _, snap := range res.Items {
ret = append(ret, snap.Name)
}

return ret, nil
}

func (b *blockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
// snapshot names must adhere to RFC1035 and be 1-63 characters
// long
Expand Down
18 changes: 0 additions & 18 deletions pkg/cloudprovider/snapshot_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ import (
// SnapshotService exposes Ark-specific operations for snapshotting and restoring block
// volumes.
type SnapshotService interface {
// GetAllSnapshots returns a slice of all snapshots found in the cloud API that
// are tagged with Ark metadata. Returns an error if a problem is encountered accessing
// the cloud API.
GetAllSnapshots() ([]string, error)

// CreateSnapshot triggers a snapshot for the specified cloud volume and tags it with metadata.
// it returns the cloud snapshot ID, or an error if a problem is encountered triggering the snapshot via
// the cloud API.
Expand Down Expand Up @@ -99,19 +94,6 @@ func (sr *snapshotService) CreateVolumeFromSnapshot(snapshotID string, volumeTyp
}
}

func (sr *snapshotService) GetAllSnapshots() ([]string, error) {
tags := map[string]string{
snapshotTagKey: snapshotTagVal,
}

res, err := sr.blockStore.ListSnapshots(tags)
if err != nil {
return nil, err
}

return res, nil
}

func (sr *snapshotService) CreateSnapshot(volumeID, volumeAZ string) (string, error) {
tags := map[string]string{
snapshotTagKey: snapshotTagVal,
Expand Down
3 changes: 0 additions & 3 deletions pkg/cloudprovider/storage_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ type BlockStore interface {
// IsVolumeReady returns whether the specified volume is ready to be used.
IsVolumeReady(volumeID, volumeAZ string) (ready bool, err error)

// ListSnapshots returns a list of all snapshots matching the specified set of tag key/values.
ListSnapshots(tagFilters map[string]string) ([]string, error)

// CreateSnapshot creates a snapshot of the specified block volume, and applies the provided
// set of tags to the snapshot.
CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (snapshotID string, err error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

func NewCommand() *cobra.Command {
logger := arkplugin.NewPluginLogger()
logger := arkplugin.NewLogger()

objectStores := map[string]cloudprovider.ObjectStore{
"aws": aws.NewObjectStore(),
Expand Down
20 changes: 0 additions & 20 deletions pkg/plugin/block_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,6 @@ func (c *BlockStoreGRPCClient) IsVolumeReady(volumeID, volumeAZ string) (bool, e
return res.Ready, nil
}

// ListSnapshots returns a list of all snapshots matching the specified set of tag key/values.
func (c *BlockStoreGRPCClient) ListSnapshots(tagFilters map[string]string) ([]string, error) {
res, err := c.grpcClient.ListSnapshots(context.Background(), &proto.ListSnapshotsRequest{TagFilters: tagFilters})
if err != nil {
return nil, err
}

return res.SnapshotIDs, nil
}

// CreateSnapshot creates a snapshot of the specified block volume, and applies the provided
// set of tags to the snapshot.
func (c *BlockStoreGRPCClient) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
Expand Down Expand Up @@ -267,16 +257,6 @@ func (s *BlockStoreGRPCServer) IsVolumeReady(ctx context.Context, req *proto.IsV
return &proto.IsVolumeReadyResponse{Ready: ready}, nil
}

// ListSnapshots returns a list of all snapshots matching the specified set of tag key/values.
func (s *BlockStoreGRPCServer) ListSnapshots(ctx context.Context, req *proto.ListSnapshotsRequest) (*proto.ListSnapshotsResponse, error) {
snapshotIDs, err := s.impl.ListSnapshots(req.TagFilters)
if err != nil {
return nil, err
}

return &proto.ListSnapshotsResponse{SnapshotIDs: snapshotIDs}, nil
}

// CreateSnapshot creates a snapshot of the specified block volume, and applies the provided
// set of tags to the snapshot.
func (s *BlockStoreGRPCServer) CreateSnapshot(ctx context.Context, req *proto.CreateSnapshotRequest) (*proto.CreateSnapshotResponse, error) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/plugin/generated/BackupItemAction.pb.go

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

Loading