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

Bug fixes for issues identified in 1.7 #396

Merged
merged 22 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
3 changes: 2 additions & 1 deletion fabric_cf/actor/core/apis/abc_actor_management_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
slice_id: ID = None, rid: ID = None, oidc_claim_sub: str = None,
email: str = None, rid_list: List[str] = None, type: str = None,
site: str = None, node_id: str = None,
host: str = None, ip_subnet: str = None) -> ResultReservationAvro:
host: str = None, ip_subnet: str = None, full: bool = False) -> ResultReservationAvro:
"""
Get Reservations
@param states states
Expand All @@ -255,6 +255,7 @@ def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
@param caller caller
@param host host
@param ip_subnet ip subnet
@param full

@return returns list of the reservations
"""
Expand Down
3 changes: 2 additions & 1 deletion fabric_cf/actor/core/apis/abc_mgmt_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def accept_update_slice(self, *, slice_id: ID) -> bool:
def get_reservations(self, *, states: List[int] = None, slice_id: ID = None,
rid: ID = None, oidc_claim_sub: str = None, email: str = None, rid_list: List[str] = None,
type: str = None, site: str = None, node_id: str = None,
host: str = None, ip_subnet: str = None) -> List[ReservationMng]:
host: str = None, ip_subnet: str = None, full: bool = False) -> List[ReservationMng]:
"""
Get Reservations
@param states states
Expand All @@ -165,6 +165,7 @@ def get_reservations(self, *, states: List[int] = None, slice_id: ID = None,
@param node_id node id
@param ip_subnet ip subnet
@param host host
@param full
Obtains all reservations
@return returns list of the reservations
"""
Expand Down
1 change: 1 addition & 0 deletions fabric_cf/actor/core/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class Constants:
MAINT_PROJECT_ID = 'maint.project.id'
INFRASTRUCTURE_PROJECT_ID = "infrastructure.project.id"
TOTAL_SLICE_COUNT_SEED = "total_slice_count_seed"
EXCLUDED_PROJECTS = "excluded.projects"

