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

Fixes #28 - added the user/creator information to environment of process running tool #31

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added
- User information to environment of process running the tool [#28](https://github.com/ncsa/datawolf/issues/28)


### Changed
- Kubernetes executor prints exception [#23](https://github.com/ncsa/datawolf/issues/23)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
public abstract class Executor {
private static Logger logger = LoggerFactory.getLogger(Executor.class);

protected static String DATAWOLF_USER = "DATAWOLF_USER";
navarroc marked this conversation as resolved.
Show resolved Hide resolved

private StringBuilder log = new StringBuilder();
private LogFile logfile = new LogFile();
private int lastsave = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ public void execute(File cwd) throws AbortException, FailedException {
env.putAll(impl.getEnv());
}

// Add user to the environment in case a tool needs this information
if(execution.getCreator() != null) {
String user = execution.getCreator().getEmail();
env.put(DATAWOLF_USER, user);
}

// find the app to execute
command.add(findApp(impl.getExecutable().trim(), cwd));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,25 @@ public State submitRemoteJob(File cwd) throws AbortException, FailedException {
container.args(command);
// add any environment variables
if (!impl.getEnv().isEmpty()) {
// TODO implement
//container.addEnvItem();
Map<String, String> environment = impl.getEnv();

for (Map.Entry<String, String> entry : environment.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
V1EnvVar envVar = new V1EnvVar();
envVar.setName(key);
envVar.setValue(value);
container.addEnvItem(envVar);
}
}

// Add user to the environment in case a tool needs this information
if(execution.getCreator() != null) {
String user = execution.getCreator().getEmail();
V1EnvVar envVar = new V1EnvVar();
envVar.setName(DATAWOLF_USER);
envVar.setValue(user);
container.addEnvItem(envVar);
}

// add resource limits
Expand Down
Loading