-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-8253. Set ozone.metadata.dirs to temporary dir if not defined in S3 Gateway #4455
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
Changes from 4 commits
e2a7d30
cea29f3
99273ee
669e89b
d9da3b1
eda47dc
7429fcd
df38baf
d992797
71694af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,13 +18,18 @@ | |
| package org.apache.hadoop.ozone.s3; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
|
|
||
| import org.apache.hadoop.hdds.StringUtils; | ||
| import org.apache.commons.io.FileUtils; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.hadoop.hdds.cli.GenericCli; | ||
| import org.apache.hadoop.hdds.cli.HddsVersionProvider; | ||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.hdds.tracing.TracingUtil; | ||
| import org.apache.hadoop.hdds.utils.HddsServerUtil; | ||
| import org.apache.hadoop.ozone.OzoneConfigKeys; | ||
| import org.apache.hadoop.ozone.OzoneSecurityUtil; | ||
| import org.apache.hadoop.ozone.s3.metrics.S3GatewayMetrics; | ||
| import org.apache.hadoop.ozone.util.OzoneNetUtils; | ||
|
|
@@ -38,6 +43,7 @@ | |
| import org.slf4j.LoggerFactory; | ||
| import picocli.CommandLine.Command; | ||
|
|
||
| import static org.apache.hadoop.hdds.StringUtils.startupShutdownMessage; | ||
| import static org.apache.hadoop.ozone.conf.OzoneServiceConfig.DEFAULT_SHUTDOWN_HOOK_PRIORITY; | ||
| import static org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_KERBEROS_KEYTAB_FILE_KEY; | ||
| import static org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_KERBEROS_PRINCIPAL_KEY; | ||
|
|
@@ -70,6 +76,25 @@ public Void call() throws Exception { | |
| OzoneConfigurationHolder.setConfiguration(ozoneConfiguration); | ||
| UserGroupInformation.setConfiguration(ozoneConfiguration); | ||
| loginS3GUser(ozoneConfiguration); | ||
|
|
||
| if (StringUtils.isEmpty(ozoneConfiguration.get( | ||
| OzoneConfigKeys.OZONE_HTTP_BASEDIR))) { | ||
| //Setting ozone.metadata.dirs if not set so that server setup doesn't | ||
| // fail. | ||
|
||
| Path tmpMetaDir = Files.createTempDirectory(Paths.get(""), | ||
| "ozone_s3g_tmp_base_dir"); | ||
| Runtime.getRuntime().addShutdownHook(new Thread(() -> { | ||
|
||
| try { | ||
| FileUtils.deleteDirectory(tmpMetaDir.toFile()); | ||
| } catch (IOException e) { | ||
| LOG.error("Failed to cleanup temporary S3 Gateway Metadir {}", | ||
| tmpMetaDir.toFile().getAbsolutePath(), e); | ||
| } | ||
| })); | ||
| ozoneConfiguration.set(OzoneConfigKeys.OZONE_HTTP_BASEDIR, | ||
| tmpMetaDir.toFile().getAbsolutePath()); | ||
| } | ||
|
|
||
| httpServer = new S3GatewayHttpServer(ozoneConfiguration, "s3gateway"); | ||
| metrics = S3GatewayMetrics.create(); | ||
| start(); | ||
|
|
@@ -87,7 +112,7 @@ public Void call() throws Exception { | |
| public void start() throws IOException { | ||
| String[] originalArgs = getCmd().getParseResult().originalArgs() | ||
| .toArray(new String[0]); | ||
| StringUtils.startupShutdownMessage(OzoneVersionInfo.OZONE_VERSION_INFO, | ||
| startupShutdownMessage(OzoneVersionInfo.OZONE_VERSION_INFO, | ||
| Gateway.class, originalArgs, LOG, ozoneConfiguration); | ||
|
|
||
| LOG.info("Starting Ozone S3 gateway"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.