Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Set progress -2 for interrupted scans #288

Merged
merged 3 commits into from
Jun 24, 2020

Conversation

jjnicola
Copy link
Member

No description provided.

jjnicola added 2 commits June 23, 2020 14:07
When a running scan is interrupted (e.g. openvas is killed unexpectedly),
set the progress to -2
Also, use a Enum class for default progress values.
@jjnicola jjnicola requested a review from bjoernricks as a code owner June 23, 2020 12:53
@codecov
Copy link

codecov bot commented Jun 23, 2020

Codecov Report

Merging #288 into master will decrease coverage by 0.08%.
The diff coverage is 96.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #288      +/-   ##
==========================================
- Coverage   75.12%   75.04%   -0.09%     
==========================================
  Files          22       22              
  Lines        2505     2517      +12     
==========================================
+ Hits         1882     1889       +7     
- Misses        623      628       +5     
Impacted Files Coverage Δ
ospd/ospd.py 75.70% <93.33%> (-0.37%) ⬇️
ospd/scan.py 90.13% <100.00%> (-0.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8672a75...04a8804. Read the comment docs.

Copy link
Contributor

@bjoernricks bjoernricks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused when to use the value of the enum and when not to use it. It seems your code mixes that up too. For example:

     self.scan_collection.set_progress(
            scan_id, ScanProgress.INTERRUPTED.value
        )
        self.set_scan_status(scan_id, ScanStatus.FINISHED)

@jjnicola
Copy link
Member Author

I am a bit confused when to use the value of the enum and when not to use it. It seems your code mixes that up too. For example:

     self.scan_collection.set_progress(
            scan_id, ScanProgress.INTERRUPTED.value
        )
        self.set_scan_status(scan_id, ScanStatus.FINISHED)

While ScanStatus is just an Enum class, ScanProgress is an IntEnum class. While the first one doesn't allow to use minor than < or greater than >, the second one yes. Then for the progress you need the value to send it to the client (e.g. 100), while the status is just the name (finished). During the comparisons, the values are not required, but it is necessary to store the progress value and not name in the scan table. When the get_scan is received, takes the progress in the right format from the scan table.

@jjnicola jjnicola requested a review from bjoernricks June 24, 2020 06:58
@bjoernricks bjoernricks merged commit cfa4a29 into greenbone:master Jun 24, 2020
@jjnicola jjnicola deleted the progress-interrupt branch June 24, 2020 10:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants