Ensure controller agent tags match job tags 100%#596
Merged
Conversation
The shared informer watches Jobs matching Labels created from tags in the controller's config. When a scheduled job is retrieved it was previously checking if all job tags were present as agent tags (and not the other way around). This was allowing scheduled jobs with only a matching `queue` tag to be created as a k8s Job. This then prevented the informer from matching the Labels of these Jobs and the controller was unable to know when they finished.
mcncl
approved these changes
May 13, 2025
DrJosh9000
reviewed
May 14, 2025
| for k, v := range jobTags { | ||
| agentTagValue, exists := agentTags[k] | ||
|
|
||
| func AgentTagsMatchJobTags(agentTags, jobTags map[string]string) bool { |
Contributor
There was a problem hiding this comment.
Given that this is in the agenttags package, AgentTags could be dropped from the start of the name so that calling it reads like agenttags.MatchJobTags(...):
Suggested change
| func AgentTagsMatchJobTags(agentTags, jobTags map[string]string) bool { | |
| func MatchJobTags(agentTags, jobTags map[string]string) bool { |
This file contains hidden or 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
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.
The shared informer watches Jobs matching Labels created from tags in the controller's config. When a scheduled job was retrieved from the API the controller was previously checking if all job tags (
agentQueryRules) were present as agent tags (and not the other way around). This was allowing scheduled jobs with only a matchingqueuetag to be created as a K8s Job. This then prevented the informer from matching the Labels of these Jobs and the controller was left with an infinitely increasing number of running jobs. The only remediation was to setmax-in-flight: 0or periodically restart the controller.Now the controller will only create K8s Jobs when tags match 100%. If tags do not match, the following
INFOlog is emitted: