Search in sources :

Example 51 with SpinnakerRuntimeSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings in project halyard by spinnaker.

the class RoscoService method getProfiles.

@Override
public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
    List<Profile> profiles = super.getProfiles(deploymentConfiguration, endpoints);
    String filename = "rosco.yml";
    String path = Paths.get(getConfigOutputPath(), filename).toString();
    Profile profile = roscoProfileFactory.getProfile(filename, path, deploymentConfiguration, endpoints);
    appendCustomConfigDir(profile);
    profiles.add(profile);
    profiles.addAll(prefixProfileBuilder.build(deploymentConfiguration, getRoscoConfigPath(), getArtifact(), "packer"));
    return profiles;
}
Also used : Profile(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.Profile)

Example 52 with SpinnakerRuntimeSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings in project halyard by spinnaker.

the class SpinnakerMonitoringDaemonProfileFactory method setProfile.

@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
    SpinnakerRuntimeSettings.Services services = endpoints.getServices();
    ServiceSettings monitoringService = services.getMonitoringDaemon();
    MetricStores metricStores = deploymentConfiguration.getMetricStores();
    List<String> enabledMetricStores = new ArrayList<>();
    List<String> files = new ArrayList<>();
    DatadogStore datadogStore = metricStores.getDatadog();
    if (datadogStore.isEnabled()) {
        enabledMetricStores.add("datadog");
    }
    PrometheusStore prometheusStore = metricStores.getPrometheus();
    if (prometheusStore.isEnabled()) {
        enabledMetricStores.add("prometheus");
    }
    StackdriverStore stackdriverStore = metricStores.getStackdriver();
    if (stackdriverStore.isEnabled()) {
        enabledMetricStores.add("stackdriver");
        files.addAll(backupRequiredFiles(stackdriverStore, deploymentConfiguration.getName()));
    }
    profile.appendContents(yamlToString(metricStores));
    Server server = new Server().setHost(monitoringService.getHost()).setPort(monitoringService.getPort());
    ServerConfig serverConfig = new ServerConfig();
    serverConfig.setServer(server);
    profile.appendContents(yamlToString(serverConfig));
    Monitor monitor = new Monitor().setPeriod(metricStores.getPeriod()).setMetricStore(enabledMetricStores);
    MonitorConfig monitorConfig = new MonitorConfig();
    monitorConfig.setMonitor(monitor);
    profile.appendContents(yamlToString(monitorConfig));
    profile.appendContents(profile.getBaseContents());
    profile.setRequiredFiles(files);
}
Also used : MetricStores(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) ArrayList(java.util.ArrayList) StackdriverStore(com.netflix.spinnaker.halyard.config.model.v1.metricStores.stackdriver.StackdriverStore) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) DatadogStore(com.netflix.spinnaker.halyard.config.model.v1.metricStores.datadog.DatadogStore) PrometheusStore(com.netflix.spinnaker.halyard.config.model.v1.metricStores.prometheus.PrometheusStore)

Example 53 with SpinnakerRuntimeSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings in project halyard by spinnaker.

the class DistributedDeployer method deploy.

