Skip to content

[management] Implement Job API with Validation, Persistence, and Bundle Job Support#4384

Closed
aliamerj wants to merge 1 commit intofeature/remote-debugfrom
debug-api
Closed

[management] Implement Job API with Validation, Persistence, and Bundle Job Support#4384
aliamerj wants to merge 1 commit intofeature/remote-debugfrom
debug-api

Conversation

@aliamerj
Copy link
Copy Markdown
Contributor

@aliamerj aliamerj commented Aug 20, 2025

Describe your changes

Implemented the API for job operations, including creating new jobs, fetching jobs by peer, and fetching individual job details. Added support for bundle/debug jobs with fully validated parameters (e.g., bundle_for_time, log_file_count, anonymize) and ensured that pending jobs are handled correctly.

Temporary permissions are based on the existing “delete peers” permission to allow job operations, with a TODO to implement a dedicated permission for creating and fetching jobs. Also added TODOs to integrate with the job channel once it is ready

All job data is persisted in the database, including account ID, peer ID, job type, status, parameters, and results. Jobs are validated before creation to prevent invalid payloads.

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

@aliamerj aliamerj changed the title Implement Job API with Validation, Persistence, and Bundle Job Support [management] Implement Job API with Validation, Persistence, and Bundle Job Support Aug 20, 2025
Comment thread management/server/activity/codes.go
Comment thread management/server/http/handlers/peers/peers_handler.go
Comment thread shared/management/http/api/types.gen.go Outdated
Comment thread management/server/http/handlers/peers/peers_handler.go Outdated
Comment thread management/server/peer.go Outdated
Comment thread management/server/store/sql_store.go Outdated
Comment thread management/server/store/store.go Outdated
Comment thread management/server/types/job.go Outdated
Comment thread management/server/types/job.go Outdated
Comment thread management/server/store/sql_store.go Outdated
Comment thread management/server/activity/codes.go Outdated
Comment thread shared/management/http/api/openapi.yml Outdated
Comment thread shared/management/http/api/openapi.yml
@aliamerj
Copy link
Copy Markdown
Contributor Author

aliamerj commented Aug 28, 2025

When using oneOf in openapi.yml, the oapi-codegen/pkg/runtime package must be installed to be work

"github.com/deepmap/oapi-codegen/pkg/runtime"

@aliamerj
Copy link
Copy Markdown
Contributor Author

I’ve updated the way we handle workloads. Instead of using JSON blobs or interface{}/any, I switched to full embedding with typed fields. This keeps everything strongly typed, avoids runtime casting, and is much cleaner to work with.
And it's stored in the database like this.

id created_at completed_at triggered_by peer_id account_id status failed_reason workload_workload_type workload_anonymize workload_bundle_for workload_bundle_for_time workload_log_file_count workload_upload_key
b52427ac.. 2025-08-29 07:14:39.515923738+00:00   google-oauth2.. d2fqqjj57uqqe46uchhg d19eo0b57uqqji4hco20 pending   bundle 0 1 2 50  

Comment thread management/server/types/job.go Outdated
@aliamerj aliamerj closed this Aug 29, 2025
@aliamerj aliamerj reopened this Aug 29, 2025
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants