Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Shell runner tasks #113

Merged
merged 1 commit into from
Mar 22, 2023
Merged

Shell runner tasks #113

merged 1 commit into from
Mar 22, 2023

Conversation

rgolangh
Copy link
Contributor

@rgolangh rgolangh commented Mar 15, 2023

Introduce basic shell tasks that consumes {"command": "", "args": ""}
executes, and timeouts after a default of 10 minutes.
Pass "timeoutInSeconds": [timeout in seconds] to override

Signed-off-by: Roy Golan rgolan@redhat.com

FLPATH-162

Related-to: #123

@rgolangh rgolangh changed the title WIP: Shell runner tasks [WIP] Shell runner tasks Mar 15, 2023
@rgolangh rgolangh changed the title [WIP] Shell runner tasks WIP: Shell runner tasks Mar 15, 2023
@rgolangh rgolangh force-pushed the add_shell_tasks branch 4 times, most recently from af5b713 to 0a82176 Compare March 16, 2023 19:01
@rgolangh rgolangh changed the title WIP: Shell runner tasks Shell runner tasks Mar 16, 2023
Copy link
Collaborator

@pkliczewski pkliczewski left a comment

Choose a reason for hiding this comment

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

code changes looks good
@ydayagi please review. It seems you wanted to place tasks in different place

Copy link
Collaborator

@eloycoto eloycoto left a comment

Choose a reason for hiding this comment

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

A few minor comments, thanks for the work!

};
this.cmdline.add(command);
if (workContext.get("args") != null) {
this.cmdline.addAll(List.of(workContext.get("args").toString().split(" ")));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this not a security issue? A user can submit a command that scales privilege, no? like sh - sudo rm

Copy link
Contributor Author

@rgolangh rgolangh Mar 19, 2023

Choose a reason for hiding this comment

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

very very good point. The thing is that I really don't know what the deployment model is yet. For example, will the user the jvm runs under is in sudoers at all? could we actually ensure podman is part of the deployment and so run every execution part of a ubi9/micro image? (like podman run ubi9/micro $cmd $args
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lshannon any input here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, and also, I would run at least in a separate shell, like sh 'command', if not can get the ENV variables and maybe connect to the database itself.

TBH, I would move this to "container shell command", and be able to specify the image and the command to execute, for me, it will be 10000 times safer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We still need to work on deployment story and we can make sure that ability to exploit this issue is limited or not possible. Let's discuss this issue while working on FLPATH-198.

throw new RuntimeException(e);
}
finally {
tmpDir.delete();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you return in the try-and-catch, this is never going to be executed, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is exactly what finally is for. It is always executed, unless there's a System.exit statement

underTest.outputConsumer = output::append;

assertThat(underTest.execute(ctx).getStatus()).isEqualTo(WorkStatus.COMPLETED);
assertThat(output.toString()).isEqualTo(randomUUID.toString());
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we assert that the temp folder is deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

following the comment above, we can count on the jvm to execute that. but for extra cation we can parametrize the call to pass in a temp dir ... wonder if its worth it.
Another though I had - writing stuff into /tmp costs memory while /var/tmp is disk space only and I tend to think those executions could involve a lot of stuff written into the scratch space of the task .

@nirarg
Copy link
Contributor

nirarg commented Mar 20, 2023

/hold
(test label)

@nirarg
Copy link
Contributor

nirarg commented Mar 20, 2023

/hold cancel

Introduce basic shell tasks that consumes {"command": "", "args": ""}
executes, and timeouts after a default of 10 minutes.
Pass "timeoutInSeconds": [timeout in seconds] to override

Signed-off-by: Roy Golan <rgolan@redhat.com>
@openshift-ci
Copy link

openshift-ci bot commented Mar 21, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rgolangh
Once this PR has been reviewed and has the lgtm label, please assign pkliczewski for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pkliczewski
Copy link
Collaborator

/lgtm

@pkliczewski
Copy link
Collaborator

@eloycoto do you think it is ready?

@lshannon
Copy link
Contributor

The lgtm label should have been applied. Not sure why its still saying its not. Going to go ahead and merge this

@lshannon lshannon merged commit a6e5681 into parodos-dev:main Mar 22, 2023
@nirarg
Copy link
Contributor

nirarg commented Mar 26, 2023

@rgolangh This code should be located in prebuilt-tsks module, no?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants