use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.
the class DiskSpaceFullCheckerTest method shouldReturnTrueIfTheArtifactFolderHasSizeLimit.
@Test
public void shouldReturnTrueIfTheArtifactFolderHasSizeLimit() {
new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, "1M");
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
ArtifactsDiskSpaceFullChecker fullChecker = createChecker(cruiseConfig);
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
fullChecker.check(result);
assertThat(result.canContinue(), is(true));
}
use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.
the class ArtifactsDiskCleaner method deleteOldArtifacts.
void deleteOldArtifacts() {
ServerConfig serverConfig = goConfigService.serverConfig();
Double requiredSpaceInGb = serverConfig.getPurgeUpto();
if (serverConfig.isArtifactPurgingAllowed()) {
double requiredSpace = requiredSpaceInGb * GoConstants.GIGA_BYTE;
LOGGER.info(String.format("Clearing old artifacts as the disk space is low. Current space: '%s'. Need to clear till we hit: '%s'.", availableSpace(), requiredSpace));
List<Stage> stages;
int numberOfStagesPurged = 0;
do {
configDbStateRepository.flushConfigState();
stages = stageService.oldestStagesWithDeletableArtifacts();
for (Stage stage : stages) {
if (availableSpace() > requiredSpace) {
break;
}
numberOfStagesPurged++;
artifactService.purgeArtifactsForStage(stage);
}
} while ((availableSpace() < requiredSpace) && !stages.isEmpty());
if (availableSpace() < requiredSpace) {
LOGGER.warn("Ran out of stages to clear artifacts from but the disk space is still low");
}
LOGGER.info(String.format("Finished clearing old artifacts. Deleted artifacts for '%s' stages. Current space: '%s'", numberOfStagesPurged, availableSpace()));
}
}
use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.
the class ArtifactDirValidator method validate.
public void validate(CruiseConfig cruiseConfig) throws Exception {
ServerConfig serverConfig = cruiseConfig.server();
String artifactDir = serverConfig.artifactsDir();
if (isEmpty(artifactDir)) {
throw new Exception("Please provide a not empty value for artifactsdir");
}
if (StringUtils.equals(".", artifactDir) || new File("").getAbsolutePath().equals(new File(artifactDir).getAbsolutePath())) {
throw new Exception("artifactsdir should not point to the root of sand box [" + new File(artifactDir).getAbsolutePath() + "]");
}
}
use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.
the class BaseUrlChangeListener method onConfigChange.
public void onConfigChange(CruiseConfig newCruiseConfig) {
ServerConfig newServerConfig = newCruiseConfig.server();
ServerSiteUrlConfig newSecureSiteUrl = newServerConfig.getSecureSiteUrl();
ServerSiteUrlConfig newSiteUrl = newServerConfig.getSiteUrl();
if (!(secureSiteUrl.equals(newSecureSiteUrl) && siteUrl.equals(newSiteUrl))) {
goCache.remove(URLS_CACHE_KEY);
LOGGER.info(String.format("[Configuration Changed] Site URL was changed from [%s] to [%s] and " + "Secure Site URL was changed from [%s] to [%s]", siteUrl, newSiteUrl, secureSiteUrl, newSecureSiteUrl));
}
setUrls(newSiteUrl, newSecureSiteUrl);
}
use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.
the class ArtifactDirValidatorTest method shouldThrowExceptionWhenUserProvidesDot.
@Test
public void shouldThrowExceptionWhenUserProvidesDot() throws Exception {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(new ServerConfig(".", null));
ArtifactDirValidator dirValidator = new ArtifactDirValidator();
try {
dirValidator.validate(cruiseConfig);
fail("should throw exception, see dot will make server check out the repository in the wrong place.");
} catch (Exception e) {
}
}
Aggregations