Skip to content

Stop serializing all hosts and template invocations in job invocation#1036

Merged
adamlazik1 merged 7 commits into
theforeman:masterfrom
adamruzicka:api-cleanup
Jul 2, 2026
Merged

Stop serializing all hosts and template invocations in job invocation#1036
adamlazik1 merged 7 commits into
theforeman:masterfrom
adamruzicka:api-cleanup

Conversation

@adamruzicka

@adamruzicka adamruzicka commented May 27, 2026

Copy link
Copy Markdown
Contributor

The show endpoint serialized every host (via hosts/base) and every template invocation on each request, including the 1-second polling requests from the detail page. None of this data is used by the frontend — hosts are fetched separately by the host table, and per-host template invocations are fetched on row expand.

The biggest problem with this is that removing it changes a public api. To offer some alternatives, we could:

  • add a parameter that would just disable the parts that I'm proposing to remove
  • add a new endpoint, deprecate the old one and eventually remove it, but then we'd eventually end up with an oddly shaped api

Api::V2::JobInvocationsController#show endpoint serialized every
host (via hosts/base) and every template invocation on each request,
including the 1-second polling requests from the detail page. None of
this data is used by the frontend — hosts are fetched separately by the
host table, and per-host template invocations are fetched on row expand.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
adamruzicka and others added 2 commits June 25, 2026 15:20
- Remove dead @hosts assignment from create action
- Extract @pattern_template_invocations into a before_action
- Add test assertion for pattern_template_invocations presence

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The before_action was only used by the show action, so inline
the assignment rather than extracting a separate method.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adamlazik1

Copy link
Copy Markdown
Contributor

Avoiding changing public API could save us from potential issues in the future. I would like to go with your suggested way to add a parameter. e.g. serialize_all_hosts (default: true).

adamruzicka and others added 2 commits June 30, 2026 10:22
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@adamruzicka

Copy link
Copy Markdown
Contributor Author

Avoiding changing public API could save us from potential issues in the future

I know, I know, it's just that it is something that should never have been added. Keeping compatibility is nice, having to opt-out from footguns not so much. Anyway, done, but if we go this way this will also need a corresponding change to h-rex to opt out from getting data it doesn't need.

- Extract duplicated include_hosts? condition into a private method
- Restore dropped 'should see only permitted hosts' authorization test
- Add test for host_status=true with include_hosts=false (silent discard)
- Add test for host_status=true with include_hosts=true (job_status present)
- Merge redundant 'should include hosts by default' into 'should get invocation detail'

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@adamlazik1 adamlazik1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, works as expected. Minor wording suggestion.

Comment thread app/controllers/api/v2/job_invocations_controller.rb Outdated
Comment thread app/controllers/api/v2/job_invocations_controller.rb Outdated
Co-authored-by: Adam Lazik <alazik@redhat.com>
@adamlazik1 adamlazik1 merged commit b30ba28 into theforeman:master Jul 2, 2026
16 of 17 checks passed
@adamlazik1

Copy link
Copy Markdown
Contributor

Thanks @adamruzicka !

@adamruzicka adamruzicka deleted the api-cleanup branch July 2, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants