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

Prevent unneeded exec operations #239

Merged
merged 9 commits into from
Jan 29, 2018
Merged

Prevent unneeded exec operations #239

merged 9 commits into from
Jan 29, 2018

Conversation

iocanel
Copy link
Contributor

@iocanel iocanel commented Oct 20, 2017

So the idea is to try avoiding exec operations invoked via ProcessLiveness, by reusing the ContainerExecProc object or by creating a fake one.

For instance:
ps -o -pid <pid> can receive a process that uses the actual ContainerExecProc to determine if its still running.
ps -o -pid 9999 can receive a fake that always returns an error response code.

This way we avoid uneeded exec to the pod.

@iocanel iocanel changed the title [WIP] Process alive Prevent unneeded exec operations Oct 23, 2017
@scoheb
Copy link
Contributor

scoheb commented Oct 26, 2017

working well in production now for 3 days...

Copy link
Contributor

@carlossg carlossg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments plus findbugs errors.

Will the cache work when killing the pipeline ? doesn't just ignore the kill process then?

public ContainerExecDecorator(KubernetesClient client, String podName, String containerName, String namespace, EnvironmentExpander environmentExpander) {
private final FilePath ws;

public ContainerExecDecorator(KubernetesClient client, String podName, String containerName, String namespace, EnvironmentExpander environmentExpander, FilePath ws) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep binary backwards compatibility ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been fixed

*/
public ContainerExecProc(ExecWatch watch, AtomicBoolean alive, CountDownLatch finished,
Callable<Integer> exitCode) {
public ContainerExecProc(int pid, ExecWatch watch, AtomicBoolean alive, CountDownLatch finished,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backwards compatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can! Do we need to though? Do we expect any external code calling these?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep it unless annotated with Restricted just in case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old method needs to be added and deprecated

@scoheb
Copy link
Contributor

scoheb commented Nov 1, 2017

Any progress on this @iocanel ?

@scoheb
Copy link
Contributor

scoheb commented Nov 21, 2017

@carlossg Can you take a look at this please?

@iocanel
Copy link
Contributor Author

iocanel commented Jan 8, 2018

Concerns have been addressed, fixed the conflicts and rebased again!

@iocanel
Copy link
Contributor Author

iocanel commented Jan 8, 2018

@carlossg: Can you take an other look please?

@scoheb
Copy link
Contributor

scoheb commented Jan 8, 2018

@carlossg
Copy link
Contributor

carlossg commented Jan 9, 2018

Still one backwards compatibility change needed and findbugs fixes

Restrict external uses of ContainerExecProc

public ContainerExecProc(int pid, ExecWatch watch, AtomicBoolean alive, CountDownLatch finished,
Callable<Integer> exitCode) {
this.pid = pid;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iocanel I don't see where the pid is used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! It seems that this wasn't used after all!

pid is not needed after all
@carlossg carlossg changed the base branch from master to stable-1.1 January 24, 2018 09:05

private synchronized int readPidFromPidFile(String... commands) throws IOException, InterruptedException {
int pid = -1;
FilePath pidFile = ws.child(readPidFile(commands));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iocanel readPidFile can return null and cause NPE

11:43:41 java.lang.NullPointerException
11:43:41 	at hudson.FilePath.isAbsolute(FilePath.java:281)
11:43:41 	at hudson.FilePath.resolvePathIfRelative(FilePath.java:266)
11:43:41 	at hudson.FilePath.<init>(FilePath.java:262)
11:43:41 	at hudson.FilePath.child(FilePath.java:1273)
11:43:41 	at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator.readPidFromPidFile(ContainerExecDecorator.java:467)
11:43:41 	at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator.access$1000(ContainerExecDecorator.java:69)
11:43:41 	at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.doLaunch(ContainerExecDecorator.java:335)
11:43:41 	at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.launch(ContainerExecDecorator.java:147)

@carlossg carlossg merged commit 9453d84 into jenkinsci:stable-1.1 Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants