Skip to content

Commit

Permalink
Fixes #28 - added the user/creator information to environment of proc…
Browse files Browse the repository at this point in the history
…ess running tool (#31)

* Fixes #28 - added the user/creator information to environment of process running the tool
* Update datawolf-core/src/main/java/edu/illinois/ncsa/datawolf/Executor.java

Co-authored-by: Rob Kooper <[email protected]>
  • Loading branch information
navarroc and robkooper committed Sep 13, 2024
1 parent f944669 commit 2a7afce
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
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";

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

0 comments on commit 2a7afce

Please sign in to comment.