From 7255b6be39171f3a9dc5b4195ce553a03cdf06bc Mon Sep 17 00:00:00 2001 From: Oguzhan Unlu Date: Fri, 31 May 2019 02:20:10 +0300 Subject: [PATCH] Fix enrichment upload mechanism (closes #194) --- provisioning/resources/control-plane/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/provisioning/resources/control-plane/main.go b/provisioning/resources/control-plane/main.go index 6ca7aaf5..40442025 100644 --- a/provisioning/resources/control-plane/main.go +++ b/provisioning/resources/control-plane/main.go @@ -102,6 +102,12 @@ func uploadEnrichments(resp http.ResponseWriter, req *http.Request) { } defer f.Close() + // Uploaded enrichment can be shorter than the existing one + // Truncating to 0 bytes and seeking I/O offset to the beginning + // Prevents the possibility of corrupted json + f.Truncate(0) + f.Seek(0, 0) + // Now we can write to file in peace io.WriteString(f, fileContent) err = restartService("streamEnrich")