Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUN-2354: fix: npe during cleanup incomplete executions #9114

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ class GormLogFileStorageRequestProvider implements LogFileStorageRequestProvider
@Override
void delete(String executionUuid) {
def execution = findExecutionByUuid(executionUuid)
if(!execution){
return
}
def request = findByExecution(execution)
execution.setLogFileStorageRequest(null)
execution.save(flush:true)
request.delete(flush:true)
request?.delete(flush:true)
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.rundeck.app.data.providers.logstorage

import grails.testing.gorm.DataTest
import org.rundeck.app.data.model.v1.logstorage.LogFileStorageRequestData
import org.rundeck.app.data.providers.GormExecReportDataProvider
import rundeck.CommandExec
import rundeck.ExecReport
import rundeck.Execution
import rundeck.JobExec
import rundeck.LogFileStorageRequest
import rundeck.PluginStep
import rundeck.Workflow
import spock.lang.Specification

class GormLogFileStorageRequestProviderSpec extends Specification implements DataTest {
def provider = new GormLogFileStorageRequestProvider()

def setupSpec() {
mockDomains(Execution, LogFileStorageRequest, Workflow, CommandExec, PluginStep, JobExec)
}

def "Delete by execid no execution"() {
given:

def execUuid = UUID.randomUUID().toString()
when:
provider.delete(execUuid)
then:
noExceptionThrown()
}

def "Delete by execid no request"() {
given:
def execUuid = UUID.randomUUID().toString()
def exec = new Execution(
dateStarted: new Date(),
dateCompleted: null,
user: 'user1',
project: 'test',
serverNodeUUID: null,
outputfilepath: '/tmp/test/logs/blah/1.rdlog',
uuid: execUuid
).save()


when:
provider.delete(execUuid)
then:
noExceptionThrown()
}

def "Delete by execid valid"() {
given:
def execUuid = UUID.randomUUID().toString()
def exec = new Execution(
dateStarted: new Date(),
dateCompleted: null,
user: 'user1',
project: 'test',
serverNodeUUID: null,
outputfilepath: '/tmp/test/logs/blah/1.rdlog',
uuid: execUuid
).save()


def request = provider.create(
Mock(LogFileStorageRequestData) {
getExecutionUuid() >> execUuid
getExecutionId() >> exec.id
getPluginName() >> 'test'
getFiletype() >> 'test'
getCompleted() >> false

}
)
when:
def found = Execution.get(exec.id).logFileStorageRequest
then:
found != null
when:
provider.delete(execUuid)
then:
Execution.get(exec.id).logFileStorageRequest == null
LogFileStorageRequest.get(request.id) == null
noExceptionThrown()
}
}