@Override
public RemoteAction deploy(DistributedServiceProvider<T> serviceProvider, AccountDeploymentDetails<T> deploymentDetails, ResolvedConfiguration resolvedConfiguration, List<SpinnakerService.Type> serviceTypes) {
    SpinnakerRuntimeSettings runtimeSettings = resolvedConfiguration.getRuntimeSettings();
    DaemonTaskHandler.newStage("Deploying Spinnaker");
    // First deploy all services not owned by Spinnaker
    for (DistributedService distributedService : serviceProvider.getPrioritizedDistributedServices(serviceTypes)) {
        SpinnakerService service = distributedService.getService();
        ServiceSettings settings = resolvedConfiguration.getServiceSettings(service);
        if (!settings.getEnabled() || settings.getSkipLifeCycleManagement()) {
            continue;
        }
        DaemonTaskHandler.newStage("Determining status of " + distributedService.getServiceName());
        boolean safeToUpdate = settings.getSafeToUpdate();
        RunningServiceDetails runningServiceDetails = distributedService.getRunningServiceDetails(deploymentDetails, runtimeSettings);
        if (distributedService.isRequiredToBootstrap() || !safeToUpdate) {
            deployServiceManually(deploymentDetails, resolvedConfiguration, distributedService, safeToUpdate);
        } else {
            DaemonResponse.StaticRequestBuilder<Void> builder = new DaemonResponse.StaticRequestBuilder<>(() -> {
                if (runningServiceDetails.getLatestEnabledVersion() == null) {
                    DaemonTaskHandler.newStage("Deploying " + distributedService.getServiceName() + " via provider API");
                    deployServiceManually(deploymentDetails, resolvedConfiguration, distributedService, safeToUpdate);
                } else {
                    DaemonTaskHandler.newStage("Deploying " + distributedService.getServiceName() + " via red/black");
                    Orca orca = serviceProvider.getDeployableService(SpinnakerService.Type.ORCA_BOOTSTRAP, Orca.class).connectToPrimaryService(deploymentDetails, runtimeSettings);
                    deployServiceWithOrca(deploymentDetails, resolvedConfiguration, orca, distributedService);
                }
                return null;
            });
            DaemonTaskHandler.submitTask(builder::build, "Deploy " + distributedService.getServiceName());
        }
    }
    DaemonTaskHandler.message("Waiting on deployments to complete");
    DaemonTaskHandler.reduceChildren(null, (t1, t2) -> null, (t1, t2) -> null).getProblemSet().throwifSeverityExceeds(Problem.Severity.WARNING);
    DistributedService<Orca, T> orca = serviceProvider.getDeployableService(SpinnakerService.Type.ORCA);
    Set<Integer> unknownVersions = reapOrcaServerGroups(deploymentDetails, runtimeSettings, orca);
    reapRoscoServerGroups(deploymentDetails, runtimeSettings, serviceProvider.getDeployableService(SpinnakerService.Type.ROSCO));
    if (!unknownVersions.isEmpty()) {
        String versions = String.join(", ", unknownVersions.stream().map(orca::getVersionedName).collect(Collectors.toList()));
        throw new HalException(new ProblemBuilder(Problem.Severity.ERROR, "The following orca versions (" + versions + ") could not safely be drained of work.").setRemediation("Please make sure that no pipelines are running, and manually destroy the server groups at those versions.").build());
    }
    return new RemoteAction();
}
Also used : Orca(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.OrcaService.Orca) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) SpinnakerService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService) ProblemBuilder(com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder) DistributedService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.DistributedService) DaemonResponse(com.netflix.spinnaker.halyard.core.DaemonResponse) RunningServiceDetails(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails) RemoteAction(com.netflix.spinnaker.halyard.core.RemoteAction)

Example 54 with SpinnakerRuntimeSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings in project halyard by spinnaker.

the class DistributedDeployer method deployServiceWithOrca.

private <T extends Account> void deployServiceWithOrca(AccountDeploymentDetails<T> details, ResolvedConfiguration resolvedConfiguration, Orca orca, DistributedService distributedService) {
    SpinnakerRuntimeSettings runtimeSettings = resolvedConfiguration.getRuntimeSettings();
    RunningServiceDetails runningServiceDetails = distributedService.getRunningServiceDetails(details, runtimeSettings);
    Supplier<String> idSupplier;
    if (!runningServiceDetails.getLoadBalancer().isExists()) {
        Map<String, Object> task = distributedService.buildUpsertLoadBalancerTask(details, runtimeSettings);
        idSupplier = () -> (String) orca.submitTask(task).get("ref");
        orcaRunner.monitorTask(idSupplier, orca);
    }
    List<String> configs = distributedService.stageProfiles(details, resolvedConfiguration);
    Integer maxRemaining = MAX_REMAINING_SERVER_GROUPS;
    boolean scaleDown = true;
    if (distributedService.isStateful()) {
        maxRemaining = null;
        scaleDown = false;
    }
    Map<String, Object> pipeline = distributedService.buildDeployServerGroupPipeline(details, runtimeSettings, configs, maxRemaining, scaleDown);
    idSupplier = () -> (String) orca.orchestrate(pipeline).get("ref");
    orcaRunner.monitorPipeline(idSupplier, orca);
}
Also used : RunningServiceDetails(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)

Example 55 with SpinnakerRuntimeSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings in project halyard by spinnaker.

