Skip to content

Commit

Permalink
Merge pull request #51 from rundeck-plugins/rse740-not-importing-logs…
Browse files Browse the repository at this point in the history
…-from-S3logstore

RSE-812: Fix: not importing logs from s3logstore
  • Loading branch information
L2JE authored Oct 26, 2023
2 parents f5878ba + 72a0286 commit e5d1cc6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apply plugin: 'pl.allegro.tech.build.axion-release'

sourceCompatibility = 1.8
ext.rundeckPluginVersion= '1.2'
ext.rundeckVersion='2.6.5'
ext.rundeckVersion='4.17.2-rc1-20231025'

/**
* Set this to a comma-separated list of full classnames of your implemented Rundeck
Expand Down Expand Up @@ -108,4 +108,4 @@ jar {
}
}
//set jar task to depend on copyToLib
jar.dependsOn(copyToLib)
jar.dependsOn(copyToLib)
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

0 comments on commit e5d1cc6

Please sign in to comment.