ELASTIC_TIME = "request.elasticTime"
ELASTIC_SIZE = "request.elasticSize"
Expand Down
3 changes: 2 additions & 1 deletion fabric_cf/actor/core/kernel/poa.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def restore(self, *, actor: ABCActorMixin, reservation: ABCReservationMixin):
"""
self.reservation = reservation
self.actor = actor
self.logger = self.actor.get_logger()
if actor:
self.logger = self.actor.get_logger()

# Update slice/sliver info if available
if reservation is not None:
Expand Down
5 changes: 3 additions & 2 deletions fabric_cf/actor/core/kernel/reservation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1837,9 +1837,10 @@ def update_slice_graph(self, *, sliver: BaseSliver):
if asm_thread is not None:
asm_thread.enqueue(graph_id=self.slice.get_graph_id(),
sliver=sliver, rid=str(self.rid),
reservation_state=self.state.name,
reservation_state=str(self.state),
error_message=error_message)
self.logger.debug(f"Update ASM completed for Reservation# {self.rid} State# {self.get_reservation_state()} "
self.logger.debug(f"Update ASM completed for Reservation# {self.rid} "
f"State# {self.get_reservation_state()} "
f"Slice Graph# {self.slice.get_graph_id()}")

except Exception as e:
Expand Down
6 changes: 3 additions & 3 deletions fabric_cf/actor/core/kernel/rpc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ def do_dispatch_incoming_rpc(self, *, actor: ABCActorMixin, rpc: IncomingRPC):
rpc.set_response_handler(response_handler=request.handler)

actor.get_logger().debug(f"Inbound {rpc.get_request_type()} request from "
f"<{rpc.get_caller().get_name()}>:{rpc.get()}")
f"<{rpc.get_caller().get_name()}>:{rpc.get()}")

self.__log_sliver(reservation=rpc.get(), logger=actor.get_logger())
#self.__log_sliver(reservation=rpc.get(), logger=actor.get_logger())

if rpc.get_request_type() == RPCRequestType.QueryResult:
if request is None:
Expand Down Expand Up @@ -564,7 +564,7 @@ def enqueue(self, *, rpc: RPCRequest):
from fabric_cf.actor.core.container.globals import GlobalsSingleton
logger = GlobalsSingleton.get().get_logger()
logger.debug(f"Outbound {rpc.get_request_type()} : {rpc.get()}")
self.__log_sliver(reservation=rpc.get(), logger=logger)
#self.__log_sliver(reservation=rpc.get(), logger=logger)
if not self.started:
logger.warning("Ignoring RPC request: container is shutting down")
return
Expand Down
8 changes: 5 additions & 3 deletions fabric_cf/actor/core/manage/actor_management_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ def increment_metrics(self, *, project_id: str, oidc_sub: str, slice_count: int
def get_slice_count(self, *, caller: AuthToken, email: str = None, states: List[int] = None,
project: str = None, user_id: str = None, excluded_projects: List[str] = None) -> int:
try:
return self.db.get_slice_count(email=email, states=states, project_id=project, oidc_sub=user_id)
return self.db.get_slice_count(email=email, states=states, project_id=project, oidc_sub=user_id,
excluded_projects=excluded_projects)
except Exception as e:
self.logger.error("get_slice_count {}".format(e))
return -1
Expand Down Expand Up @@ -431,7 +432,7 @@ def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
slice_id: ID = None, rid: ID = None, oidc_claim_sub: str = None,
email: str = None, rid_list: List[str] = None, type: str = None,
site: str = None, node_id: str = None, host: str = None,
ip_subnet: str = None) -> ResultReservationAvro:
ip_subnet: str = None, full: bool = False) -> ResultReservationAvro:
result = ResultReservationAvro()
result.status = ResultAvro()

Expand Down Expand Up @@ -464,7 +465,8 @@ def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
r_slice_id = r.get_slice_id()
slice_obj = self.get_slice_by_guid(guid=r_slice_id)
r.restore(actor=self.actor, slice_obj=slice_obj)
full = True if slice_id or rid else False
if not full:
full = True if slice_id or rid else False
rr = Converter.fill_reservation(reservation=r, full=full)
result.reservations.append(rr)
except ReservationNotFoundException as e:
Expand Down
2 changes: 1 addition & 1 deletion fabric_cf/actor/core/manage/kafka/kafka_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def delete_slice(self, *, slice_id: ID) -> bool:
def get_reservations(self, *, states: List[int] = None, slice_id: ID = None,
rid: ID = None, oidc_claim_sub: str = None, email: str = None, rid_list: List[str] = None,
type: str = None, site: str = None, node_id: str = None,
host: str = None, ip_subnet: str = None) -> List[ReservationMng]:
host: str = None, ip_subnet: str = None, full: bool = False) -> List[ReservationMng]:
request = GetReservationsRequestAvro()
request = self.fill_request_by_id_message(request=request, slice_id=slice_id,
states=states, email=email, rid=rid,
Expand Down
4 changes: 2 additions & 2 deletions fabric_cf/actor/core/manage/local/local_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ def remove_slice(self, *, slice_id: ID) -> bool:
def get_reservations(self, *, states: List[int] = None, slice_id: ID = None,
rid: ID = None, oidc_claim_sub: str = None, email: str = None, rid_list: List[str] = None,
type: str = None, site: str = None, node_id: str = None,
host: str = None, ip_subnet: str = None) -> List[ReservationMng]:
host: str = None, ip_subnet: str = None, full: bool = False) -> List[ReservationMng]:
self.clear_last()
try:
result = self.manager.get_reservations(caller=self.auth, states=states, slice_id=slice_id, rid=rid,
oidc_claim_sub=oidc_claim_sub, email=email, rid_list=rid_list,
type=type, site=site, node_id=node_id, host=host,
ip_subnet=ip_subnet)
ip_subnet=ip_subnet, full=full)
self.last_status = result.status

if result.status.get_code() == 0:
Expand Down
28 changes: 13 additions & 15 deletions fabric_cf/actor/core/policy/broker_simpler_units_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ def __allocate_services(self, *, rid: ID, inv: NetworkServiceInventory, sliver:
self.logger.info(f"Allocated Interface Sliver: {ifs} delegation: {delegation_id}")

owner_v4_service = self.get_ns_from_switch(switch=owner_switch, ns_type=ServiceType.FABNetv4)
self.logger.info(f"owner_v4_service: {owner_v4_service}")
if owner_v4_service and owner_v4_service.get_labels():
ero_source_end_info.append((owner_switch.node_id, owner_v4_service.get_labels().ipv4))

Expand All @@ -891,8 +892,12 @@ def __allocate_services(self, *, rid: ID, inv: NetworkServiceInventory, sliver:
if ServiceType.MPLS == ns.get_type():
owner_mpls_ns = ns
break
delegation_id, delegated_label = InventoryForType.get_delegations(lab_cap_delegations=
owner_ns.get_label_delegations())
if owner_ns and ServiceType.MPLS == owner_ns.get_type():
delegation_id, delegated_label = InventoryForType.get_delegations(lab_cap_delegations=
owner_switch.get_label_delegations())
else:
delegation_id, delegated_label = InventoryForType.get_delegations(lab_cap_delegations=
owner_ns.get_label_delegations())

# Set the Subnet and gateway from the Owner Switch (a)
existing_reservations = self.get_existing_reservations(node_id=owner_ns_id,
Expand All @@ -917,7 +922,7 @@ def __allocate_services(self, *, rid: ID, inv: NetworkServiceInventory, sliver:
node_id_to_reservations=node_id_to_reservations, term=term)

if sliver.ero and len(sliver.ero.get()) and len(ero_source_end_info) == 2:
self.logger.info(f"Requested ERO: {sliver.ero}")
self.logger.info(f"Requested ERO: {sliver.ero} {ero_source_end_info}")
ero_hops = []
new_path = [ero_source_end_info[0][1]]
type, path = sliver.ero.get()
Expand All @@ -939,11 +944,13 @@ def __allocate_services(self, *, rid: ID, inv: NetworkServiceInventory, sliver:
new_path.append(ero_source_end_info[1][1])

if len(new_path):
'''
if not self.validate_requested_ero_path(source_node=ero_source_end_info[0][0],
end_node=ero_source_end_info[1][0],
hops=ero_hops):
raise BrokerException(error_code=ExceptionErrorCode.INVALID_ARGUMENT,
msg=f"Requested ERO path: {sliver.ero} is invalid!")
'''
ero_path = Path()
ero_path.set_symmetric(new_path)
sliver.ero.set(ero_path)
Expand Down Expand Up @@ -997,7 +1004,7 @@ def __allocate_peered_interfaces(self, *, rid: ID, peered_interfaces: List[Inter
ns_type=sliver.get_type())
peer_mpls, peer_sw = self.get_network_service_from_graph(node_id=peer_ns_id, parent=True)

peer_mpls, peer_ns = self.get_ns(switch=peer_sw, ns_type=sliver.get_type())
peer_ns = self.get_ns_from_switch(switch=peer_sw, ns_type=sliver.get_type())

bqm_interface = None
for bifs in owner_mpls.interface_info.interfaces.values():
Expand All @@ -1020,7 +1027,8 @@ def __allocate_peered_interfaces(self, *, rid: ID, peered_interfaces: List[Inter
pfs.set_node_map(node_map=(self.combined_broker_model_graph_id, bqm_interface.node_id))
if pfs.peer_labels is None:
pfs.peer_labels = Labels()
pfs.peer_labels = Labels.update(pfs.peer_labels, asn=peer_ns.labels.asn)
if peer_ns and peer_ns.labels:
pfs.peer_labels = Labels.update(pfs.peer_labels, asn=peer_ns.labels.asn)
self.logger.info(f"Allocated Peered Interface Sliver: {pfs}")

# Update the Network Service Sliver Node Map
Expand Down Expand Up @@ -1380,16 +1388,6 @@ def get_shortest_path(self, *, src_node_id: str, dest_node_id: str):
finally:
self.lock.release()

def get_ns(self, *, switch: NodeSliver, ns_type: ServiceType) -> Tuple[NetworkServiceSliver, NetworkServiceSliver]:
peer_mpls = peer_ns = None
for ns in switch.network_service_info.network_services.values():
if ServiceType.MPLS == ns.get_type():
peer_mpls = ns
if ns.get_type() == ns_type:
peer_ns = ns

return peer_mpls, peer_ns

def get_peer_node(self, *, site: str, node_type: str, node_name: str) -> NodeSliver:
if node_type == str(NodeType.Facility):
peer_node = self.get_facility_sliver(node_name=f'{site},{node_name}')
Expand Down
13 changes: 11 additions & 2 deletions fabric_cf/actor/core/policy/network_node_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from fim.slivers.attached_components import AttachedComponentsInfo
from fim.slivers.base_sliver import BaseSliver
from fim.slivers.network_node import NodeSliver
from fim.user import Capacities, ComponentType
from fim.user import Capacities, ComponentType, Labels

from fabric_cf.actor.core.apis.abc_authority_reservation import ABCAuthorityReservation
from fabric_cf.actor.core.apis.abc_reservation_mixin import ABCReservationMixin
Expand Down Expand Up @@ -219,12 +219,18 @@ def assign(self, *, reservation: ABCAuthorityReservation, delegation_name: str,
properties=reservation.get_slice().get_config_properties())
gained = UnitSet(plugin=self.authority.get_plugin(), units={unit.reservation_id: unit})
else:
self.logger.info(f"Extend Lease for now, no modify supported res# {reservation}")
current_sliver = current.get_sliver()
diff = current_sliver.diff(other_sliver=requested)
if diff is not None:
if requested.get_label_allocations() and current_sliver.get_label_allocations():
requested.label_allocations = Labels.update(current_sliver.label_allocations)
else:
requested.set_label_allocations(current_sliver.get_label_allocations())
requested.set_management_ip(current_sliver.get_management_ip())

# Modify MVP - only handle add components for now
if len(diff.added.components) > 0:
self.logger.info(f"Extend Lease - modify add res# {reservation}")
self.__check_components(rid=reservation.get_reservation_id(),
requested_components=requested.attached_components_info,
graph_node=graph_node,
Expand All @@ -235,13 +241,16 @@ def assign(self, *, reservation: ABCAuthorityReservation, delegation_name: str,
properties=reservation.get_slice().get_config_properties())
modified = UnitSet(plugin=self.authority.get_plugin(), units={unit.reservation_id: unit})
elif len(diff.removed.components) > 0 or len(diff.modified.components):
self.logger.info(f"Extend Lease - modify rem/modify res# {reservation}")
unit = Unit(rid=reservation.get_reservation_id(), slice_id=reservation.get_slice_id(),
actor_id=self.authority.get_guid(), sliver=requested, rtype=resource_type,
properties=reservation.get_slice().get_config_properties())
modified = UnitSet(plugin=self.authority.get_plugin(), units={unit.reservation_id: unit})
else:
self.logger.info(f"Extend Lease res# {reservation}")
return current
else:
self.logger.info(f"Extend Lease res# {reservation}")
return current

result = ResourceSet(gained=gained, modified=modified, lost=lost, rtype=resource_type)
Expand Down
28 changes: 22 additions & 6 deletions fabric_cf/actor/core/policy/network_service_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def allocate(self, *, rid: ID, requested_ns: NetworkServiceSliver, owner_ns: Net
return requested_ns

gateway_labels = self._assign_gateway_labels(ip_network=ip_network, subnet_list=subnet_list,
requested_ns_type=requested_ns.get_type())
requested_ns=requested_ns)

self.logger.debug(f"Gateway Labels: {gateway_labels}")

Expand Down Expand Up @@ -487,25 +487,41 @@ def _get_allocated_sliver(self, reservation: ABCReservationMixin) -> NetworkServ
self.logger.error("Could not find the allocated Sliver - should not reach here!")

def _assign_gateway_labels(self, *, ip_network: Union[IPv4Network, IPv6Network], subnet_list: List,
requested_ns_type: str) -> Labels:
requested_ns: NetworkServiceSliver) -> Labels:
"""
Assign gateway labels based on the requested network service type.
:param ip_network: The IP network from which subnets are derived, either IPv4Network or IPv6Network.
:param subnet_list: A list of subnets derived from the ip_network.
:param requested_ns_type: The type of the requested network service.
:param requested_ns: Network Service sliver.
:return: Gateway labels populated with the appropriate subnet and IP address.
"""
gateway_labels = Labels()
if requested_ns_type == ServiceType.FABNetv4:
if requested_ns.get_type() == ServiceType.FABNetv4:
# Allocate the requested network if available else allocate new network
if requested_ns.gateway and requested_ns.gateway.lab and requested_ns.gateway.lab.ipv4_subnet:
requested_subnet = IPv4Network(requested_ns.gateway.lab.ipv4_subnet)
if requested_subnet in subnet_list:
gateway_labels.ipv4_subnet = requested_subnet.with_prefixlen
gateway_labels.ipv4 = str(next(requested_subnet.hosts()))
return gateway_labels

gateway_labels.ipv4_subnet = subnet_list[0].with_prefixlen
gateway_labels.ipv4 = str(list(subnet_list[0].hosts())[0])

elif requested_ns_type == ServiceType.FABNetv4Ext:
elif requested_ns.get_type() == ServiceType.FABNetv4Ext:
gateway_labels.ipv4_subnet = ip_network.with_prefixlen
gateway_labels.ipv4 = str(subnet_list[0])

elif requested_ns_type in Constants.L3_FABNETv6_SERVICES:
elif requested_ns.get_type() in Constants.L3_FABNETv6_SERVICES:
# Allocate the requested network if available else allocate new network
if requested_ns.gateway and requested_ns.gateway.lab and requested_ns.gateway.lab.ipv6_subnet:
requested_subnet = IPv6Network(requested_ns.gateway.lab.ipv6_subnet)
if requested_subnet in subnet_list:
gateway_labels.ipv6_subnet = requested_subnet.with_prefixlen
gateway_labels.ipv6 = str(next(requested_subnet.hosts()))
return gateway_labels

gateway_labels.ipv6_subnet = subnet_list[0].with_prefixlen
gateway_labels.ipv6 = str(next(subnet_list[0].hosts()))

Expand Down
Loading