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

Script overview page does not show the last run/status of script job exection in 4.1.x #17501

Closed
timeu opened this issue Sep 16, 2024 · 2 comments · Fixed by #17581
Closed

Script overview page does not show the last run/status of script job exection in 4.1.x #17501

timeu opened this issue Sep 16, 2024 · 2 comments · Fixed by #17581
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@timeu
Copy link

timeu commented Sep 16, 2024

Deployment Type

Self-hosted

NetBox Version

v4.1.1

Python Version

3.10

Steps to Reproduce

  1. Add a dummy script:
from django.db.models import Count, Q

from dcim.models import Cable
from extras.scripts import Script


class Test(Script):
    class Meta:
        name = f'test'
        description = f'test'

    def test_report(self):
        pass

  1. Execute the script
  2. Navigate to the script overview

Expected Behavior

Last Run and Status should be displayed corectly (job run date and status)

Observed Behavior

"Last Run" column shows "Never" and status is empty.

image

image

I believe the issue is:

The name of the script job is set to empty string here but the view template (https://github.com/netbox-community/netbox/blob/develop/netbox/templates/extras/script_list.html#L53) filters the last job on the scipt name.

@timeu timeu added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Sep 16, 2024
@alehaa
Copy link
Contributor

alehaa commented Sep 16, 2024

That a Script job doesn't have a name is correct, as its identified by the script instance linked to it.

To fix this issue, I believe JobsMixin.get_latest_jobs() must not use the name as key for the dictionary being generated and also not sort by name. Afterwards it should be sufficient to just get the latest job of the script using last_job=script.get_latest_jobs|first, if needed filtering name='' to allow future extensions.

@timeu
Copy link
Author

timeu commented Sep 16, 2024

@alehaa : Sounds right. This will work also with script instances that contain multiple classes which have their own job runs ?

@arthanson arthanson added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Sep 16, 2024
@arthanson arthanson added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Sep 23, 2024
@arthanson arthanson self-assigned this Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants