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

Refactor Task List and filters with error handlers for Scheduler #1957

Merged
merged 105 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
ab427be
More error handlign for Scheduler
Rieven Oct 18, 2023
ff0047d
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Oct 19, 2023
dc65052
Fix ConnectionError everywhere
Rieven Oct 23, 2023
4488a64
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Oct 23, 2023
50a555d
Fix health page
Rieven Oct 23, 2023
71dcb6b
Merge branch 'fix-more-scheduler-error-handling' of github.com:minvws…
Rieven Oct 23, 2023
75bb92a
fix lang
Rieven Oct 23, 2023
6c21376
Fix review changes
Rieven Oct 25, 2023
95140c2
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Oct 25, 2023
55ac513
fix lang
Rieven Oct 25, 2023
e2d8f05
Fix function
Rieven Oct 25, 2023
0659831
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Oct 30, 2023
d7414f5
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Nov 1, 2023
ff2a9e4
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Nov 6, 2023
bc797ea
Fix to handle all SchedulerErrors
Rieven Nov 6, 2023
20f9c4e
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Nov 6, 2023
7daf2bc
Fix test
Rieven Nov 6, 2023
a54fbd3
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Nov 7, 2023
abb0247
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Nov 7, 2023
e234451
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Nov 8, 2023
bd1444a
fix test
Rieven Nov 8, 2023
60dad55
Merge branch 'fix-more-scheduler-error-handling' of github.com:minvws…
Rieven Nov 8, 2023
f72001a
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Nov 9, 2023
7b46479
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Nov 27, 2023
bb26496
Fix scheduler
Rieven Nov 27, 2023
f4a83b9
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Nov 27, 2023
ec676ac
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Jan 4, 2024
9d5866e
Merge branch 'main' into fix-more-scheduler-error-handling
underdarknl Jan 31, 2024
6b17153
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Feb 5, 2024
503e753
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Feb 7, 2024
5e9685b
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Feb 7, 2024
8856ca1
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Feb 12, 2024
6bbb409
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Mar 18, 2024
ea041e8
Fix schduler views
Rieven Mar 19, 2024
085d163
remove try
Rieven Mar 19, 2024
9ef97ca
Fix Scheduler error being handled properly
Rieven Mar 21, 2024
dc86c84
fix health page
Rieven Mar 21, 2024
ed4757d
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Mar 21, 2024
03636be
fix tests and views
Rieven Mar 25, 2024
000cdbb
Merge branch 'fix-more-scheduler-error-handling' of github.com:minvws…
Rieven Mar 25, 2024
f00674f
Fixes for scheduler view
Rieven Mar 25, 2024
2b59ef3
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Mar 25, 2024
1304663
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Mar 25, 2024
b5aa49d
Fix scheduler error handler
Rieven Mar 26, 2024
2a66a2e
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Apr 2, 2024
9376d16
Fix soem views and tests
Rieven Apr 4, 2024
f7b865f
Fix more try and except
Rieven Apr 4, 2024
7cddf60
Remove double message
Rieven Apr 4, 2024
a316a2e
Move views and error handling
Rieven Apr 8, 2024
21b6653
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Apr 8, 2024
3cc36d4
Fix task list not showing automatically
Rieven Apr 10, 2024
d6e2c90
remove double filter form
Rieven Apr 10, 2024
6c94e87
Fix normalizer detail
Rieven Apr 10, 2024
5cd1648
Set context data
Rieven Apr 11, 2024
47cf6b3
Fix views for scheduler errors
Rieven Apr 22, 2024
9f10b5f
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Apr 22, 2024
86968ff
Move some actions
Rieven Apr 22, 2024
5cb97e8
fix tests
Rieven Apr 24, 2024
bbdd065
Fix scheduler filters and task list
Rieven Apr 29, 2024
a9fe041
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Apr 29, 2024
ec6ad51
Fix templates task list
Rieven Apr 30, 2024
9fadb16
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Apr 30, 2024
4bcc667
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven May 6, 2024
f81720a
Fix clear filters
Rieven May 6, 2024
4977c37
Fix scheduler view
Rieven May 7, 2024
c7d3236
Fix some errors
Rieven May 8, 2024
e5e060f
add test
Rieven May 14, 2024
62853a6
move some code to create logic
Rieven May 29, 2024
961de4b
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Jun 5, 2024
4c4a260
fix tests
Rieven Jun 6, 2024
1dfc81e
fix tests
Rieven Jun 10, 2024
cd08c98
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Jun 10, 2024
c84ef9a
fix tests
Rieven Jun 17, 2024
07ab246
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Jun 17, 2024
0a61c75
fix lang and precommit
Rieven Jun 17, 2024
ca3bf8c
fix precommit
Rieven Jun 17, 2024
030a430
Merge branch 'main' into fix-more-scheduler-error-handling
Rieven Jun 19, 2024
fb6acd7
Update rocky/rocky/scheduler.py
Rieven Jun 19, 2024
43e1001
Update rocky/rocky/views/tasks.py
Rieven Jun 19, 2024
c06636d
Review feedback
Rieven Jun 19, 2024
c0d08d8
Merge branch 'fix-more-scheduler-error-handling' of github.com:minvws…
Rieven Jun 19, 2024
2ce8ad6
Fix lang
Rieven Jun 19, 2024
1a74ad4
Fix errors, not redirecting
Rieven Jun 19, 2024
874bda6
fix lang
Rieven Jun 19, 2024
bdb01d9
fix tests
Rieven Jun 19, 2024
7813253
Merge branch 'main' into fix-more-scheduler-error-handling
underdarknl Jun 20, 2024
da0ab12
Fix lang en text stats to status
Rieven Jun 24, 2024
032c6aa
Merge branch 'fix-more-scheduler-error-handling' of github.com:minvws…
Rieven Jun 24, 2024
09698fc
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Jun 24, 2024
f9a691a
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Jun 27, 2024
aabf97c
Merge branch 'main' of github.com:minvws/nl-kat-coordination into fix…
Rieven Jul 8, 2024
d411fd2
fix test adding fixture
Rieven Jul 8, 2024
a1f060d
Fixes for 2 list at boefje detail
Rieven Jul 10, 2024
b35f80a
extra message to main class
Rieven Jul 10, 2024
63ee0cf
Fix filtering on plugin_id for normalizers
jpbruinsslot Jul 10, 2024
b671cae
00~Merge branch 'fix/mula/fix-normalizer-filtering' of github.com:min…
Rieven Jul 10, 2024
7acc1f1
Pre-commit
jpbruinsslot Jul 10, 2024
e5a5865
00~Merge branch 'fix/mula/fix-normalizer-filtering' of github.com:min…
Rieven Jul 10, 2024
47eee5b
Add input ooi for normalizer detail
Rieven Jul 11, 2024
074507a
Add task actions
Rieven Jul 11, 2024
f6b76c8
boefje_meta_id for download normalizer task fix
Rieven Jul 11, 2024
09cb31a
00~Merge branch 'main' of github.com:minvws/nl-kat-coordination into …
Rieven Jul 11, 2024
2167c52
Merge branch 'main' into fix-more-scheduler-error-handling
dekkers Jul 11, 2024
56e2020
fix lang
Rieven Jul 11, 2024
af89a4c
Merge branch 'fix-more-scheduler-error-handling' of github.com:minvws…
Rieven Jul 11, 2024
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
15 changes: 9 additions & 6 deletions docs/source/developer_documentation/rocky.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,18 @@ classDiagram
direction RL
class OrganizationView
class OctopoesView
class BoefjeMixin
class SchedulerView
class TaskListView

