[JIRA] (JENKINS-56442) Use agent slave pod label value instead of key

10 views
Skip to first unread message

erikah@netcompany.com (JIRA)

unread,
Mar 6, 2019, 8:36:02 AM3/6/19
to jenkinsc...@googlegroups.com
Erik Aaron Hansen created an issue
 
Jenkins / Bug JENKINS-56442
Use agent slave pod label value instead of key
Issue Type: Bug Bug
Assignee: Carlos Sanchez
Components: kubernetes-plugin
Created: 2019-03-06 13:35
Priority: Minor Minor
Reporter: Erik Aaron Hansen

We have an issue with the labels assigned to jenkins slave pods within the jenkins kubernetes plugin. A label in a Kubernetes pod are key/value pairs. Valid label keys have two segments: an optional prefix and name, separated by a slash . The issue we are seeing is that the keys are unique for each pod that is spinned up. Following the guidelines here: https://github.com/jenkinsci/kubernetes-plugin means that we end up with a pod label like: `jenkins/worker-a3346222-237b-4882-a8f9-2d1f125e2a44=true`. so instead of putting the unique id for the worker as the value, it is part of the key. This becomes a problem because we get one index per build in elasticsearch. Has anybody thought about this or know a workaround? It seems unnecessary that we have to write a logstash filter to ignore fields starting with `jenkins/`

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

todd.lyons@pgi.com (JIRA)

unread,
Mar 8, 2019, 9:59:02 AM3/8/19
to jenkinsc...@googlegroups.com
Todd Lyons commented on Bug JENKINS-56442
 
Re: Use agent slave pod label value instead of key

I too had to work through this in Dec 2018 and worked with Eric in the slack channel discussing it.  I couldn't get it to work with logstash and filebeats, in any combination.  Instead in the Kube stack that runs our Jenkins builders, I had to install and configure fluentd and use inline ruby scripting to morph the fields.  I had to capture everything after the `jenkins/(.+)`, create a new key "jenkins_build=$1".  What I had to do to accomplish it is documented here:
https://gist.github.com/mrballcb/c1a8ff4132224e654e85aad80f3a0fec

todd.lyons@pgi.com (JIRA)

unread,
Mar 8, 2019, 10:19:02 AM3/8/19
to jenkinsc...@googlegroups.com

I had considered this as another possible option:
```

$ git diff src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java
diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java
index 4cdecb0..74881fe 100644
--- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java
+++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java
@@ -360,6 +360,7 @@ public class PodTemplate extends AbstractDescribableImpl<PodTemplate> implements
 if (!labelSet.isEmpty()) {
  for (LabelAtom label : labelSet) {
    // builder.put(label == null ? DEFAULT_ID : "jenkins/" + label.getName(), "true");
+   builder.put(label == null ? DEFAULT_ID : "jenkins_build", label.getName());
  }
 }
 return builder.build();

```
But I felt it was kind of stupid to even consider maintaining my own mods to a jenkins plugin, and instead make the log shipper do the transformation work.

I struggle with the `if (!labelSet.isEmpty())` logic, and the getLabelsMap() in general.  I think if we can specify our own label, probably in the config where we define the Kube “cloud”, it would possibly get around all of this. I never explored if there is in fact a way to do that from the config UI (or even if I was properly reading that function).

jglick@cloudbees.com (JIRA)

unread,
Jul 16, 2019, 3:43:40 PM7/16/19
to jenkinsc...@googlegroups.com
Jesse Glick assigned an issue to Unassigned
 
Change By: Jesse Glick
Assignee: Carlos Sanchez

vincent@latombe.net (JIRA)

unread,
Dec 19, 2019, 4:24:04 AM12/19/19
to jenkinsc...@googlegroups.com
Vincent Latombe closed an issue as Fixed
Change By: Vincent Latombe
Status: Open Closed
Resolution: Fixed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages