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

[21.05] agent backport, part 3 #832

Merged
merged 12 commits into from
Nov 20, 2023
Next Next commit
agent: only schedule requests in State.due
Scheduling requests that are already running or are in a state
to be archived isn't useful and may cause unneccessary errors.

PL-131813

(cherry picked from commit 91466ec)
dpausp committed Nov 17, 2023
commit 0590c8fc77c13dbc8ee44bd16192b84807dff48e
3 changes: 2 additions & 1 deletion pkgs/fc/agent/fc/maintenance/reqmanager.py
Original file line number Diff line number Diff line change
@@ -359,7 +359,7 @@ def _estimated_request_duration(self, request) -> int:
@require_lock
@require_directory
def schedule(self):
"""Triggers request scheduling on server."""
"""Gets (updated) start times for pending requests from the directory."""
self.log.debug("schedule-start")

schedule_maintenance = {
@@ -368,6 +368,7 @@ def schedule(self):
"comment": req.comment,
}
for reqid, req in self.requests.items()
if req.state == State.pending
}
if schedule_maintenance:
self.log.debug(
10 changes: 7 additions & 3 deletions pkgs/fc/agent/fc/maintenance/tests/test_reqmanager.py
Original file line number Diff line number Diff line change
@@ -173,13 +173,17 @@ def test_list_other_requests(reqmanager):

@unittest.mock.patch("fc.util.directory.connect")
def test_schedule_requests(connect, reqmanager):
req = reqmanager.add(Request(Activity(), 320, "comment"))
req = reqmanager.add(Request(Activity(), 320, "schedule"))
req_success = reqmanager.add(
Request(Activity(), 320, "done, do not schedule this")
)
req_success.state = State.success
rpccall = connect().schedule_maintenance
rpccall.return_value = {req.id: {"time": "2016-04-20T15:12:40.9+00:00"}}
reqmanager.schedule()
#
# The estimate is expected to be 900 (15 min) which is the minimum.
rpccall.assert_called_once_with(
{req.id: {"estimate": 900, "comment": "comment"}}
{req.id: {"estimate": 900, "comment": "schedule"}}
)
assert req.next_due == datetime.datetime(
2016, 4, 20, 15, 12, 40, 900000, tzinfo=pytz.UTC