diff --git a/cmd/liqo-controller-manager/modules/networking.go b/cmd/liqo-controller-manager/modules/networking.go index abd191a49d..3305a4c5db 100644 --- a/cmd/liqo-controller-manager/modules/networking.go +++ b/cmd/liqo-controller-manager/modules/networking.go @@ -60,7 +60,7 @@ type NetworkingOption struct { } // SetupNetworkingModule setup the networking module and initializes its controllers . -func SetupNetworkingModule(ctx context.Context, mgr manager.Manager, opts *NetworkingOption) error { +func SetupNetworkingModule(_ context.Context, mgr manager.Manager, opts *NetworkingOption) error { networkReconciler := networkctrl.NewNetworkReconciler(mgr.GetClient(), mgr.GetScheme(), opts.IpamClient) if err := networkReconciler.SetupWithManager(mgr, opts.NetworkWorkers); err != nil { klog.Errorf("Unable to start the networkReconciler: %v", err) diff --git a/pkg/ipam/ipam.go b/pkg/ipam/ipam.go index 7341f20a06..e4945f394d 100644 --- a/pkg/ipam/ipam.go +++ b/pkg/ipam/ipam.go @@ -75,72 +75,39 @@ func New(ctx context.Context, cl client.Client, opts *ServerOptions) (*LiqoIPAM, func (lipam *LiqoIPAM) IPAcquire(_ context.Context, req *IPAcquireRequest) (*IPAcquireResponse, error) { remappedIP, err := lipam.acquireIP(req.GetCidr()) if err != nil { - return &IPAcquireResponse{ - Result: &ResponseResult{ - Success: false, - Error: err.Error(), - }, - }, err + return &IPAcquireResponse{}, err } - return &IPAcquireResponse{ - Ip: remappedIP, - Result: &ResponseResult{ - Success: true, - }, - }, nil + return &IPAcquireResponse{Ip: remappedIP}, nil } // IPRelease releases an IP from a given CIDR. func (lipam *LiqoIPAM) IPRelease(_ context.Context, req *IPReleaseRequest) (*IPReleaseResponse, error) { lipam.freeIP(ipCidr{ip: req.GetIp(), cidr: req.GetCidr()}) - return &IPReleaseResponse{ - Result: &ResponseResult{ - Success: true, - }, - }, nil + return &IPReleaseResponse{}, nil } // NetworkAcquire acquires a network. If it is already reserved, it allocates and reserves a new free one with the same prefix length. func (lipam *LiqoIPAM) NetworkAcquire(_ context.Context, req *NetworkAcquireRequest) (*NetworkAcquireResponse, error) { remappedCidr, err := lipam.acquireNetwork(req.GetCidr(), req.GetImmutable()) if err != nil { - return &NetworkAcquireResponse{ - Result: &ResponseResult{ - Success: false, - Error: err.Error(), - }, - }, err + return &NetworkAcquireResponse{}, err } - return &NetworkAcquireResponse{ - Cidr: remappedCidr, - Result: &ResponseResult{ - Success: true, - }, - }, nil + return &NetworkAcquireResponse{Cidr: remappedCidr}, nil } // NetworkRelease releases a network. func (lipam *LiqoIPAM) NetworkRelease(_ context.Context, req *NetworkReleaseRequest) (*NetworkReleaseResponse, error) { lipam.freeNetwork(req.GetCidr()) - return &NetworkReleaseResponse{ - Result: &ResponseResult{ - Success: true, - }, - }, nil + return &NetworkReleaseResponse{}, nil } // NetworkIsAvailable checks if a network is available. func (lipam *LiqoIPAM) NetworkIsAvailable(_ context.Context, req *NetworkAvailableRequest) (*NetworkAvailableResponse, error) { available := lipam.isNetworkAvailable(req.GetCidr()) - return &NetworkAvailableResponse{ - Available: available, - Result: &ResponseResult{ - Success: true, - }, - }, nil + return &NetworkAvailableResponse{Available: available}, nil } diff --git a/pkg/ipam/ipam.pb.go b/pkg/ipam/ipam.pb.go index 8eeec24cf2..06336a84d4 100644 --- a/pkg/ipam/ipam.pb.go +++ b/pkg/ipam/ipam.pb.go @@ -25,9 +25,6 @@ type ResponseResult struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } func (x *ResponseResult) Reset() { @@ -60,20 +57,6 @@ func (*ResponseResult) Descriptor() ([]byte, []int) { return file_pkg_ipam_ipam_proto_rawDescGZIP(), []int{0} } -func (x *ResponseResult) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -func (x *ResponseResult) GetError() string { - if x != nil { - return x.Error - } - return "" -} - type IPAcquireRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -124,8 +107,8 @@ type IPAcquireResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Result *ResponseResult `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` - Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"` + Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"` + Result *ResponseResult `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"` } func (x *IPAcquireResponse) Reset() { @@ -158,18 +141,18 @@ func (*IPAcquireResponse) Descriptor() ([]byte, []int) { return file_pkg_ipam_ipam_proto_rawDescGZIP(), []int{2} } -func (x *IPAcquireResponse) GetResult() *ResponseResult { +func (x *IPAcquireResponse) GetIp() string { if x != nil { - return x.Result + return x.Ip } - return nil + return "" } -func (x *IPAcquireResponse) GetIp() string { +func (x *IPAcquireResponse) GetResult() *ResponseResult { if x != nil { - return x.Ip + return x.Result } - return "" + return nil } type IPReleaseRequest struct { @@ -328,8 +311,8 @@ type NetworkAcquireResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Result *ResponseResult `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` - Cidr string `protobuf:"bytes,2,opt,name=cidr,proto3" json:"cidr,omitempty"` + Cidr string `protobuf:"bytes,1,opt,name=cidr,proto3" json:"cidr,omitempty"` + Result *ResponseResult `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"` } func (x *NetworkAcquireResponse) Reset() { @@ -362,18 +345,18 @@ func (*NetworkAcquireResponse) Descriptor() ([]byte, []int) { return file_pkg_ipam_ipam_proto_rawDescGZIP(), []int{6} } -func (x *NetworkAcquireResponse) GetResult() *ResponseResult { +func (x *NetworkAcquireResponse) GetCidr() string { if x != nil { - return x.Result + return x.Cidr } - return nil + return "" } -func (x *NetworkAcquireResponse) GetCidr() string { +func (x *NetworkAcquireResponse) GetResult() *ResponseResult { if x != nil { - return x.Cidr + return x.Result } - return "" + return nil } type NetworkReleaseRequest struct { @@ -516,8 +499,8 @@ type NetworkAvailableResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Result *ResponseResult `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` - Available bool `protobuf:"varint,2,opt,name=available,proto3" json:"available,omitempty"` + Available bool `protobuf:"varint,1,opt,name=available,proto3" json:"available,omitempty"` + Result *ResponseResult `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"` } func (x *NetworkAvailableResponse) Reset() { @@ -550,36 +533,33 @@ func (*NetworkAvailableResponse) Descriptor() ([]byte, []int) { return file_pkg_ipam_ipam_proto_rawDescGZIP(), []int{10} } -func (x *NetworkAvailableResponse) GetResult() *ResponseResult { +func (x *NetworkAvailableResponse) GetAvailable() bool { if x != nil { - return x.Result + return x.Available } - return nil + return false } -func (x *NetworkAvailableResponse) GetAvailable() bool { +func (x *NetworkAvailableResponse) GetResult() *ResponseResult { if x != nil { - return x.Available + return x.Result } - return false + return nil } var File_pkg_ipam_ipam_proto protoreflect.FileDescriptor var file_pkg_ipam_ipam_proto_rawDesc = []byte{ 0x0a, 0x13, 0x70, 0x6b, 0x67, 0x2f, 0x69, 0x70, 0x61, 0x6d, 0x2f, 0x69, 0x70, 0x61, 0x6d, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x40, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, - 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, - 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x26, 0x0a, 0x10, 0x49, 0x50, 0x41, 0x63, 0x71, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x10, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x26, 0x0a, 0x10, 0x49, 0x50, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x64, 0x72, 0x22, 0x4c, 0x0a, 0x11, 0x49, 0x50, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x70, 0x12, 0x27, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x22, 0x36, 0x0a, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x36, 0x0a, 0x10, 0x49, 0x50, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, @@ -593,11 +573,11 @@ var file_pkg_ipam_ipam_proto_rawDesc = []byte{ 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6d, 0x6d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x6d, 0x6d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x55, 0x0a, 0x16, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x63, 0x69, 0x64, 0x72, 0x22, 0x2b, 0x0a, 0x15, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x64, 0x72, 0x12, 0x27, 0x0a, 0x06, + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x2b, 0x0a, 0x15, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x64, 0x72, 0x22, 0x41, 0x0a, 0x16, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x6c, @@ -609,11 +589,11 @@ var file_pkg_ipam_ipam_proto_rawDesc = []byte{ 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x64, 0x72, 0x22, 0x61, 0x0a, 0x18, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x27, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0f, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x76, 0x61, - 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x61, 0x76, - 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x32, 0xbf, 0x02, 0x0a, 0x04, 0x49, 0x50, 0x41, 0x4d, + 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x09, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x27, + 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, + 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, + 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0xbf, 0x02, 0x0a, 0x04, 0x49, 0x50, 0x41, 0x4d, 0x12, 0x32, 0x0a, 0x09, 0x49, 0x50, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x12, 0x11, 0x2e, 0x49, 0x50, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x49, 0x50, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, diff --git a/pkg/ipam/ipam.proto b/pkg/ipam/ipam.proto index d257f10ee4..ac53a74f05 100644 --- a/pkg/ipam/ipam.proto +++ b/pkg/ipam/ipam.proto @@ -11,8 +11,6 @@ service IPAM { } message ResponseResult { - bool success = 1; - string error = 2; } message IPAcquireRequest { @@ -20,8 +18,8 @@ message IPAcquireRequest { } message IPAcquireResponse { - ResponseResult result = 1; - string ip = 2; + string ip = 1; + ResponseResult result = 2; } message IPReleaseRequest { @@ -39,8 +37,8 @@ message NetworkAcquireRequest { } message NetworkAcquireResponse { - ResponseResult result = 1; - string cidr = 2; + string cidr = 1; + ResponseResult result = 2; } message NetworkReleaseRequest { @@ -56,6 +54,6 @@ message NetworkAvailableRequest { } message NetworkAvailableResponse { - ResponseResult result = 1; - bool available = 2; + bool available = 1; + ResponseResult result = 2; }