Skip to content

Commit ad1dc03

Browse files
authored
Remove endpoint /executionLogs from orchestrator (#1265)
* reused path from backend for sandbox storage
1 parent 708bc1e commit ad1dc03

22 files changed

Lines changed: 13 additions & 333 deletions

File tree

docker-compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ services:
2525
- "5100:5100"
2626
volumes:
2727
- "/var/run/docker.sock:/var/run/docker.sock"
28-
- /home/saveu/executionLogs:/home/cnb/executionLogs/
2928
- /home/saveu/configs/orchestrator:/home/cnb/config
3029
- save-tmp-resources:/tmp
3130
extra_hosts:

save-agent/src/linuxX64Main/kotlin/com/saveourtool/save/agent/AgentConfiguration.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,11 @@ data class HeartbeatConfig(
7171
*
7272
* @property url URL of orchestrator
7373
* @property heartbeatEndpoint endpoint to post heartbeats to
74-
* @property executionLogsEndpoint endpoint to post executionLogs to
7574
*/
7675
@Serializable
7776
data class OrchestratorConfig(
7877
val url: String,
7978
val heartbeatEndpoint: String = "/heartbeat",
80-
val executionLogsEndpoint: String = "/executionLogs",
8179
)
8280

8381
/**

save-agent/src/linuxX64Main/kotlin/com/saveourtool/save/agent/SaveAgent.kt

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import generated.SAVE_CLOUD_VERSION
2424
import io.ktor.client.*
2525
import io.ktor.client.call.body
2626
import io.ktor.client.request.*
27-
import io.ktor.client.request.forms.*
28-
import io.ktor.client.statement.*
2927
import io.ktor.http.*
3028
import io.ktor.utils.io.core.*
3129
import okio.FileSystem
@@ -269,11 +267,11 @@ class SaveAgent(private val config: AgentConfiguration,
269267
logInfoCustom("SAVE has completed execution with status ${executionResult.code}")
270268

271269
val saveCliLogFilePath = config.logFilePath
272-
val byteArray = FileSystem.SYSTEM.source(saveCliLogFilePath.toPath())
270+
val saveCliLogData = FileSystem.SYSTEM.source(saveCliLogFilePath.toPath())
273271
.buffer()
274272
.readByteArray()
275-
val saveCliLogData = String(byteArray).split("\n")
276-
launchLogSendingJob(byteArray)
273+
.let { String(it) }
274+
.split("\n")
277275
logDebugCustom("SAVE has completed execution, execution logs:")
278276
saveCliLogData.forEach {
279277
logDebugCustom("[SAVE] $it")
@@ -358,16 +356,6 @@ class SaveAgent(private val config: AgentConfiguration,
358356
}
359357
}
360358

361-
private fun CoroutineScope.launchLogSendingJob(byteArray: ByteArray): Job = launch {
362-
runCatching {
363-
sendLogs(byteArray)
364-
}
365-
.exceptionOrNull()
366-
?.let {
367-
logErrorCustom("Couldn't send logs, reason: ${it.message}")
368-
}
369-
}
370-
371359
private fun CoroutineScope.handleSuccessfulExit(): Job {
372360
val jsonReport = "${config.save.reportDir}/save.out.json"
373361
val result = runCatching {
@@ -395,24 +383,6 @@ class SaveAgent(private val config: AgentConfiguration,
395383
}
396384
}
397385

398-
/**
399-
* @param byteArray byte array with logs of CLI execution progress that will be sent in a message
400-
*/
401-
private suspend fun sendLogs(byteArray: ByteArray): HttpResponse =
402-
httpClient.post {
403-
url("${config.orchestrator.url}${config.orchestrator.executionLogsEndpoint}")
404-
setBody(MultiPartFormDataContent(formData {
405-
append(
406-
"executionLogs",
407-
byteArray,
408-
Headers.build {
409-
append(HttpHeaders.ContentType, ContentType.MultiPart.FormData)
410-
append(HttpHeaders.ContentDisposition, "filename=${config.id}")
411-
}
412-
)
413-
}))
414-
}
415-
416386
private suspend fun sendReport(testResultDebugInfo: TestResultDebugInfo) = httpClient.post {
417387
url("${config.backend.url}${config.backend.debugInfoEndpoint}?executionId=${executionId.value}")
418388
contentType(ContentType.Application.Json)

save-agent/src/linuxX64Test/kotlin/com/saveourtool/save/agent/SaveAgentTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class SaveAgentTest {
4646
HttpStatusCode.OK,
4747
headersOf(HttpHeaders.ContentType, ContentType.Application.Json.toString())
4848
)
49-
"/executionData" -> respond("", status = HttpStatusCode.OK)
50-
"/executionLogs" -> respond("", status = HttpStatusCode.OK)
5149
else -> error("Unhandled ${request.url}")
5250
}
5351
}

save-cloud-charts/save-cloud/templates/orchestrator-deployment.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ spec:
4747
fieldPath: spec.nodeName
4848
volumeMounts:
4949
- {{ include "spring-boot.config-volume-mount" . | indent 14 | trim }}
50-
- name: execution-logs-storage
51-
mountPath: /home/cnb/executionLogs/
5250
{{- include "spring-boot.management" .Values.orchestrator | nindent 10 }}
5351
resources:
5452
limits:
@@ -57,6 +55,3 @@ spec:
5755
memory: 600M
5856
volumes:
5957
- {{ include "spring-boot.config-volume" (dict "service" .Values.orchestrator) | indent 10 | trim }}
60-
- name: execution-logs-storage
61-
# FixMe: Do we still need logs storage? All logs should be stored in Loki.
62-
emptyDir: {}

save-orchestrator/src/main/kotlin/com/saveourtool/save/orchestrator/config/ConfigProperties.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import org.springframework.boot.context.properties.ConstructorBinding
1616
* @property kubernetes configuration for setup in Kubernetes
1717
* @property dockerResourcesLifetime time, after which resources (images, containers, etc) should be released
1818
* @property agentsCount a number of agents to start for every [Execution]
19-
* @property executionLogs path to folder to store cli logs
2019
* @property shutdown configuration related to process of shutting down groups of agents for executions
2120
* @property aptExtraFlags additional flags that will be passed to `apt-get` when building image for tests
2221
* @property adjustResourceOwner whether Linux user that will be set as owner of resources copied into docker build directory
@@ -35,7 +34,6 @@ data class ConfigProperties(
3534
val kubernetes: KubernetesSettings?,
3635
val dockerResourcesLifetime: String = "720h",
3736
val agentsCount: Int,
38-
val executionLogs: String,
3937
val shutdown: ShutdownSettings,
4038
val aptExtraFlags: String = "",
4139
val adjustResourceOwner: Boolean = true,

save-orchestrator/src/main/kotlin/com/saveourtool/save/orchestrator/controller/AgentsController.kt

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,16 @@ import com.github.dockerjava.api.exception.DockerException
1515
import io.fabric8.kubernetes.client.KubernetesClientException
1616
import org.slf4j.LoggerFactory
1717
import org.springframework.http.HttpStatus
18-
import org.springframework.http.MediaType
1918
import org.springframework.http.ResponseEntity
20-
import org.springframework.http.codec.multipart.FilePart
2119
import org.springframework.web.bind.annotation.PostMapping
2220
import org.springframework.web.bind.annotation.RequestBody
2321
import org.springframework.web.bind.annotation.RequestParam
24-
import org.springframework.web.bind.annotation.RequestPart
2522
import org.springframework.web.bind.annotation.RestController
2623
import org.springframework.web.reactive.function.client.WebClientResponseException
2724
import org.springframework.web.server.ResponseStatusException
2825
import reactor.core.publisher.Mono
2926
import reactor.kotlin.core.publisher.doOnError
3027

31-
import java.io.File
32-
import java.io.FileOutputStream
33-
3428
/**
3529
* Controller used to start agents with needed information
3630
*/
@@ -108,38 +102,6 @@ class AgentsController(
108102
dockerService.stopAgents(agentIds)
109103
}
110104

111-
/**
112-
* @param executionLogs ExecutionLogs
113-
*/
114-
@PostMapping("/executionLogs", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
115-
fun saveAgentsLog(@RequestPart(required = true) executionLogs: FilePart) {
116-
// File name is equals to agent id
117-
val agentId = executionLogs.filename()
118-
val logDir = File(configProperties.executionLogs)
119-
if (!logDir.exists()) {
120-
log.info("Folder to store logs from agents was created: ${logDir.name}")
121-
logDir.mkdirs()
122-
}
123-
val logFile = File(logDir.path + File.separator + "$agentId.log")
124-
if (!logFile.exists()) {
125-
logFile.createNewFile()
126-
log.info("Log file for $agentId agent was created")
127-
}
128-
executionLogs.content()
129-
.map { dtBuffer ->
130-
FileOutputStream(logFile, true).use { os ->
131-
dtBuffer.asInputStream().use {
132-
it.copyTo(os)
133-
}
134-
}
135-
}
136-
.collectList()
137-
.doOnSuccess {
138-
log.info("Logs of agent with id = $agentId were written")
139-
}
140-
.subscribe()
141-
}
142-
143105
/**
144106
* Delete containers and images associated with execution [executionId]
145107
*
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
orchestrator.executionLogs=/Users/Shared/.save-cloud/cnb/executionLogs/
21
orchestrator.test-resources.tmp-path=/Users/Shared/.save-cloud/cnb/tmp
32
orchestrator.adjustResourceOwner=false
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
orchestrator.backend-url=http://localhost:5800/internal
2-
orchestrator.execution-logs=${user.home}/.save-cloud/executionLogs/
32
orchestrator.test-resources.tmp-path=${user.home}/.save-cloud/tmp
43
orchestrator.adjust-resource-owner=false

save-orchestrator/src/main/resources/application.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ spring.codec.max-in-memory-size=100MB
44
spring.jmx.enabled=false
55
management.endpoints.web.exposure.include=health,info,prometheus
66
orchestrator.backend-url=http://backend:5800/internal
7-
orchestrator.execution-logs=/home/cnb/executionLogs/
87
orchestrator.test-resources.tmp-path=/tmp
98
orchestrator.shutdown.checks-interval-millis=5000
109
orchestrator.shutdown.graceful-timeout-seconds=60

0 commit comments

Comments
 (0)