OctopoesView <|-- OrganizationView

BoefjeMixin <|-- OctopoesView
BoefjeDetailView <|-- BoefjeMixin
OOIDetailView <|-- BoefjeMixin
SchedulerView <|-- OctopoesView
TaskListView <|-- SchedulerView
BoefjeDetailView <|-- TaskListView
OOIDetailView <|-- TaskListView
OOIDetailView <|-- OOIRelatedObjectAddView
OOIDetailView <|-- OOIFindingManager
ChangeClearanceLevel <|-- BoefjeMixin
ChangeClearanceLevel <|-- SchedulerView

SingleOOIMixin <|-- OctopoesView
SingleOOITreeMixin <|-- SingleOOIMixin
Expand Down Expand Up @@ -300,13 +302,14 @@ direction RL

class PluginSettingsDeleteView
class BoefjeDetailView
class TaskListView

KATalogusView <|-- OrganizationView
KATalogusView <|-- FormView
SinglePluginView <|-- OrganizationView
SingleSettingView <|-- SinglePluginView
BoefjeDetailView <|-- PluginSettingsListView
BoefjeDetailView <|-- BoefjeMixin
BoefjeDetailView <|-- TaskListView
PluginEnableDisableView <|-- SinglePluginView
PluginSettingsAddView <|-- FormView
PluginSettingsAddView <|-- SinglePluginView
Expand Down
6 changes: 6 additions & 0 deletions rocky/account/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def get_context_data(self, **kwargs):
context["perms"] = OrganizationPermWrapper(self.organization_member)
return context

