-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #400 from OHDSI/bigquery
Reinstate support for BigQuery
- Loading branch information
Showing
11 changed files
with
199 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM eclipse-temurin:8-jdk | ||
FROM eclipse-temurin:8-jre | ||
LABEL maintainer="Odysseus Data Services, Inc: [email protected]" | ||
VOLUME /tmp | ||
VOLUME /libs-r | ||
|
@@ -10,9 +10,6 @@ RUN ln -fs /usr/share/zoneinfo/Etc/GMT /etc/localtime && dpkg-reconfigure -f non | |
RUN update-rc.d cron defaults && systemctl enable rsyslog | ||
ENV R_INSTALL_SCRIPT=libs.r | ||
ADD execution-engine-exec.jar /execution-engine.jar | ||
RUN mkdir /impala | ||
ADD Cloudera_ImpalaJDBC4_2.5.41.zip /impala/impala-jdbc.zip | ||
RUN cd /impala && unzip impala-jdbc.zip && rm -f impala-jdbc.zip | ||
RUN mkdir /runtimes | ||
COPY descriptor_base.json /runtimes/descriptor_base.json | ||
RUN ls -la /runtimes/* | ||
|
17 changes: 17 additions & 0 deletions
17
engine/src/main/java/com/odysseusinc/arachne/executionengine/auth/AuthEffects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.odysseusinc.arachne.executionengine.auth; | ||
|
||
import java.util.Map; | ||
|
||
public interface AuthEffects { | ||
interface AddEnvironmentVariables extends AuthEffects { | ||
Map<String, String> getEnvVars(); | ||
} | ||
|
||
interface ModifyUrl extends AuthEffects { | ||
String getNewUrl(); | ||
} | ||
|
||
interface Cleanup extends AuthEffects { | ||
void cleanup(); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...c/main/java/com/odysseusinc/arachne/executionengine/auth/BigQueryCredentialsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.odysseusinc.arachne.executionengine.auth; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.odysseusinc.arachne.commons.types.DBMSType; | ||
import com.odysseusinc.arachne.execution_engine_common.api.v1.dto.DataSourceUnsecuredDTO; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.io.FileUtils; | ||
import org.apache.commons.io.IOUtils; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Map; | ||
|
||
@Service | ||
@Slf4j | ||
public class BigQueryCredentialsProvider implements CredentialsProvider { | ||
private static final String RUNTIME_BQ_KEYFILE = "BQ_KEYFILE"; | ||
|
||
@Override | ||
public AuthEffects apply(DataSourceUnsecuredDTO dataSource, Path analysisDir, String analysisDirInContainer) { | ||
if (dataSource.getType() == DBMSType.BIGQUERY) { | ||
try { | ||
Path keyFile = Files.createTempFile(analysisDir, "", ".json").toAbsolutePath(); | ||
try (OutputStream out = Files.newOutputStream(keyFile)) { | ||
IOUtils.write(dataSource.getKeyfile(), out); | ||
} | ||
Path innerPath = Paths.get(analysisDirInContainer).resolve(keyFile.getFileName()); | ||
return new Effects(dataSource.getConnectionString(), keyFile, innerPath.toString()); | ||
} catch (IOException e) { | ||
log.error("Failed to resolve BigQuery authentication for Source: [{}]", dataSource.getName(), e); | ||
throw new RuntimeException(e); | ||
} | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@AllArgsConstructor | ||
private static class Effects implements AuthEffects, AuthEffects.AddEnvironmentVariables, AuthEffects.ModifyUrl, AuthEffects.Cleanup { | ||
private final String newUrl; | ||
private final Path keyFile; | ||
private final String keyFileInContainer; | ||
|
||
@Override | ||
public Map<String, String> getEnvVars() { | ||
return ImmutableMap.of(RUNTIME_BQ_KEYFILE, keyFileInContainer); | ||
} | ||
|
||
@Override | ||
public String getNewUrl() { | ||
return newUrl + ";OAuthPvtKeyPath=" + keyFileInContainer + ";"; | ||
} | ||
|
||
@Override | ||
public void cleanup() { | ||
FileUtils.deleteQuietly(keyFile.toFile()); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
engine/src/main/java/com/odysseusinc/arachne/executionengine/auth/CredentialsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.odysseusinc.arachne.executionengine.auth; | ||
|
||
import com.odysseusinc.arachne.execution_engine_common.api.v1.dto.DataSourceUnsecuredDTO; | ||
|
||
import java.nio.file.Path; | ||
|
||
public interface CredentialsProvider { | ||
AuthEffects apply(DataSourceUnsecuredDTO dataSource, Path analysisDir, String analysisDirInContainer); | ||
} |
60 changes: 60 additions & 0 deletions
60
...c/main/java/com/odysseusinc/arachne/executionengine/auth/KerberosCredentialsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.odysseusinc.arachne.executionengine.auth; | ||
|
||
import com.odysseusinc.arachne.execution_engine_common.api.v1.dto.DataSourceUnsecuredDTO; | ||
import com.odysseusinc.datasourcemanager.krblogin.KerberosService; | ||
import com.odysseusinc.datasourcemanager.krblogin.KrbConfig; | ||
import com.odysseusinc.datasourcemanager.krblogin.RuntimeServiceMode; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.io.FileUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Map; | ||
|
||
@Service | ||
@Slf4j | ||
public class KerberosCredentialsProvider implements CredentialsProvider { | ||
@Autowired | ||
private KerberosService kerberosService; | ||
|
||
@Override | ||
public AuthEffects apply(DataSourceUnsecuredDTO ds, Path analysisDir, String analysisDirInContainer) { | ||
Path keys = analysisDir.resolve("keys"); | ||
File keystoreDir = keys.toFile(); | ||
|
||
if (ds.getUseKerberos()) { | ||
keystoreDir.mkdirs(); | ||
try { | ||
KrbConfig config = kerberosService.runKinit(ds, RuntimeServiceMode.SINGLE, keystoreDir); | ||
return new Effects(config, keys); | ||
} catch (IOException e) { | ||
log.error("Failed to resolve Kerberos auth for Datasource: {}", ds.getName(), e); | ||
throw new RuntimeException(e); | ||
} | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@AllArgsConstructor | ||
private static class Effects implements AuthEffects, AuthEffects.AddEnvironmentVariables, AuthEffects.Cleanup { | ||
private final KrbConfig config; | ||
private final Path keyFile; | ||
|
||
@Override | ||
public Map<String, String> getEnvVars() { | ||
return config.getIsolatedRuntimeEnvs(); | ||
} | ||
|
||
@Override | ||
public void cleanup() { | ||
FileUtils.deleteQuietly(keyFile.toFile()); | ||
FileUtils.deleteQuietly(config.getComponents().getKeytabPath().toFile()); | ||
FileUtils.deleteQuietly(config.getConfPath().toFile()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
engine/src/main/java/com/odysseusinc/arachne/executionengine/execution/KerberosSupport.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.