LocalLogCollector(HasServiceSettings<T> service) { super(service); this.logPaths = new ArrayList<>(); this.logPaths.add(Paths.get("/var/log/spinnaker/", getService().getCanonicalName())); this.logPaths.add(Paths.get("/var/log/upstart/", getService().getCanonicalName() + ".log")); }
LocalLogCollector(HasServiceSettings<T> service) { super(service); this.logPaths = new ArrayList<>(); this.logPaths.add(Paths.get("/var/log/spinnaker/", getService().getCanonicalName())); this.logPaths.add(Paths.get("/var/log/upstart/", getService().getCanonicalName() + ".log")); }
default String buildAddress() { return String.format("%s.service.spinnaker.consul", getService().getCanonicalName()); }
default String buildAddress() { return String.format("%s.service.spinnaker.consul", getService().getCanonicalName()); }
@Override public List<Profile> getSidecarProfiles(GenerateService.ResolvedConfiguration resolvedConfiguration, SpinnakerService service) { List<Profile> result = new ArrayList<>(); Map<String, Profile> profiles = resolvedConfiguration.getProfilesForService(getType()); Profile profile = profiles.get(consulClientService(service.getCanonicalName())); result.add(profile); profile = profiles.get(clientProfileName); result.add(profile); return result; }
@Override public List<Profile> getSidecarProfiles(GenerateService.ResolvedConfiguration resolvedConfiguration, SpinnakerService service) { List<Profile> result = new ArrayList<>(); Map<String, Profile> profiles = resolvedConfiguration.getProfilesForService(getType()); Profile profile = profiles.get(consulClientService(service.getCanonicalName())); result.add(profile); profile = profiles.get(clientProfileName); result.add(profile); return result; }
@Override public List<Profile> getSidecarProfiles(GenerateService.ResolvedConfiguration resolvedConfiguration, SpinnakerService service) { List<Profile> result = new ArrayList<>(); Map<String, Profile> monitoringProfiles = resolvedConfiguration.getProfilesForService(getType()); String profileName = serviceRegistryProfileName(service.getCanonicalName()); Profile profile = monitoringProfiles.get(profileName); result.add(profile); profile = monitoringProfiles.get(monitoringProfileName()); result.add(profile); return result; }
public ServiceSettings getDefaultServiceSettings(DeploymentConfiguration deploymentConfiguration) { File userSettingsFile = new File( halconfigDirectoryStructure.getUserServiceSettingsPath(deploymentConfiguration.getName()).toString(), getCanonicalName() + ".yml" ); if (userSettingsFile.exists() && userSettingsFile.length() != 0) { try { log.info("Reading user provided service settings from " + userSettingsFile); return objectMapper.convertValue( yamlParser.load(new FileInputStream(userSettingsFile)), ServiceSettings.class ); } catch (FileNotFoundException e) { throw new HalException(Problem.Severity.FATAL, "Unable to read provided user settings: " + e.getMessage(), e); } } else { return new ServiceSettings(); } }
public ServiceSettings getDefaultServiceSettings(DeploymentConfiguration deploymentConfiguration) { File userSettingsFile = new File( halconfigDirectoryStructure.getUserServiceSettingsPath(deploymentConfiguration.getName()).toString(), getCanonicalName() + ".yml" ); if (userSettingsFile.exists() && userSettingsFile.length() != 0) { try { log.info("Reading user provided service settings from " + userSettingsFile); return objectMapper.convertValue( yamlParser.load(new FileInputStream(userSettingsFile)), ServiceSettings.class ); } catch (FileNotFoundException e) { throw new HalException(Problem.Severity.FATAL, "Unable to read provided user settings: " + e.getMessage(), e); } } else { return new ServiceSettings(); } }
@Override public List<Profile> getSidecarProfiles(GenerateService.ResolvedConfiguration resolvedConfiguration, SpinnakerService service) { List<Profile> result = new ArrayList<>(); Map<String, Profile> monitoringProfiles = resolvedConfiguration.getProfilesForService(getType()); String profileName = serviceRegistryProfileName(service.getCanonicalName()); Profile profile = monitoringProfiles.get(profileName); result.add(profile); profile = monitoringProfiles.get(monitoringProfileName()); result.add(profile); profile = monitoringProfiles.get(monitoringLocalProfileName()); if (profile != null) { result.add(profile); } profile = monitoringProfiles.get(defaultFilterProfileName()); if (profile != null) { result.add(profile); } return result; }
@Override public void collectLogs(DeploymentDetails details, SpinnakerRuntimeSettings runtimeSettings) { File outputDir = directoryStructure.getServiceLogsPath( details.getDeploymentName(), "localhost", getService().getCanonicalName()).toFile(); for (Path path : logPaths) { File logFile = path.toFile(); try { if (logFile.exists()) { log.warn("No logs file \"" + logFile + "\" found."); } else if (logFile.isDirectory()) { FileUtils.copyDirectoryToDirectory(logFile, outputDir); } else if (logFile.isFile()) { FileUtils.copyFileToDirectory(logFile, outputDir); } else { log.warn("Unknown file type " + logFile); } } catch (IOException e) { throw new HalException(Problem.Severity.FATAL, "Unable to copy logs: " + e.getMessage(), e); } } } }
@Override public void collectLogs(DeploymentDetails details, SpinnakerRuntimeSettings runtimeSettings) { File outputDir = directoryStructure.getServiceLogsPath( details.getDeploymentName(), "localhost", getService().getCanonicalName()).toFile(); for (Path path : logPaths) { File logFile = path.toFile(); try { if (logFile.exists()) { log.warn("No logs file \"" + logFile + "\" found."); } else if (logFile.isDirectory()) { FileUtils.copyDirectoryToDirectory(logFile, outputDir); } else if (logFile.isFile()) { FileUtils.copyFileToDirectory(logFile, outputDir); } else { log.warn("Unknown file type " + logFile); } } catch (IOException e) { throw new HalException(Problem.Severity.FATAL, "Unable to copy logs: " + e.getMessage(), e); } } } }
@Override public void collectLogs(AccountDeploymentDetails<A> details, SpinnakerRuntimeSettings runtimeSettings) { DistributedService<T, A> distributedService = (DistributedService<T, A>) getService(); RunningServiceDetails runningServiceDetails = distributedService.getRunningServiceDetails(details, runtimeSettings); runningServiceDetails.getInstances().values().forEach(is -> is.stream() .filter(RunningServiceDetails.Instance::isRunning) .forEach(i -> { File outputDir = getDirectoryStructure().getServiceLogsPath( details.getDeploymentName(), i.getId(), getService().getCanonicalName()).toFile(); collectInstanceLogs(details, runtimeSettings, outputDir, i.getId()); }) ); }
installable.installArtifactCommand(deploymentDetails), installable.stageStartupScripts(deploymentDetails, resolvedConfiguration)); commands.put(installable.getService().getCanonicalName(), command); return commands; }, (m1, m2) -> {
@Override public void collectLogs(AccountDeploymentDetails<A> details, SpinnakerRuntimeSettings runtimeSettings) { DistributedService<T, A> distributedService = (DistributedService<T, A>) getService(); RunningServiceDetails runningServiceDetails = distributedService.getRunningServiceDetails(details, runtimeSettings); runningServiceDetails.getInstances().values().forEach(is -> is.stream() .filter(RunningServiceDetails.Instance::isRunning) .forEach(i -> { File outputDir = getDirectoryStructure().getServiceLogsPath( details.getDeploymentName(), i.getId(), getService().getCanonicalName()).toFile(); collectInstanceLogs(details, runtimeSettings, outputDir, i.getId()); }) ); }
installable.installArtifactCommand(deploymentDetails), installable.stageProfilesCommand(deploymentDetails, resolvedConfiguration)); commands.put(installable.getService().getCanonicalName(), command); return commands; }, (m1, m2) -> {
installable.installArtifactCommand(deploymentDetails), installable.stageProfilesCommand(deploymentDetails, resolvedConfiguration)); commands.put(installable.getService().getCanonicalName(), command); return commands; }, (m1, m2) -> {
default String getServiceYaml(GenerateService.ResolvedConfiguration resolvedConfiguration) { ServiceSettings settings = resolvedConfiguration.getServiceSettings(getService()); String namespace = getNamespace(settings); TemplatedResource service = new JinjaJarResource("/kubernetes/manifests/service.yml"); service.addBinding("name", getService().getCanonicalName()); service.addBinding("namespace", namespace); service.addBinding("port", settings.getPort()); return service.toString(); }
default String getServiceYaml(GenerateService.ResolvedConfiguration resolvedConfiguration) { ServiceSettings settings = resolvedConfiguration.getServiceSettings(getService()); String namespace = getNamespace(settings); TemplatedResource service = new JinjaJarResource("/kubernetes/manifests/service.yml"); service.addBinding("name", getService().getCanonicalName()); service.addBinding("namespace", namespace); service.addBinding("port", settings.getPort()); service.addBinding("type", settings.getKubernetes().getServiceType()); service.addBinding("nodePort", settings.getKubernetes().getNodePort()); return service.toString(); }
default String getResourceYaml(KubernetesV2Executor executor, AccountDeploymentDetails<KubernetesAccount> details, GenerateService.ResolvedConfiguration resolvedConfiguration) { ServiceSettings settings = resolvedConfiguration.getServiceSettings(getService()); Integer targetSize = settings.getTargetSize(); CustomSizing customSizing = details.getDeploymentConfiguration().getDeploymentEnvironment().getCustomSizing(); if (customSizing != null) { Map componentSizing = customSizing.getOrDefault(getService().getServiceName(), new HashMap()); targetSize = (Integer) componentSizing.getOrDefault("replicas", targetSize); } String version = makeValidLabel(details.getDeploymentConfiguration().getVersion()); if (version.isEmpty()) { version = "unknown"; } return new JinjaJarResource("/kubernetes/manifests/deployment.yml") .addBinding("name", getService().getCanonicalName()) .addBinding("namespace", getNamespace(settings)) .addBinding("replicas", targetSize) .addBinding("version", version) .addBinding("podAnnotations", settings.getKubernetes().getPodAnnotations()) .addBinding("podSpec", getPodSpecYaml(executor, details, resolvedConfiguration)) .toString(); }