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

RSE-812: Fix: not importing logs from s3logstore #51

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
14 changes: 11 additions & 3 deletions src/main/java/org/rundeck/plugins/S3LogFileStoragePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class S3LogFileStoragePlugin implements ExecutionFileStoragePlugin, AWSCr
public static final String DEFAULT_PATH_FORMAT = "project/${job.project}/${job.execid}";
public static final String DEFAULT_REGION = "us-east-1";
public static final String META_EXECID = "execid";

public static final String META_ID_FOR_LOGSTORE = "execIdForLogStore";

public static final String _PREFIX_META = "rundeck.";

public static final String META_USERNAME = "username";
Expand Down Expand Up @@ -188,7 +191,7 @@ public void initialize(Map<String, ?> context) {
if (!configpath.contains("${job.execid}") && configpath.endsWith("/")) {
configpath = path + "/${job.execid}";
}
expandedPath = expandPath(configpath, context);
expandedPath = (context.get("isRemoteFilePath") != null && context.get("isRemoteFilePath").equals("true")) ? String.valueOf(context.get("outputfilepath").toString()) : expandPath(configpath, context);
if (null == expandedPath || "".equals(expandedPath.trim())) {
throw new IllegalArgumentException("expanded value of path was empty");
}
Expand Down Expand Up @@ -268,10 +271,15 @@ private static Map<String, String> stringMap(final Map<String, ?> context) {

public boolean isAvailable(final String filetype) throws ExecutionFileStorageException {
HashMap<String, Object> expected = new HashMap<>();
expected.put(metaKey(META_EXECID), context.get(META_EXECID));
expected.put(metaKey(META_EXECID), context.get(META_ID_FOR_LOGSTORE));
return isPathAvailable(resolvedFilepath(expandedPath, filetype), expected);
}

@Override
public String getConfiguredPathTemplate() {
return this.path;
}

protected boolean isPathAvailable(final String key, Map<String, Object> expectedMeta)
throws ExecutionFileStorageException
{
Expand Down Expand Up @@ -394,7 +402,7 @@ public boolean deleteFile(String filetype) throws IOException, ExecutionFileStor
try{

HashMap<String, Object> expected = new HashMap<>();
expected.put(metaKey(META_EXECID), context.get(META_EXECID));
expected.put(metaKey(META_EXECID), context.get(META_ID_FOR_LOGSTORE));
String filePath = resolvedFilepath(expandedPath, filetype);

amazonS3.deleteObject(getBucket(), filePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void expandJobId() {
private HashMap<String, Object> testContext() {
HashMap<String, Object> stringHashMap = new HashMap<String, Object>();
stringHashMap.put("execid", "testexecid");
stringHashMap.put(S3LogFileStoragePlugin.META_ID_FOR_LOGSTORE, "testexecid");
stringHashMap.put("project", "testproject");
stringHashMap.put("url", "http://rundeck:4440/execution/5/show");
stringHashMap.put("serverUrl", "http://rundeck:4440");
Expand Down
Loading