Skip to content
Snippets Groups Projects
Verified Commit e8e0da07 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Solve a FIXME and revert to the vanilla implementation of...

Solve a FIXME and revert to the vanilla implementation of task_validate_products over our custom one
parent 25ca6784
No related branches found
No related tags found
1 merge request!436Add modify note workflow to all existing products
Pipeline #95033 passed
"""Remove obsolete validation task.
Revision ID: 7c3094cd282a
Revises: 24858fd1d805
Create Date: 2025-06-20 11:34:08.439370
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '7c3094cd282a'
down_revision = '24858fd1d805'
branch_labels = None
depends_on = None
from orchestrator.migrations.helpers import create_task, delete_workflow
old_task = {
"name": "task_validate_geant_products",
"description": "Validate GEANT products"
}
def upgrade() -> None:
conn = op.get_bind()
conn.execute(sa.text(f"""
DELETE FROM processes WHERE workflow_id = (SELECT workflow_id FROM workflows WHERE name = '{old_task["name"]}')
"""))
delete_workflow(conn, old_task["name"])
def downgrade() -> None:
conn = op.get_bind()
create_task(conn, old_task)
......@@ -4,12 +4,10 @@ from celery import shared_task
from orchestrator.services.processes import start_process
from gso.schedules.scheduling import CronScheduleConfig, scheduler
from gso.services.processes import count_incomplete_validate_products
@shared_task
@scheduler(CronScheduleConfig(name="Validate Products and inactive subscriptions", minute="30", hour="2"))
def validate_products() -> None:
"""Validate all products."""
if count_incomplete_validate_products() == 0:
start_process("task_validate_geant_products")
start_process("task_validate_products")
......@@ -18,19 +18,6 @@ def get_processes_by_workflow_name(workflow_name: str) -> Query:
return ProcessTable.query.join(WorkflowTable).filter(WorkflowTable.name == workflow_name)
def count_incomplete_validate_products() -> int:
"""Count the number of incomplete validate_geant_products processes.
Returns:
The count of incomplete 'validate_geant_products' processes.
"""
return (
get_processes_by_workflow_name("validate_geant_products")
.filter(ProcessTable.last_status != ProcessStatus.COMPLETED)
.count()
)
def get_failed_tasks() -> list[ProcessTable]:
"""Get all tasks that have failed."""
return ProcessTable.query.filter(
......
......@@ -163,7 +163,6 @@
"task_modify_partners": "Modify partner task",
"task_redeploy_base_config": "Redeploy base config on multiple routers",
"task_send_email_notifications": "Send email notifications for failed tasks",
"task_validate_geant_products": "Validation task for GEANT products",
"terminate_edge_port": "Terminate Edge Port",
"terminate_iptrunk": "Terminate IP Trunk",
"terminate_geant_ip": "Terminate GÉANT IP",
......
......@@ -104,7 +104,6 @@ LazyWorkflowInstance("gso.workflows.opengear.import_opengear", "import_opengear"
# Tasks
LazyWorkflowInstance("gso.workflows.tasks.send_email_notifications", "task_send_email_notifications")
LazyWorkflowInstance("gso.workflows.tasks.validate_geant_products", "task_validate_geant_products")
LazyWorkflowInstance("gso.workflows.tasks.create_partners", "task_create_partners")
LazyWorkflowInstance("gso.workflows.tasks.modify_partners", "task_modify_partners")
LazyWorkflowInstance("gso.workflows.tasks.delete_partners", "task_delete_partners")
......
"""A task that checks for all products in the database to be well-kept."""
# <!-- vale off -->
# Copyright 2019-2020 SURF.
# Copyright 2024 GÉANT Vereniging.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# <!-- vale on -->
from orchestrator.targets import Target
from orchestrator.workflow import StepList, done, init, workflow
from orchestrator.workflows.tasks.validate_products import (
check_all_workflows_are_in_db,
check_db_fixed_input_config,
check_subscription_models,
check_that_products_have_create_modify_and_terminate_workflows,
check_workflows_for_matching_targets_and_descriptions,
)
@workflow("Validate GEANT products", target=Target.SYSTEM)
def task_validate_geant_products() -> StepList:
"""Validate products in the database.
This task is based on the ``task_validate_products`` present in ``orchestrator-core`` but it does not check for the
existence of the ``modify_note`` workflow on all products, since this workflow is currently not used in GEANT.
"""
return (
init
>> check_all_workflows_are_in_db
>> check_workflows_for_matching_targets_and_descriptions
# >> check_that_products_have_at_least_one_workflow FIXME: Uncomment as soon as this would pass again
>> check_db_fixed_input_config
>> check_that_products_have_create_modify_and_terminate_workflows
>> check_subscription_models
>> done
)
......@@ -4,14 +4,15 @@ from test.workflows import assert_complete, extract_state, run_workflow
@pytest.mark.workflow()
def test_task_validate_geant_products():
result, _, _ = run_workflow("task_validate_geant_products", [{}])
def test_task_validate_products():
result, _, _ = run_workflow("task_validate_products", [{}])
assert_complete(result)
state = extract_state(result)
assert state["check_all_workflows_are_in_db"]
assert state["check_workflows_for_matching_targets_and_descriptions"]
# assert state["check_that_products_have_at_least_one_workflow"] FIXME: Uncomment when the task is reverted again
assert state["check_that_products_have_at_least_one_workflow"]
assert state["check_that_active_products_have_a_modify_note"]
assert state["check_db_fixed_input_config"]
assert state["check_that_products_have_create_modify_and_terminate_workflows"]
assert state["check_subscription_models"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment