Add original item to restore plugin interface

Signed-off-by: Michal Wieczorek <wieczorek-michal@wp.pl>
This commit is contained in:
Michal Wieczorek
2018-12-05 14:22:04 +01:00
committed by Carlisia
parent ce3f43e876
commit 1354e2b6ff
21 changed files with 256 additions and 178 deletions

View File

@@ -147,7 +147,7 @@ type CreateSnapshotRequest struct {
func (m *CreateSnapshotRequest) Reset() { *m = CreateSnapshotRequest{} }
func (m *CreateSnapshotRequest) String() string { return proto.CompactTextString(m) }
func (*CreateSnapshotRequest) ProtoMessage() {}
func (*CreateSnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{6} }
func (*CreateSnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{4} }
func (m *CreateSnapshotRequest) GetPlugin() string {
if m != nil {
@@ -184,7 +184,7 @@ type CreateSnapshotResponse struct {
func (m *CreateSnapshotResponse) Reset() { *m = CreateSnapshotResponse{} }
func (m *CreateSnapshotResponse) String() string { return proto.CompactTextString(m) }
func (*CreateSnapshotResponse) ProtoMessage() {}
func (*CreateSnapshotResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{7} }
func (*CreateSnapshotResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} }
func (m *CreateSnapshotResponse) GetSnapshotID() string {
if m != nil {
@@ -201,7 +201,7 @@ type DeleteSnapshotRequest struct {
func (m *DeleteSnapshotRequest) Reset() { *m = DeleteSnapshotRequest{} }
func (m *DeleteSnapshotRequest) String() string { return proto.CompactTextString(m) }
func (*DeleteSnapshotRequest) ProtoMessage() {}
func (*DeleteSnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{8} }
func (*DeleteSnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{6} }
func (m *DeleteSnapshotRequest) GetPlugin() string {
if m != nil {
@@ -225,7 +225,7 @@ type GetVolumeIDRequest struct {
func (m *GetVolumeIDRequest) Reset() { *m = GetVolumeIDRequest{} }
func (m *GetVolumeIDRequest) String() string { return proto.CompactTextString(m) }
func (*GetVolumeIDRequest) ProtoMessage() {}
func (*GetVolumeIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{9} }
func (*GetVolumeIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{7} }
func (m *GetVolumeIDRequest) GetPlugin() string {
if m != nil {
@@ -248,7 +248,7 @@ type GetVolumeIDResponse struct {
func (m *GetVolumeIDResponse) Reset() { *m = GetVolumeIDResponse{} }
func (m *GetVolumeIDResponse) String() string { return proto.CompactTextString(m) }
func (*GetVolumeIDResponse) ProtoMessage() {}
func (*GetVolumeIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{10} }
func (*GetVolumeIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{8} }
func (m *GetVolumeIDResponse) GetVolumeID() string {
if m != nil {
@@ -266,7 +266,7 @@ type SetVolumeIDRequest struct {
func (m *SetVolumeIDRequest) Reset() { *m = SetVolumeIDRequest{} }
func (m *SetVolumeIDRequest) String() string { return proto.CompactTextString(m) }
func (*SetVolumeIDRequest) ProtoMessage() {}
func (*SetVolumeIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{11} }
func (*SetVolumeIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{9} }
func (m *SetVolumeIDRequest) GetPlugin() string {
if m != nil {
@@ -296,7 +296,7 @@ type SetVolumeIDResponse struct {
func (m *SetVolumeIDResponse) Reset() { *m = SetVolumeIDResponse{} }
func (m *SetVolumeIDResponse) String() string { return proto.CompactTextString(m) }
func (*SetVolumeIDResponse) ProtoMessage() {}
func (*SetVolumeIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{12} }
func (*SetVolumeIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{10} }
func (m *SetVolumeIDResponse) GetPersistentVolume() []byte {
if m != nil {
@@ -592,41 +592,38 @@ var _BlockStore_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("BlockStore.proto", fileDescriptor1) }
var fileDescriptor1 = []byte{
// 566 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x6e, 0xd3, 0x40,
0x10, 0x96, 0x63, 0xb7, 0x6a, 0x26, 0xa5, 0x8a, 0x36, 0x3f, 0xb2, 0x2c, 0x11, 0x8c, 0x4f, 0x51,
0x25, 0x22, 0x08, 0x07, 0x2a, 0x0e, 0x48, 0x05, 0x17, 0x64, 0x51, 0x09, 0xc9, 0x2e, 0x08, 0xc1,
0xc9, 0x90, 0x4d, 0x1a, 0xd5, 0xf1, 0x1a, 0xef, 0xa6, 0x92, 0x1f, 0x86, 0x77, 0xe3, 0x41, 0x38,
0x54, 0xb6, 0x37, 0xf1, 0xae, 0xb3, 0x69, 0x72, 0xc9, 0xcd, 0x33, 0xb3, 0xfb, 0xcd, 0x37, 0x3b,
0xdf, 0x8c, 0xa1, 0xfd, 0x3e, 0x22, 0xbf, 0xef, 0x02, 0x46, 0x52, 0x3c, 0x4a, 0x52, 0xc2, 0x08,
0x6a, 0xce, 0x70, 0x8c, 0xd3, 0x90, 0xe1, 0x89, 0x75, 0x1a, 0xdc, 0x86, 0x29, 0x9e, 0x94, 0x01,
0xe7, 0xaf, 0x06, 0x9d, 0x0f, 0x29, 0x0e, 0x19, 0xfe, 0x46, 0xa2, 0xe5, 0x02, 0xfb, 0xf8, 0xcf,
0x12, 0x53, 0x86, 0xfa, 0x70, 0x9c, 0x44, 0xcb, 0xd9, 0x3c, 0x36, 0x35, 0x5b, 0x1b, 0x36, 0x7d,
0x6e, 0xa1, 0x01, 0x00, 0x8d, 0xc3, 0x84, 0xde, 0x12, 0xe6, 0xb9, 0x66, 0xa3, 0x88, 0x09, 0x9e,
0x3c, 0x7e, 0x5f, 0x00, 0xdd, 0x64, 0x09, 0x36, 0xf5, 0x32, 0x5e, 0x79, 0x90, 0x05, 0x27, 0xa5,
0x75, 0x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x3a, 0x2e, 0xfe, 0xac, 0xaf, 0x1f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa2, 0x65,
0xf8, 0xa4, 0x86, 0x07, 0x00, 0x00,
// 527 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x6f, 0xd3, 0x4e,
0x10, 0x95, 0x63, 0xb7, 0xfa, 0x65, 0xd2, 0x5f, 0x15, 0x4d, 0xfe, 0xc8, 0xb2, 0x44, 0x30, 0x3e,
0x45, 0x3d, 0x44, 0x10, 0x0e, 0x54, 0x1c, 0x90, 0x0a, 0x2e, 0x28, 0xa2, 0x12, 0x92, 0x5d, 0x10,
0x82, 0x93, 0xa1, 0xd3, 0x34, 0xaa, 0xe3, 0x35, 0xde, 0x4d, 0xa5, 0x7c, 0x18, 0xee, 0x7c, 0x2c,
0x3e, 0x0a, 0x8a, 0xbd, 0x49, 0x76, 0x93, 0x4d, 0xd3, 0x4b, 0x6f, 0x9e, 0x19, 0xcf, 0x9b, 0xf7,
0xc6, 0x6f, 0xd7, 0xd0, 0x7c, 0x9b, 0xb2, 0x9f, 0xb7, 0xb1, 0x60, 0x05, 0x0d, 0xf2, 0x82, 0x09,
0x86, 0xf5, 0x31, 0x65, 0x54, 0x24, 0x82, 0xae, 0xbc, 0xa3, 0xf8, 0x26, 0x29, 0xe8, 0xaa, 0x2a,
0x04, 0xbf, 0x2d, 0x68, 0xbd, 0x2b, 0x28, 0x11, 0xf4, 0x85, 0xa5, 0xb3, 0x29, 0x45, 0xf4, 0x6b,
0x46, 0x5c, 0x60, 0x17, 0x0e, 0xf3, 0x74, 0x36, 0x9e, 0x64, 0xae, 0xe5, 0x5b, 0xfd, 0x7a, 0x24,
0x23, 0xec, 0x01, 0xf0, 0x2c, 0xc9, 0xf9, 0x0d, 0x13, 0xa3, 0xd0, 0xad, 0x95, 0x35, 0x25, 0xb3,
0xa8, 0xdf,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 = fmt.Errorf
var _ = math.Inf
type RestoreExecuteRequest struct {
Plugin string `protobuf:"bytes,1,opt,name=plugin" json:"plugin,omitempty"`
Item []byte `protobuf:"bytes,2,opt,name=item,proto3" json:"item,omitempty"`
Restore []byte `protobuf:"bytes,3,opt,name=restore,proto3" json:"restore,omitempty"`
Plugin string `protobuf:"bytes,1,opt,name=plugin" json:"plugin,omitempty"`
Item []byte `protobuf:"bytes,2,opt,name=item,proto3" json:"item,omitempty"`
Restore []byte `protobuf:"bytes,3,opt,name=restore,proto3" json:"restore,omitempty"`
ItemFromBackup []byte `protobuf:"bytes,4,opt,name=itemFromBackup,proto3" json:"itemFromBackup,omitempty"`
}
func (m *RestoreExecuteRequest) Reset() { *m = RestoreExecuteRequest{} }
@@ -49,6 +50,13 @@ func (m *RestoreExecuteRequest) GetRestore() []byte {
return nil
}
func (m *RestoreExecuteRequest) GetItemFromBackup() []byte {
if m != nil {
return m.ItemFromBackup
}
return nil
}
type RestoreExecuteResponse struct {
Item []byte `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
Warning string `protobuf:"bytes,2,opt,name=warning" json:"warning,omitempty"`
@@ -186,20 +194,21 @@ var _RestoreItemAction_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("RestoreItemAction.proto", fileDescriptor4) }
var fileDescriptor4 = []byte{
// 230 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x0f, 0x4a, 0x2d, 0x2e,
0xc9, 0x2f, 0x4a, 0xf5, 0x2c, 0x49, 0xcd, 0x75, 0x4c, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28,
0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4c, 0x4f, 0xcd, 0x4b, 0x2d, 0x4a, 0x2c, 0x49, 0x4d, 0x91, 0xe2,
0x09, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0x81, 0x48, 0x28, 0xc5, 0x72, 0x89, 0x42, 0xf5, 0xb8, 0x56,
0xa4, 0x26, 0x97, 0x96, 0xa4, 0x06, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x89, 0x71, 0xb1,
0x15, 0xe4, 0x94, 0xa6, 0x67, 0xe6, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x41, 0x79, 0x42,
0x42, 0x5c, 0x2c, 0x99, 0x25, 0xa9, 0xb9, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0x3c, 0x41, 0x60, 0xb6,
0x90, 0x04, 0x17, 0x7b, 0x11, 0xc4, 0x10, 0x09, 0x66, 0xb0, 0x30, 0x8c, 0xab, 0xe4, 0xc6, 0x25,
0x86, 0x6e, 0x7c, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0x2a, 0xdc, 0x1c, 0x46, 0x54, 0x73, 0xca, 0x13,
0x8b, 0xf2, 0x32, 0xf3, 0xd2, 0xc1, 0xc6, 0x73, 0x06, 0xc1, 0xb8, 0x46, 0xab, 0x19, 0xb9, 0x04,
0x31, 0xfc, 0x26, 0xe4, 0xc6, 0xc5, 0xe9, 0x58, 0x50, 0x90, 0x93, 0x99, 0x5a, 0x1c, 0x92, 0x2f,
0x24, 0xad, 0x07, 0xf7, 0xa3, 0x1e, 0x5c, 0x14, 0xea, 0x1b, 0x29, 0x19, 0xec, 0x92, 0x50, 0xb7,
0xf8, 0x71, 0xb1, 0x43, 0x9d, 0x27, 0xa4, 0x80, 0xa4, 0x10, 0x6b, 0xc0, 0x48, 0x29, 0xe2, 0x51,
0x01, 0x31, 0x2f, 0x89, 0x0d, 0x1c, 0xb6, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xe5,
0x97, 0xa4, 0x8f, 0x01, 0x00, 0x00,
// 252 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff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, 0x41, 0xb6, 0x36, 0x66, 0x2b, 0xc9, 0x3d, 0x6a, 0x3c, 0x2b, 0x87, 0x32,
0xca, 0x81, 0x4d, 0xaf, 0xce, 0xcf, 0xc7, 0x87, 0x29, 0xcb, 0x3d, 0xcc, 0x52, 0x3c, 0x2c, 0x7e,
0x08, 0x47, 0x0b, 0xcc, 0x2f, 0xfe, 0x51, 0xf4, 0xfb, 0x9e, 0xa6, 0xf1, 0x13, 0xae, 0xbf, 0x02,
0x00, 0x00, 0xff, 0xff, 0x19, 0xeb, 0x64, 0x57, 0xb8, 0x01, 0x00, 0x00,
}

View File

@@ -7,6 +7,7 @@ message RestoreExecuteRequest {
string plugin = 1;
bytes item = 2;
bytes restore = 3;
bytes itemFromBackup = 4;
}
message RestoreExecuteResponse {

View File

@@ -88,6 +88,14 @@ func runRestartableDelegateTests(
continue
}
// If function returns nil as struct return type, we cannot just
// compare the interface to nil as its type will not be nil,
// only the value will be
if expected[i] == nil && reflect.ValueOf(a).Kind() == reflect.Ptr {
assert.True(t, reflect.ValueOf(a).IsNil())
continue
}
// Otherwise, use plain Equal
assert.Equal(t, expected[i], a)
}

View File

@@ -17,9 +17,7 @@ package plugin
import (
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/runtime"
api "github.com/heptio/velero/pkg/apis/velero/v1"
"github.com/heptio/velero/pkg/restore"
)
@@ -78,11 +76,11 @@ func (r *restartableRestoreItemAction) AppliesTo() (restore.ResourceSelector, er
}
// Execute restarts the plugin's process if needed, then delegates the call.
func (r *restartableRestoreItemAction) Execute(obj runtime.Unstructured, restore *api.Restore) (res runtime.Unstructured, warning error, err error) {
func (r *restartableRestoreItemAction) Execute(input *restore.RestoreItemActionExecuteInput) (*restore.RestoreItemActionExecuteOutput, error) {
delegate, err := r.getDelegate()
if err != nil {
return nil, nil, err
return nil, err
}
return delegate.Execute(obj, restore)
return delegate.Execute(input)
}

View File

@@ -98,18 +98,25 @@ func TestRestartableRestoreItemActionGetDelegate(t *testing.T) {
}
func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
r := new(v1.Restore)
pv := &unstructured.Unstructured{
Object: map[string]interface{}{
"color": "blue",
},
}
pvToReturn := &unstructured.Unstructured{
Object: map[string]interface{}{
"color": "green",
input := &restore.RestoreItemActionExecuteInput{
Item: pv,
ItemFromBackup: pv,
Restore: new(v1.Restore),
}
output := &restore.RestoreItemActionExecuteOutput{
UpdatedItem: &unstructured.Unstructured{
Object: map[string]interface{}{
"color": "green",
},
},
Warning: errors.Errorf("delegate warning"),
}
runRestartableDelegateTests(
@@ -132,9 +139,9 @@ func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
},
restartableDelegateTest{
function: "Execute",
inputs: []interface{}{pv, r},
expectedErrorOutputs: []interface{}{nil, nil, errors.Errorf("reset error")},
expectedDelegateOutputs: []interface{}{pvToReturn, errors.Errorf("delegate warning"), errors.Errorf("delegate error")},
inputs: []interface{}{input},
expectedErrorOutputs: []interface{}{nil, errors.Errorf("reset error")},
expectedDelegateOutputs: []interface{}{output, errors.Errorf("delegate error")},
},
)
}

View File

@@ -24,7 +24,6 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
api "github.com/heptio/velero/pkg/apis/velero/v1"
proto "github.com/heptio/velero/pkg/plugin/generated"
@@ -39,6 +38,8 @@ type RestoreItemActionPlugin struct {
*pluginBase
}
var _ restore.ItemAction = &RestoreItemActionGRPCClient{}
// NewRestoreItemActionPlugin constructs a RestoreItemActionPlugin.
func NewRestoreItemActionPlugin(options ...pluginOption) *RestoreItemActionPlugin {
return &RestoreItemActionPlugin{
@@ -84,31 +85,37 @@ func (c *RestoreItemActionGRPCClient) AppliesTo() (restore.ResourceSelector, err
}, nil
}
func (c *RestoreItemActionGRPCClient) Execute(item runtime.Unstructured, restore *api.Restore) (runtime.Unstructured, error, error) {
itemJSON, err := json.Marshal(item.UnstructuredContent())
func (c *RestoreItemActionGRPCClient) Execute(input *restore.RestoreItemActionExecuteInput) (*restore.RestoreItemActionExecuteOutput, error) {
itemJSON, err := json.Marshal(input.Item.UnstructuredContent())
if err != nil {
return nil, nil, err
return nil, err
}
restoreJSON, err := json.Marshal(restore)
itemFromBackupJSON, err := json.Marshal(input.ItemFromBackup.UnstructuredContent())
if err != nil {
return nil, nil, err
return nil, err
}
restoreJSON, err := json.Marshal(input.Restore)
if err != nil {
return nil, err
}
req := &proto.RestoreExecuteRequest{
Plugin: c.plugin,
Item: itemJSON,
Restore: restoreJSON,
Plugin: c.plugin,
Item: itemJSON,
ItemFromBackup: itemFromBackupJSON,
Restore: restoreJSON,
}
res, err := c.grpcClient.Execute(context.Background(), req)
if err != nil {
return nil, nil, err
return nil, err
}
var updatedItem unstructured.Unstructured
if err := json.Unmarshal(res.Item, &updatedItem); err != nil {
return nil, nil, err
return nil, err
}
var warning error
@@ -116,7 +123,10 @@ func (c *RestoreItemActionGRPCClient) Execute(item runtime.Unstructured, restore
warning = errors.New(res.Warning)
}
return &updatedItem, warning, nil
return &restore.RestoreItemActionExecuteOutput{
UpdatedItem: &updatedItem,
Warning: warning,
}, nil
}
//////////////////////////////////////////////////////////////////////////////
@@ -176,31 +186,40 @@ func (s *RestoreItemActionGRPCServer) Execute(ctx context.Context, req *proto.Re
}
var (
item unstructured.Unstructured
restore api.Restore
item unstructured.Unstructured
itemFromBackup unstructured.Unstructured
restoreObj api.Restore
)
if err := json.Unmarshal(req.Item, &item); err != nil {
return nil, err
}
if err := json.Unmarshal(req.Restore, &restore); err != nil {
if err := json.Unmarshal(req.ItemFromBackup, &itemFromBackup); err != nil {
return nil, err
}
res, warning, err := impl.Execute(&item, &restore)
if err := json.Unmarshal(req.Restore, &restoreObj); err != nil {
return nil, err
}
executeOutput, err := impl.Execute(&restore.RestoreItemActionExecuteInput{
Item: &item,
ItemFromBackup: &itemFromBackup,
Restore: &restoreObj,
})
if err != nil {
return nil, err
}
updatedItem, err := json.Marshal(res)
updatedItem, err := json.Marshal(executeOutput.UpdatedItem)
if err != nil {
return nil, err
}
var warnMessage string
if warning != nil {
warnMessage = warning.Error()
if executeOutput.Warning != nil {
warnMessage = executeOutput.Warning.Error()
}
return &proto.RestoreExecuteResponse{