def indemnification_error(self):
return messages.error(
self.request,
f"Indemnification not present at organization {self.organization}.",
)

@property
def may_update_clearance_level(self) -> bool:
if not self.indemnification_present:
Expand Down
28 changes: 28 additions & 0 deletions rocky/assets/css/components/table-state-icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,27 @@ table td .icon {
}
}

&.completed {
&::before {
content: "\ea67"; // $ti-icon-circle-check
color: var(--color-alert-positive);
}
}

&.negative {
&::before {
content: "\ea6a"; // $ti-icon-circle-x
color: var(--color-alert-negative);
}
}

&.failed {
&::before {
content: "\ea6a"; // $ti-icon-circle-x
color: var(--color-alert-negative);
}
}

&.incomplete {
&::before {
content: "\ea6a"; // $ti-icon-circle-x
Expand All @@ -68,13 +82,27 @@ table td .icon {
}
}

&.dispatched {
&::before {
content: "\ed27"; // $ti-icon-circle-dashed (should become ti-icon-progress, when we have it)
color: var(--color-alert-informative);
}
}

&.queued {
&::before {
content: "\ea70"; // $ti-icon-clock
color: var(--color-alert-warning);
}
}

&.pending {
&::before {
content: "\ea70"; // $ti-icon-clock
color: var(--color-alert-warning);
}
}

&.cancelled {
&::before {
content: "\ea05"; // $ti-icon-alert-circle
Expand Down
1 change: 1 addition & 0 deletions rocky/katalogus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def get_plugins(self, **params):
def get_plugin(self, plugin_id: str) -> Plugin:
response = self.session.get(f"{self.organization_uri}/plugins/{plugin_id}")
response.raise_for_status()

return parse_plugin(response.json())

def get_plugin_schema(self, plugin_id) -> dict | None:
Expand Down
4 changes: 2 additions & 2 deletions rocky/katalogus/templates/boefje_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1>{{ plugin.name }}</h1>
</div>
</section>
{% if perms.tools.can_view_katalogus_settings %}
{% include "plugin_settings_list.html" with object_list=object_list plugin=plugin %}
{% include "plugin_settings_list.html" with object_list=plugin_settings plugin=plugin %}

{% endif %}
<section>
Expand Down Expand Up @@ -73,7 +73,7 @@ <h2>{% translate "Produces" %}</h2>
</ul>
</p>
<p>
{% include "tasks/partials/boefje_task_history.html" %}
{% include "tasks/plugin_detail_task_list.html" %}

</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions rocky/katalogus/templates/normalizer_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1>{{ plugin.name }}</h1>
</div>
</section>
{% if perms.tools.can_view_katalogus_settings %}
{% include "plugin_settings_list.html" with object_list=object_list plugin=plugin %}
{% include "plugin_settings_list.html" with object_list=plugin_settings plugin=plugin %}

{% endif %}
<section>
Expand Down Expand Up @@ -74,7 +74,7 @@ <h2>{% translate "Produces" %}</h2>
{% endif %}
</p>
<p>
{% include "tasks/partials/normalizer_task_history.html" %}
{% include "tasks/plugin_detail_task_list.html" %}

</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion rocky/katalogus/templates/partials/objects_to_scan.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2>{{ form_title }}</h2>
</p>
{% endif %}
{% if select_oois_form.fields.ooi.choices %}
{% include "partials/form/checkbox_group_table_form.html" with checkbox_group_table_form=select_oois_form btn_text="Start scan" plugin_enabled=plugin.enabled key="boefje_id" value=plugin.id action="scan" checkbox_group_table_filter_form=select_ooi_filter_form unique_id="" %}
{% include "partials/form/checkbox_group_table_form.html" with checkbox_group_table_form=select_oois_form btn_text="Start scan" plugin_enabled=plugin.enabled key="boefje_id" value=plugin.id action="scan_oois" checkbox_group_table_filter_form=select_ooi_filter_form unique_id="" %}

{% elif has_consumable_oois %}
{% blocktranslate trimmed with name=plugin.name %}
Expand Down
2 changes: 0 additions & 2 deletions rocky/katalogus/templates/plugin_settings_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ <h1>{{ plugin.type|title }}{% translate " Details" %}</h1>
{% csrf_token %}
<button type="submit">{% translate "Delete" %}</button>
</form>
{% include "partials/pagination.html" %}

</div>
</div>
</section>
Expand Down
5 changes: 3 additions & 2 deletions rocky/katalogus/views/change_clearance_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView

from katalogus.views.mixins import BoefjeMixin, SinglePluginView
from katalogus.views.mixins import SinglePluginView
from rocky.views.scheduler import SchedulerView


class ChangeClearanceLevel(OrganizationPermissionRequiredMixin, BoefjeMixin, SinglePluginView, TemplateView):
class ChangeClearanceLevel(OrganizationPermissionRequiredMixin, SchedulerView, SinglePluginView, TemplateView):
template_name = "change_clearance_level.html"
permission_required = "tools.can_set_clearance_level"

Expand Down
54 changes: 2 additions & 52 deletions rocky/katalogus/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@
from django.utils.translation import gettext_lazy as _
from httpx import HTTPError, HTTPStatusError
from rest_framework.status import HTTP_404_NOT_FOUND
from tools.view_helpers import schedule_task

from katalogus.client import Boefje as KATalogusBoefje
from katalogus.client import KATalogusClientV1, get_katalogus
from katalogus.client import Normalizer as KATalogusNormalizer
from octopoes.models import OOI
from rocky.scheduler import Boefje, BoefjeTask, Normalizer, NormalizerTask, PrioritizedItem, RawData
from rocky.views.mixins import OctopoesView
from katalogus.client import KATalogusClientV1, Plugin, get_katalogus

logger = getLogger(__name__)


class SinglePluginView(OrganizationView):
katalogus_client: KATalogusClientV1
plugin: KATalogusBoefje | KATalogusNormalizer
plugin: Plugin

def setup(self, request, *args, plugin_id: str, **kwargs):
"""
Expand Down Expand Up @@ -57,47 +51,3 @@ def is_required_field(self, field: str) -> bool:
def is_secret_field(self, field: str) -> bool:
"""Check whether this field should be secret, defaults to False."""
return bool(self.plugin_schema and field in self.plugin_schema.get("secret", []))


class NormalizerMixin(OctopoesView):
"""
When a user wants to run a normalizer on a given set of raw data,
this mixin provides the method to construct the normalizer task for that data and run it.
"""

def run_normalizer(self, normalizer: KATalogusNormalizer, raw_data: RawData) -> None:
normalizer_task = NormalizerTask(normalizer=Normalizer(id=normalizer.id, version=None), raw_data=raw_data)

task = PrioritizedItem(priority=1, data=normalizer_task)

schedule_task(self.request, self.organization.code, task)


class BoefjeMixin(OctopoesView):
"""
When a user wants to scan one or multiple OOI's,
this mixin provides the methods to construct the boefjes for the OOI's and run them.
"""

def run_boefje(self, katalogus_boefje: KATalogusBoefje, ooi: OOI | None) -> None:
boefje_task = BoefjeTask(
boefje=Boefje.model_validate(katalogus_boefje.model_dump()),
input_ooi=ooi.reference if ooi else None,
organization=self.organization.code,
)

task = PrioritizedItem(priority=1, data=boefje_task)
schedule_task(self.request, self.organization.code, task)

def run_boefje_for_oois(
self,
boefje: KATalogusBoefje,
oois: list[OOI],
) -> None:
if not oois and not boefje.consumes:
self.run_boefje(boefje, None)

for ooi in oois:
if ooi.scan_profile and ooi.scan_profile.level < boefje.scan_level:
self.can_raise_clearance_level(ooi, boefje.scan_level)
self.run_boefje(boefje, ooi)
Loading