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

Be able to set the seed-job-agent to "Only build jobs with label expression matching this node" #1014

Open
renovate-eika opened this issue May 16, 2024 · 4 comments · May be fixed by #1079
Open
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers needs triage not-stale

Comments

@renovate-eika
Copy link

renovate-eika commented May 16, 2024

Describe the solution you'd like

  • Be able to set the seed-job-agent to "Only build jobs with label expression matching this node"
  • Be able to scale the number of executors on the seed-job-agent

The reason behind this is that we have many multibranch pipelines which are pointing to Jenkinsfiles without any requirements of using node labels. We only use labels if they need to use a special node that is not on the "golden path". On the Jenkins server we decide which agents should be used as much as possible.

Describe alternatives you've considered

Since the seed-job is by default labeled/restricted to use "seed-job-agent", I think the agent could be set to only build the jobs with matching labels, or at least an option to set these settings.

I have tested to do this with the following groovy script added to "groovyScripts" without any success:

apiVersion: v1
kind: ConfigMap
metadata:
  name: seed-job-agent
data:
  seed-job-agent.groovy: |2
    import jenkins.model.Jenkins
    import hudson.model.Node.Mode

    def agentName = 'seed-job-agent'
    def newExecutors = 1  
      
    def agent = Jenkins.instance.getNode(agentName)
    if (agent != null) {
      agent.setNumExecutors(newExecutors)
      agent.setMode(Mode.EXCLUSIVE)
      agent.save()
      println("The number of executors for agent '${agentName}' has been set to ${newExecutors} and configuration saved.")
      Jenkins.instance.reload()
    } 

Additional context

There may be use-cases I haven't thought through

@renovate-eika renovate-eika added the enhancement New feature or request label May 16, 2024
@brokenpip3
Copy link
Collaborator

Like I said in the operator chat this is something that we should add, the change is not complex and needs to be done here.

Any PR is welcome!

@lavigneer
Copy link

@brokenpip3 can I take this one on?

@brokenpip3
Copy link
Collaborator

@brokenpip3 can I take this one on?

sure, let me assign it to you

@lavigneer
Copy link

I dug into this one a bit and it seems like the goclient package hasn't been updated in a bit. There's an open PR for it at bndr/gojenkins#315 that would allow us to specify the mode as Exclusive instead of Normal to accomplish this task.

Given that the PR hasn't been merged in a year, I can take a look at if there would be a workaround for this, like running a script on the jenkins node after agent creation to set the mode instead.

lavigneer added a commit to lavigneer/jenkins-kubernetes-operator that referenced this issue Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers needs triage not-stale
Projects
None yet
3 participants