From e566c573564417d6fd8076fc11de90b7130fe40b Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Tue, 29 Aug 2023 15:33:17 -0400 Subject: [PATCH] handle both restart and replace params --- .../java/io/cryostat/recordings/Recordings.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/cryostat/recordings/Recordings.java b/src/main/java/io/cryostat/recordings/Recordings.java index 8708d9c2a..5ae3a468a 100644 --- a/src/main/java/io/cryostat/recordings/Recordings.java +++ b/src/main/java/io/cryostat/recordings/Recordings.java @@ -511,6 +511,9 @@ public LinkedRecordingDescriptor createRecording( @RestForm String recordingName, @RestForm String events, @RestForm Optional replace, + // restart param is deprecated, only 'replace' should be used and takes priority if both + // are provided + @RestForm Optional restart, @RestForm Optional duration, @RestForm Optional toDisk, @RestForm Optional maxAge, @@ -554,6 +557,15 @@ public LinkedRecordingDescriptor createRecording( labels.putAll( mapper.readValue(rawMetadata.get(), Metadata.class).labels); } + RecordingReplace replacement = RecordingReplace.ALWAYS; + if (replace.isPresent()) { + replacement = RecordingReplace.fromString(replace.get()); + } else if (restart.isPresent()) { + replacement = + restart.get() + ? RecordingReplace.ALWAYS + : RecordingReplace.NEVER; + } IConstrainedMap recordingOptions = optionsBuilder.build(); return recordingHelper.startRecording( target, @@ -562,7 +574,7 @@ public LinkedRecordingDescriptor createRecording( template.getRight(), new Metadata(labels), archiveOnStop.orElse(false), - RecordingReplace.fromString(replace.orElse("always")), + replacement, connection); });