Study/CI&CD
[troubleshooting] sonarqube 사용 시 socket timeout 발생
Bluesky_
2022. 7. 9. 10:22
반응형
에러 발생 현상
오래간만에 sonarqube를 사용했는데 계속 socket timeout이 발생한다.
mvn clean verify -B -U -Psonarqube sonar:sonar -Dsonar.projectKey=bluesky-boot "-Dsonar.projectName=bluesky boot project"
에러는 대략 다음과 같다.
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project bluesky-boot-build: Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@135b8428-org.sonar.scanner.report.ReportPublisher': Unsatisfied dependency expressed through constructor parameter 7; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@135b8428-org.sonar.scanner.report.ActiveRulesPublisher': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ActiveRules' defined in org.sonar.scanner.rule.ActiveRulesProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonar.api.batch.rule.internal.DefaultActiveRules]: Factory method 'provide' threw exception; nested exception is java.lang.IllegalStateException: Fail to request url: http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muLQH4ykNsAtFooq0&ps=500&p=1: timeout: Socket closed -> [Help 1]
내 경우 이 주소를 호출하면서 socket timeout이 발생했다.
/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muLQH4ykNsAtFooq0&ps=500&p=1
debug mode로 로그를 확인하면 다음과 같이 /api/rules/search.protobuf의 내용을 가져오다가 응답에 시간이 오래 걸리면서 socket timeout이 발생한 것을 확인할 수 있다.
[DEBUG] 16:19:57.099 GET 200 http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muKsv4ykNsAtFon2Y&ps=500&p=1 | time=700ms
[DEBUG] 16:19:57.929 GET 200 http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muKwc4ykNsAtFon31&ps=500&p=1 | time=656ms
[DEBUG] 16:19:58.487 GET 200 http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3ncCPwk6rJFVNFwvMO&ps=500&p=1 | time=555ms
[DEBUG] 16:19:59.081 GET 200 http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muK0G4ykNsAtFon5Q&ps=500&p=1 | time=593ms
[DEBUG] 16:19:59.740 GET 200 http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muK3_4ykNsAtFon8c&ps=500&p=1 | time=656ms
[DEBUG] 16:20:25.635 GET 200 http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muK8K4ykNsAtFooD4&ps=500&p=1 | time=25887ms
[DEBUG] 16:20:26.500 GET 200 http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muLBF4ykNsAtFooLv&ps=500&p=1 | time=850ms
[DEBUG] 16:20:27.208 GET 200 http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muLFk4ykNsAtFooPJ&ps=500&p=1 | time=698ms
[DEBUG] 16:20:53.179 GET 200 http://sonarqube-service:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt,deprecatedKeys&activation=true&qprofile=AX3muLKv4ykNsAtFooXy&ps=500&p=1 | time=25963ms
해결 방법
이 경우 timeout 시간을 늘려주면 된다.
해당 설정은 문서에 안내되어 있다.
https://docs.sonarqube.org/latest/analysis/analysis-parameters/
다음과 같이 빌드 시 'sonar.ws.timeout' 파라미터를 추가한다.
mvn clean verify -B -U -Psonarqube sonar:sonar -Dsonar.ws.timeout=300 -Dsonar.projectKey=bluesky-boot "-Dsonar.projectName=bluesky boot project"
반응형