Adds support for allowing a RestoreItemAction to skip item restore (#1336)

* Adds support for allowing a RestoreItemAction to skip item restore

This allows a RestoreItemAction plugin to signal to velero that
the returned item should be skipped rather than restored to the
cluster.

To support this, a boolean SkipRestore attribute is added to
RestoreItemActionExecuteOutput. If restore.restoreResource finds
this set to true, any remaining actions on this item are skipped,
and restore on this item is skipped. Execution continues with
the next item of this resource type.

To signal this for a particular item, the RestoreItemAction's
Execute method should call WithoutRestore() on the
RestoreItemActionExecuteOutput before returning it.

Signed-off-by: Scott Seago <sseago@redhat.com>

* Autogenerated code to support SkipRestore

Signed-off-by: Scott Seago <sseago@redhat.com>

* Added changelog for #1336

Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
sseago
2019-04-04 15:39:54 -04:00
committed by Steve Kriss
parent 0167539a14
commit a519547efc
7 changed files with 48 additions and 20 deletions

View File

@@ -117,5 +117,6 @@ func (c *RestoreItemActionGRPCClient) Execute(input *velero.RestoreItemActionExe
return &velero.RestoreItemActionExecuteOutput{
UpdatedItem: &updatedItem,
AdditionalItems: additionalItems,
SkipRestore: res.SkipRestore,
}, nil
}

View File

@@ -126,7 +126,8 @@ func (s *RestoreItemActionGRPCServer) Execute(ctx context.Context, req *proto.Re
}
res := &proto.RestoreItemActionExecuteResponse{
Item: updatedItemJSON,
Item: updatedItemJSON,
SkipRestore: executeOutput.SkipRestore,
}
for _, item := range executeOutput.AdditionalItems {

View File

@@ -60,6 +60,7 @@ func (m *RestoreItemActionExecuteRequest) GetItemFromBackup() []byte {
type RestoreItemActionExecuteResponse struct {
Item []byte `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
AdditionalItems []*ResourceIdentifier `protobuf:"bytes,2,rep,name=additionalItems" json:"additionalItems,omitempty"`
SkipRestore bool `protobuf:"varint,3,opt,name=skipRestore" json:"skipRestore,omitempty"`
}
func (m *RestoreItemActionExecuteResponse) Reset() { *m = RestoreItemActionExecuteResponse{} }
@@ -83,6 +84,13 @@ func (m *RestoreItemActionExecuteResponse) GetAdditionalItems() []*ResourceIdent
return nil
}
func (m *RestoreItemActionExecuteResponse) GetSkipRestore() bool {
if m != nil {
return m.SkipRestore
}
return false
}
func init() {
proto.RegisterType((*RestoreItemActionExecuteRequest)(nil), "generated.RestoreItemActionExecuteRequest")
proto.RegisterType((*RestoreItemActionExecuteResponse)(nil), "generated.RestoreItemActionExecuteResponse")
@@ -196,23 +204,24 @@ var _RestoreItemAction_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("RestoreItemAction.proto", fileDescriptor3) }
var fileDescriptor3 = []byte{
// 280 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0xdb, 0x4a, 0x03, 0x31,
0x10, 0x25, 0x6d, 0x69, 0xe9, 0x58, 0x14, 0xf3, 0xa0, 0x61, 0x55, 0x5c, 0xfa, 0x20, 0x8b, 0xc2,
0x3e, 0xd4, 0x2f, 0xa8, 0x60, 0xa5, 0xaf, 0xd1, 0x1f, 0xd8, 0x6e, 0xc6, 0x1a, 0xdc, 0x4d, 0x62,
0x2e, 0xe0, 0x9b, 0x9f, 0xe0, 0x27, 0xf9, 0x6b, 0xb2, 0x17, 0x97, 0xda, 0xaa, 0xf8, 0x96, 0x39,
0x73, 0xce, 0x9c, 0x33, 0x19, 0x38, 0xe6, 0xe8, 0xbc, 0xb6, 0xb8, 0xf4, 0x58, 0xce, 0x73, 0x2f,
0xb5, 0x4a, 0x8d, 0xd5, 0x5e, 0xd3, 0xf1, 0x1a, 0x15, 0xda, 0xcc, 0xa3, 0x88, 0x26, 0xf7, 0x4f,
0x99, 0x45, 0xd1, 0x34, 0xa6, 0xef, 0x04, 0xce, 0x77, 0x44, 0xb7, 0xaf, 0x98, 0x07, 0x8f, 0x1c,
0x5f, 0x02, 0x3a, 0x4f, 0x8f, 0x60, 0x68, 0x8a, 0xb0, 0x96, 0x8a, 0x91, 0x98, 0x24, 0x63, 0xde,
0x56, 0x94, 0xc2, 0x40, 0x7a, 0x2c, 0x59, 0x2f, 0x26, 0xc9, 0x84, 0xd7, 0x6f, 0xca, 0x60, 0x64,
0x9b, 0x71, 0xac, 0x5f, 0xc3, 0x5f, 0x25, 0xbd, 0x80, 0xfd, 0x8a, 0xb1, 0xb0, 0xba, 0xbc, 0xc9,
0xf2, 0xe7, 0x60, 0xd8, 0xa0, 0x26, 0x6c, 0xa1, 0xd3, 0x37, 0x88, 0x7f, 0x0f, 0xe4, 0x8c, 0x56,
0x0e, 0x3b, 0x67, 0xb2, 0xe1, 0x7c, 0x07, 0x07, 0x99, 0x10, 0xb2, 0xa2, 0x67, 0x45, 0x25, 0x75,
0xac, 0x17, 0xf7, 0x93, 0xbd, 0xd9, 0x59, 0xda, 0x2d, 0x9f, 0x72, 0x74, 0x3a, 0xd8, 0x1c, 0x97,
0x02, 0x95, 0x97, 0x8f, 0x12, 0x2d, 0xdf, 0x56, 0xcd, 0x3e, 0x08, 0x1c, 0xee, 0x24, 0xa0, 0x0b,
0x18, 0xcf, 0x8d, 0x29, 0x24, 0xba, 0x07, 0x4d, 0x4f, 0x36, 0x46, 0x76, 0x68, 0xfb, 0x5d, 0xd1,
0xe9, 0xcf, 0xcd, 0x36, 0xfa, 0x0a, 0x46, 0xed, 0x36, 0xf4, 0xf2, 0x7b, 0xb0, 0xbf, 0x6e, 0x10,
0x5d, 0xfd, 0x8b, 0xdb, 0x78, 0xac, 0x86, 0xf5, 0x6d, 0xaf, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff,
0xef, 0xe4, 0xd1, 0x78, 0x0f, 0x02, 0x00, 0x00,
// 293 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x5b, 0x4a, 0xc3, 0x40,
0x14, 0x65, 0xda, 0xd2, 0x9a, 0xdb, 0xa2, 0x38, 0x1f, 0x3a, 0x44, 0xc5, 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0x2b, 0x9e, 0x05, 0x6a, 0xbe, 0xad, 0xa2, 0x01, 0x8c, 0xcd, 0x46, 0x28,
0xde, 0xe9, 0x71, 0xc0, 0xbb, 0xd0, 0xec, 0x93, 0xc0, 0xf1, 0x4e, 0x46, 0xba, 0x00, 0x6f, 0xae,
0x54, 0x26, 0xd0, 0x3c, 0x49, 0x7a, 0xd6, 0x31, 0x6d, 0xd1, 0xe6, 0x45, 0xfd, 0xf3, 0xdf, 0x97,
0x4d, 0xb9, 0x15, 0x8c, 0x9a, 0xbe, 0xf4, 0xfa, 0x67, 0xf4, 0xff, 0xce, 0xe4, 0xdf, 0xec, 0xc5,
0xad, 0x3d, 0x56, 0xc3, 0xea, 0xfc, 0xb7, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf2, 0xe2, 0xba,
0x19, 0x32, 0x02, 0x00, 0x00,
}

View File

@@ -13,6 +13,7 @@ message RestoreItemActionExecuteRequest {
message RestoreItemActionExecuteResponse {
bytes item = 1;
repeated ResourceIdentifier additionalItems = 2;
bool skipRestore = 3;
}
service RestoreItemAction {

View File

@@ -57,6 +57,11 @@ type RestoreItemActionExecuteOutput struct {
// AdditionalItems is a list of additional related items that should
// be restored.
AdditionalItems []ResourceIdentifier
// SkipRestore tells velero to stop executing further actions
// on this item, and skip the restore step. When this field's
// value is true, AdditionalItems will be ignored.
SkipRestore bool
}
// NewRestoreItemActionExecuteOutput creates a new RestoreItemActionExecuteOutput
@@ -65,3 +70,9 @@ func NewRestoreItemActionExecuteOutput(item runtime.Unstructured) *RestoreItemAc
UpdatedItem: item,
}
}
// WithoutRestore returns SkipRestore for RestoreItemActionExecuteOutput
func (r *RestoreItemActionExecuteOutput) WithoutRestore() *RestoreItemActionExecuteOutput {
r.SkipRestore = true
return r
}