Skip to content

Commit 0c5f6ed

Browse files
authored
Merge pull request #541 from oracle/fix-take10
Synchronization on config map script loading
2 parents ec58713 + e484477 commit 0c5f6ed

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

operator/src/main/java/oracle/kubernetes/operator/builders/WatchBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ private class ListJobCall implements BiFunction<ApiClient, CallParams, Call> {
189189

190190
@Override
191191
public Call apply(ApiClient client, CallParams callParams) {
192+
// Ensure that client doesn't time out before call or watch
193+
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
194+
192195
try {
193196
return new BatchV1Api(client)
194197
.listNamespacedJobCall(

operator/src/main/java/oracle/kubernetes/operator/helpers/ConfigMapHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class ConfigMapHelper {
3939
private static final String SCRIPT_LOCATION = "/scripts";
4040
private static final ConfigMapComparator COMPARATOR = new ConfigMapComparatorImpl();
4141

42-
private static FileGroupReader scriptReader = new FileGroupReader(SCRIPT_LOCATION);
42+
private static final FileGroupReader scriptReader = new FileGroupReader(SCRIPT_LOCATION);
4343

4444
private ConfigMapHelper() {}
4545

operator/src/main/java/oracle/kubernetes/operator/helpers/FileGroupReader.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ class FileGroupReader {
4545
* @return a map of file paths to string contents.
4646
*/
4747
Map<String, String> loadFilesFromClasspath() {
48-
try {
49-
try (ScriptPath scriptPath = getScriptPath()) {
50-
return loadContents(scriptPath.getScriptsDir());
48+
synchronized (FileGroupReader.class) {
49+
try {
50+
try (ScriptPath scriptPath = getScriptPath()) {
51+
return loadContents(scriptPath.getScriptsDir());
52+
}
53+
} catch (Exception e) {
54+
LOGGER.warning(MessageKeys.EXCEPTION, e);
55+
throw new RuntimeException(e);
5156
}
52-
} catch (Exception e) {
53-
LOGGER.warning(MessageKeys.EXCEPTION, e);
54-
throw new RuntimeException(e);
5557
}
5658
}
5759

0 commit comments

Comments
 (0)