Change in vdsm[master]: sdm: Jobs may be run only when status=pending
gerrit-hooks has posted comments on this change. Change subject: sdm: Jobs may be run only when status=pending .. Patch Set 2: * Update tracker: IGNORE, no Bug-Url found -- To view, visit https://gerrit.ovirt.org/61138 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I601f6db19527635c1a00c3a4c2910eac4ac5371b Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: sdm: Jobs may be run only when status=pending
Adam Litke has abandoned this change. Change subject: sdm: Jobs may be run only when status=pending .. Abandoned Alternate solution merged. -- To view, visit https://gerrit.ovirt.org/61138 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I601f6db19527635c1a00c3a4c2910eac4ac5371b Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: sdm: Jobs may be run only when status=pending
Nir Soffer has posted comments on this change. Change subject: sdm: Jobs may be run only when status=pending .. Patch Set 2: (1 comment) https://gerrit.ovirt.org/#/c/61138/2/vdsm/storage/sdm/api/base.py File vdsm/storage/sdm/api/base.py: Line 44: if self._status == jobs.STATUS.ABORTED: Line 45: self.log.info("Job id=%s aborted while pending", self.id) Line 46: return Line 47: if self._status != jobs.STATUS.PENDING: Line 48: raise InvalidJobStatus("Job id=%s cannot be started from %r status", pep8 tools is unhappy: 19:57:11 ./vdsm/storage/sdm/api/base.py:48:80: E501 line too long (80 > 79 characters) Line 49:self.id, self.status) Line 50: self._status = jobs.STATUS.RUNNING Line 51: vars.job_id = self.id Line 52: try: -- To view, visit https://gerrit.ovirt.org/61138 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I601f6db19527635c1a00c3a4c2910eac4ac5371b Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: Yes ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: sdm: Jobs may be run only when status=pending
Nir Soffer has posted comments on this change. Change subject: sdm: Jobs may be run only when status=pending .. Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.ovirt.org/61138 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I601f6db19527635c1a00c3a4c2910eac4ac5371b Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: sdm: Jobs may be run only when status=pending
gerrit-hooks has posted comments on this change. Change subject: sdm: Jobs may be run only when status=pending .. Patch Set 2: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61138 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I601f6db19527635c1a00c3a4c2910eac4ac5371b Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: sdm: Jobs may be run only when status=pending
Nir Soffer has posted comments on this change. Change subject: sdm: Jobs may be run only when status=pending .. Patch Set 1: (3 comments) https://gerrit.ovirt.org/#/c/61138/1/tests/storage_sdm_api_test.py File tests/storage_sdm_api_test.py: Line 71: )) Line 72: def test_run_from_invalid_state(self, status): Line 73: job = TestingJob() Line 74: job.set_status(status) Line 75: self.assertRaises(base.CannotRunJob, job.run) Lets check also that job status does not change in this case. Line 76: Line 77: Line 78: class TestingJob(base.Job): Line 79: Line 82: super(TestingJob, self).__init__(job_id, 'testing_job', 'host_id') Line 83: self.exception = exception Line 84: Line 85: def set_status(self, value): Line 86: self._status = value Do we really need this helper? Line 87: Line 88: def _abort(self): Line 89: pass Line 90: https://gerrit.ovirt.org/#/c/61138/1/vdsm/storage/sdm/api/base.py File vdsm/storage/sdm/api/base.py: Line 26: from vdsm import exception Line 27: from vdsm.storage.threadlocal import vars Line 28: Line 29: Line 30: class CannotRunJob(Exception): This error means something impossible has happened, probably bug in the code. Lets name it InvalidJobStatus. Line 31: pass Line 32: Line 33: Line 34: class Job(jobs.Job): -- To view, visit https://gerrit.ovirt.org/61138 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I601f6db19527635c1a00c3a4c2910eac4ac5371b Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: Yes ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: sdm: Jobs may be run only when status=pending
gerrit-hooks has posted comments on this change. Change subject: sdm: Jobs may be run only when status=pending .. Patch Set 1: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61138 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I601f6db19527635c1a00c3a4c2910eac4ac5371b Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: sdm: Jobs may be run only when status=pending
Adam Litke has uploaded a new change for review. Change subject: sdm: Jobs may be run only when status=pending .. sdm: Jobs may be run only when status=pending An SDM Job begins its lifecycle in pending state and at some point a scheduler will call its run() method to run it. The job should not run from any state other than pending. If a job was aborted while waiting to be executed we should print a message and return. If the job is in any other state we have a bug and an exception should be raised. Change-Id: I601f6db19527635c1a00c3a4c2910eac4ac5371b Signed-off-by: Adam Litke --- M tests/storage_sdm_api_test.py M vdsm/storage/sdm/api/base.py 2 files changed, 32 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/61138/1 diff --git a/tests/storage_sdm_api_test.py b/tests/storage_sdm_api_test.py index c8d93d2..3306c30 100644 --- a/tests/storage_sdm_api_test.py +++ b/tests/storage_sdm_api_test.py @@ -21,6 +21,7 @@ import uuid from testlib import VdsmTestCase +from testlib import expandPermutations, permutations from sdmtestlib import wait_for_job from vdsm import jobs @@ -30,6 +31,7 @@ from storage.sdm.api import base +@expandPermutations class ApiBaseTests(VdsmTestCase): def run_job(self, job): @@ -58,6 +60,20 @@ self.assertEqual(jobs.STATUS.FAILED, job.status) self.assertIsInstance(job.error, exception.VdsmException) +def test_run_aborted_job(self): +job = TestingJob() +job.abort() +job.run() +self.assertEqual(jobs.STATUS.ABORTED, job.status) + +@permutations(( +(jobs.STATUS.DONE,), (jobs.STATUS.RUNNING,), (jobs.STATUS.FAILED,) +)) +def test_run_from_invalid_state(self, status): +job = TestingJob() +job.set_status(status) +self.assertRaises(base.CannotRunJob, job.run) + class TestingJob(base.Job): @@ -66,6 +82,12 @@ super(TestingJob, self).__init__(job_id, 'testing_job', 'host_id') self.exception = exception +def set_status(self, value): +self._status = value + +def _abort(self): +pass + def _run(self): assert(self.status == jobs.STATUS.RUNNING) assert(vars.job_id == self.id) diff --git a/vdsm/storage/sdm/api/base.py b/vdsm/storage/sdm/api/base.py index a342300..eb88f35 100644 --- a/vdsm/storage/sdm/api/base.py +++ b/vdsm/storage/sdm/api/base.py @@ -27,6 +27,10 @@ from vdsm.storage.threadlocal import vars +class CannotRunJob(Exception): +pass + + class Job(jobs.Job): _JOB_TYPE = "storage" log = logging.getLogger('storage.sdmjob') @@ -37,6 +41,12 @@ self.host_id = host_id def run(self): +if self._status == jobs.STATUS.ABORTED: +self.log.info("Job id=%s aborted while pending", self.id) +return +if self._status != jobs.STATUS.PENDING: +raise CannotRunJob("Job id=%s cannot be started from %r status", + self.id, self.status) self._status = jobs.STATUS.RUNNING vars.job_id = self.id try: -- To view, visit https://gerrit.ovirt.org/61138 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I601f6db19527635c1a00c3a4c2910eac4ac5371b Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org