#8135 When Service weight is set as 0 for server in IPA location "IPA Error 903: InternalError" is displayed
Closed: fixed 2 years ago by rcritten. Opened 2 years ago by fcami.

Ticket was cloned from Red Hat Bugzilla (product Red Hat Enterprise Linux 8): Bug 1777806

Description of problem: When Service weight is set as 0 for server in IPA
location "IPA Error 903: InternalError" is displayed

Version-Release number of selected component (if applicable):
ipa-server-4.8.2-2.module+el8.2.0+4736+360582ce.x86_64


How reproducible: Always


Steps to Reproduce:
1. Install IPA server with 2 locations
2. Setup replica.rhel82.test in one location1 with Service weight 10
3. Setup replica2.rhel82.test in another location2 with Service weight 0

Actual results:
2. Server replica.rhel82.test is added to the location1 with Service weight 10
3. Although not sure if weight of 0 is correct, but when replica2.rhel82.test
is added to location2 with Service weight 0 an error is displayed on the UI
'Error 903: Internal error is occured'


httpd error_log
  1 [Thu Nov 28 16:02:26.740769 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950] ipa: ERROR: non-public: ZeroDivisionError:
float division by zero
  2 [Thu Nov 28 16:02:26.740801 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950] Traceback (most recent call last):
  3 [Thu Nov 28 16:02:26.740805 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]   File
"/usr/lib/python3.6/site-packages/ipaserver/rpcserver.py", line 368, in
wsgi_execute
  4 [Thu Nov 28 16:02:26.740809 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]     result = command(*args, **options)
  5 [Thu Nov 28 16:02:26.740812 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]   File
"/usr/lib/python3.6/site-packages/ipalib/frontend.py", line 450, in __call__
  6 [Thu Nov 28 16:02:26.740815 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]     return self.__do_call(*args, **options)
  7 [Thu Nov 28 16:02:26.740818 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]   File
"/usr/lib/python3.6/site-packages/ipalib/frontend.py", line 478, in __do_call
  8 [Thu Nov 28 16:02:26.740821 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]     ret = self.run(*args, **options)
  9 [Thu Nov 28 16:02:26.740824 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]   File
"/usr/lib/python3.6/site-packages/ipalib/frontend.py", line 800, in run
 10 [Thu Nov 28 16:02:26.740827 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]     return self.execute(*args, **options)
 11 [Thu Nov 28 16:02:26.740831 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]   File
"/usr/lib/python3.6/site-packages/ipaserver/plugins/location.py", line 230, in
execute
 12 [Thu Nov 28 16:02:26.740834 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]
int(server['ipaserviceweight'][0])*100.0/weight_sum)
 13 [Thu Nov 28 16:02:26.740838 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950] ZeroDivisionError: float division by zero
 14 [Thu Nov 28 16:02:26.740853 2019] [wsgi:error] [pid 8648:tid
140034638186240] [remote :49950]

The RFC at https://tools.ietf.org/html/rfc2782 states that weight=0 is a valid use-case.

If all servers in a location have weight=0, the sum of their weights is still 0:

            for server in servers:
                weight = int(server.get('ipaserviceweight', [100])[0])
                weight_sum += weight

leading to a division by zero later on:

            for server in servers_additional_info.values():
                server['service_relative_weight'] = [
                    u'{:.1f}%'.format(
                        int(server['ipaserviceweight'][0])*100.0/weight_sum)
                ]

Possible solution is to set service_relative_weight to 0 if weight_sum is 0.

~

Expected results:
Fix the error "IPA Error 903: InternalError"

Additional info:

Metadata Update from @fcami:
- Custom field rhbz adjusted to https://bugzilla.redhat.com/show_bug.cgi?id=1777806

2 years ago

Metadata Update from @rcritten:
- Issue assigned to rcritten

2 years ago

master:

  • f589a89 Fix div-by-zero when svc weight is 0 for all masters in location

Metadata Update from @rcritten:
- Issue priority set to: normal
- Issue set to the milestone: FreeIPA 4.8.5
- Issue tagged with: bug

2 years ago

ipa-4-8:

  • 12d6864 Fix div-by-zero when svc weight is 0 for all masters in location

Metadata Update from @rcritten:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Login to comment on this ticket.

Metadata