the class DistributedDeployer method disableOrcaServerGroups.

private <T extends Account> Set<Integer> disableOrcaServerGroups(AccountDeploymentDetails<T> details, SpinnakerRuntimeSettings runtimeSettings, DistributedService<Orca, T> orcaService, RunningServiceDetails runningOrcaDetails) {
    Map<Integer, List<RunningServiceDetails.Instance>> instances = runningOrcaDetails.getInstances();
    List<Integer> existingVersions = new ArrayList<>(instances.keySet());
    existingVersions.sort(Integer::compareTo);
    Map<String, String> disableRequest = new HashMap<>();
    Set<Integer> result = new HashSet<>();
    disableRequest.put("enabled", "false");
    List<Integer> disabledVersions = existingVersions.subList(0, existingVersions.size() - 1);
    for (Integer version : disabledVersions) {
        try {
            for (RunningServiceDetails.Instance instance : instances.get(version)) {
                log.info("Disabling instance " + instance.getId());
                Orca orca = orcaService.connectToInstance(details, runtimeSettings, orcaService.getService(), instance.getId());
                orca.setInstanceStatusEnabled(disableRequest);
            }
            result.add(version);
        } catch (RetrofitError e) {
            Response response = e.getResponse();
            if (response == null) {
                log.warn("Unexpected error disabling orca", e);
            } else if (response.getStatus() == 400 && ((Map) e.getBodyAs(Map.class)).containsKey("discovery")) {
                log.info("Orca instance is managed by eureka");
                result.add(version);
            } else {
                log.warn("Orca version doesn't support explicit disabling of instances", e);
            }
        }
    }
    Set<Integer> unknownVersions = disabledVersions.stream().filter(i -> !result.contains(i)).collect(Collectors.toSet());
    if (unknownVersions.size() > 0) {
        log.warn("There are existing orca server groups that cannot be explicitly disabled, we will have to wait for these to drain work");
    }
    return unknownVersions;
}
Also used : RedisService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.RedisService) DaemonResponse(com.netflix.spinnaker.halyard.core.DaemonResponse) LogCollector(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.LogCollector) Autowired(org.springframework.beans.factory.annotation.Autowired) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) HashMap(java.util.HashMap) Supplier(java.util.function.Supplier) DaemonTaskHandler(com.netflix.spinnaker.halyard.core.tasks.v1.DaemonTaskHandler) RunningServiceDetails(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) HashSet(java.util.HashSet) Orca(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.OrcaService.Orca) Rosco(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.RoscoService.Rosco) Map(java.util.Map) ResolvedConfiguration(com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService.ResolvedConfiguration) SpinnakerService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService) Response(retrofit.client.Response) DistributedServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.DistributedServiceProvider) Set(java.util.Set) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) Collectors(java.util.stream.Collectors) ProblemBuilder(com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder) Slf4j(lombok.extern.slf4j.Slf4j) Component(org.springframework.stereotype.Component) List(java.util.List) RetrofitError(retrofit.RetrofitError) Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) Jedis(redis.clients.jedis.Jedis) DistributedService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.DistributedService) Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) ConfigSource(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ConfigSource) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) RemoteAction(com.netflix.spinnaker.halyard.core.RemoteAction) Collections(java.util.Collections) Orca(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.OrcaService.Orca) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DaemonResponse(com.netflix.spinnaker.halyard.core.DaemonResponse) Response(retrofit.client.Response) RunningServiceDetails(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) RetrofitError(retrofit.RetrofitError)

Aggregations

ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)28 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)22 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)20 RunningServiceDetails (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails)20 ArrayList (java.util.ArrayList)20 Profile (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.Profile)19 HashMap (java.util.HashMap)16 SpinnakerService (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService)15 Map (java.util.Map)12 List (java.util.List)11 AccountDeploymentDetails (com.netflix.spinnaker.halyard.deploy.deployment.v1.AccountDeploymentDetails)9 Collectors (java.util.stream.Collectors)9 Names (com.netflix.frigga.Names)7 RemoteAction (com.netflix.spinnaker.halyard.core.RemoteAction)7 DistributedService (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.DistributedService)7 HashSet (java.util.HashSet)7 Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)6 ConfigSource (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ConfigSource)6 Collections (java.util.Collections)6 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)5