[JIRA] (JENKINS-54012) File handle leak in Groovy Script

6 views
Skip to first unread message

pzaikin@cloudlinux.com (JIRA)

unread,
Oct 11, 2018, 5:13:01 AM10/11/18
to jenkinsc...@googlegroups.com
Pavel Zaikin created an issue
 
Jenkins / Bug JENKINS-54012
File handle leak in Groovy Script
Issue Type: Bug Bug
Assignee: vjuranek
Components: groovy-plugin
Created: 2018-10-11 09:12
Environment: Jenkins ver. 2.145
Priority: Minor Minor
Reporter: Pavel Zaikin

We use Groovy script in inject variables phase:

// code placeholder
import hudson.model.*;
def thr = Thread.currentThread();
def build = thr?.executable;

String os = build.properties.environment.OS_TYPE.toString();
String os_ver = build.properties.environment.OS_VERSION.toString();
String panel =  build.properties.environment.PANEL_NAME.toString();
String panel_ver =  build.properties.environment.PANEL_VERSION.toString();
String bnum =  build.properties.environment.BUILD_NUMBER.toString();
String gerrit =  build.properties.environment.GERRIT_REF.toString();

String build_link =  build.properties.environment.BUILD_SYSTEM_REPO_IDS.toString();
String author =  build.properties.environment.CREATED_BY.toString();
String gerrit_link = ""

build.displayName = "#" + bnum + " " + os+"_"+os_ver +" " + panel+"_"+panel_ver;if (gerrit.substring(0,5)=="refs/")  {
  gerrit_link = "https://somelink/#/c/"+gerrit.split('/').drop(3).join('/');
}
else {
  gerrit_link = "https://somelink/#/q/status:closed+project:project+branch:"+gerrit;
}
def tags ="";
def gerrit_tests = "";def title = ""+gerrit+"\ntagged: "+tags+"\nBuild: "+build_link+"\nTests:⌥"+gerrit_tests+"\nCreated by: "+author+"\n"build.causes.each { cause ->
title = title + cause.getShortDescription();
}build.description = "⌥<a title=\""+title+"\" href="+gerrit_link+">"+gerrit+"</a><br />Build: <a href=https://somelink/#/build/"+build_link+">"+build_link+"</a><br />Created by: "+author;
def map = [:];
return map;

And each build.properties.environment.VAR call left 2 file handlers opened to /var/lib/jenkins/jobs/job name/builds/NN/log

As we use this script 5 times in one test run and have 8 numbers of environment call, we have 80 opened file handlers after each start. Five test run and here 300 opened files.

When I remove build.properties.environment.VAR - opened files disapeared.

I found way to rewrite script and don't use build.properties.environment - but think that's a bug.

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

pzaikin@cloudlinux.com (JIRA)

unread,
Oct 11, 2018, 5:16:02 AM10/11/18
to jenkinsc...@googlegroups.com
Pavel Zaikin updated an issue
Change By: Pavel Zaikin
We use Groovy script in inject variables phase:
{code:java}

// code placeholder
import hudson.model.*;
def thr = Thread.currentThread();
def build = thr?.executable;

String os = build.properties.environment.OS_TYPE.toString();
String os_ver = build.properties.environment.OS_VERSION.toString();
String panel =  build.properties.environment.PANEL_NAME.toString();
String panel_ver =  build.properties.environment.PANEL_VERSION.toString();
String bnum =  build.properties.environment.BUILD_NUMBER.toString();
String gerrit =  build.properties.environment.GERRIT_REF.toString();

String build_link =  build.properties.environment.BUILD_SYSTEM_REPO_IDS.toString();
String author =  build.properties.environment.CREATED_BY.toString();
String gerrit_link = ""

build.displayName = "#" + bnum + " " + os+"_"+os_ver +" " + panel+"_"+panel_ver;if (gerrit.substring(0,5)=="refs/")  {
  gerrit_link = "https://somelink/#/c/"+gerrit.split('/').drop(3).join('/');
}
else {
  gerrit_link = "https://somelink/#/q/status:closed+project:project+branch:"+gerrit;
}
def tags ="";
def gerrit_tests = "";def title = "⌥"+gerrit+"\ntagged: "+tags+"\nBuild: "+build_link+"\nTests:⌥"+gerrit_tests+"\nCreated by: "+author+"\n"build.causes.each { cause ->
title = title + cause.getShortDescription();
}build.description = "⌥<a title=\""+title+"\" href="+gerrit_link+">"+gerrit+"</a><br />Build: <a href=https://somelink/#/build/"+build_link+">"+build_link+"</a><br />Created by: "+author;
def map = [:];
return map;
{code}
And each {color:#de350b}build.properties.environment.VAR{color} call left 2 file handlers opened to /var/lib/jenkins/jobs/job name/builds/NN/log


As we use this script 5 times in one test run and have 8 numbers of environment call, we have 80 opened file handlers after each start. Five test run and here 300 opened files.

When I remove {color:#de350b}build.properties.environment.VAR{color} - opened files disapeared disappeared .


I found way to rewrite script and don't use build.properties.environment - but think that's a bug.

pzaikin@cloudlinux.com (JIRA)

unread,
Oct 11, 2018, 5:18:02 AM10/11/18
to jenkinsc...@googlegroups.com
When I remove {color:#de350b} removed build.properties.environment.VAR {color} - opened files disappeared.

I found
a way to rewrite the script and don't use build.properties.environment - but think that's a bug.

marco.pensallorto@brightcomputing.com (JIRA)

unread,
Oct 13, 2019, 4:56:05 AM10/13/19
to jenkinsc...@googlegroups.com
Marco Pensallorto commented on Bug JENKINS-54012
 
Re: File handle leak in Groovy Script

We encountered the very same problem. In our case, the file leak was in a shared bit of code ran by several jobs and overtime the number of open files grew in the hundrends of thousands . After rewriting that bit of code bypassing .enviroment the problem is gone. This is definitely a bug. Version 2.150.3 LTS here.

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

marco.pensallorto@brightcomputing.com (JIRA)

unread,
Oct 13, 2019, 4:56:05 AM10/13/19
to jenkinsc...@googlegroups.com
Marco Pensallorto updated an issue
 
Change By: Marco Pensallorto
Environment: Jenkins ver. 2.145
Jenkins ver. 2.150.3 LTS

marco.pensallorto@brightcomputing.com (JIRA)

unread,
Oct 13, 2019, 4:56:05 AM10/13/19
to jenkinsc...@googlegroups.com
Marco Pensallorto updated an issue
Change By: Marco Pensallorto
Priority: Minor Major

marco.pensallorto@brightcomputing.com (JIRA)

unread,
Oct 13, 2019, 4:57:01 AM10/13/19
to jenkinsc...@googlegroups.com
Marco Pensallorto edited a comment on Bug JENKINS-54012
We encountered the very same problem. In our case, the file leak was in a shared bit of code ran by several jobs and overtime the number of open files grew in the hundrends hundreds of thousands (!). After rewriting that bit of code bypassing .enviroment the problem is gone. This is definitely a bug. Version 2.150.3 LTS here.
Reply all
Reply to author
Forward
0 new messages