-
Notifications
You must be signed in to change notification settings - Fork 0
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
assigner: implements task assignment for scans and dummy mock test #95
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ashwiniag
changed the title
assigner: implements task assignment for scans
assigner: implements task assignment for scans and dummy mock test
Jan 1, 2025
ashwiniag
changed the base branch from
ag-server-enhancement
to
ag-registration
January 1, 2025 13:26
ashwiniag
added a commit
that referenced
this pull request
Jan 3, 2025
… reports (#90) * adds logic to register the agent and poll * adds field scanner in policies * adds field scanner in scans tables and updates test cases across * adds foreign key integrationID to table scans and updates test cases * adds field scanner in config yaml and supporting logic, adds enum for status fields * adds field scanner in config yaml and supporting logic, adds enum for status fields * updates logic to add an image:tag string in scans.image and integrationID in scans.integrationsID rendering its value using policy.image.registery which is equivalent to integrations.name * fix executing of migration just once at the start of config loads * restructure code for v0 * updates the get list call logic i.e orders by created_at ASC and adds its test case * modularizing registries like dockerhub, gcr * updates scan.Report logic to hold the json result of scanner * modularizes the scanner tools * modularizes the scanner tools * some todo * updates the get call to query by status * updates the CRUD to use pointers as certain fields are optional or conditionally updated * agent implementation workflow * assigner: implements task assignment for scans and dummy mock test (#95) * updates the get call of scan to query by status * updates the GET call of agents to query by status * updates the GET call of agents to query by status or scan_id * adds task assignment logic * adds task assignment logic * fix lints * fix lints
ashwiniag
added a commit
that referenced
this pull request
Jan 6, 2025
* adds config parsing and feeds to database at server start * removes redundency on config reloads * agent: implements logic to register agents and scan images and upload reports (#90) * adds logic to register the agent and poll * adds field scanner in policies * adds field scanner in scans tables and updates test cases across * adds foreign key integrationID to table scans and updates test cases * adds field scanner in config yaml and supporting logic, adds enum for status fields * adds field scanner in config yaml and supporting logic, adds enum for status fields * updates logic to add an image:tag string in scans.image and integrationID in scans.integrationsID rendering its value using policy.image.registery which is equivalent to integrations.name * fix executing of migration just once at the start of config loads * restructure code for v0 * updates the get list call logic i.e orders by created_at ASC and adds its test case * modularizing registries like dockerhub, gcr * updates scan.Report logic to hold the json result of scanner * modularizes the scanner tools * modularizes the scanner tools * some todo * updates the get call to query by status * updates the CRUD to use pointers as certain fields are optional or conditionally updated * agent implementation workflow * assigner: implements task assignment for scans and dummy mock test (#95) * updates the get call of scan to query by status * updates the GET call of agents to query by status * updates the GET call of agents to query by status or scan_id * adds task assignment logic * adds task assignment logic * fix lints * fix lints
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes: #91
Introduces
assigner.go
, which is designed to distribute pending scans among available agents through round robin fashion. This assignment logic run independently as go routine and periodically at 1min intervalassigner_test.go
which just test interaction with HTTP endpoints and verifies that the assigner.go logic correctly interacts with endpoints. As follow:Abstract Assigner Flow Logic
Fetch Pending Scans:
Retrieve all scans with scans.Status=scan_pending that are waiting for assignment.
Fetch Available Agents:
Identify agents with agents.Status=connected that are ready to process tasks.
Assign scans to agents via Round-Robin Assignment:
Each scan is assigned to an agent in sequential order.
Once the last agent is assigned, the logic loops back to the first agent.
Used this thinking it ensures even distribution without overloading any single agent and retries any new batch of scans comes in with periodic execution.
Process Assignment
Before assigning a scan, verify if it is already assigned to an agent in agentTasks to avoid duplication.
Assign Tasks:
Create a task linking the scan and the assigned agent in in agentTasks.
Periodic Execution:
The assigner runs at regular intervals to continuously check for new scans and available agents, ensuring no scan is left unprocessed.
Note:
This deosn't handle the logic of if scans have failed which are in scan.Status=error. Need to think on this