Search in sources :

Example 6 with DaemonTaskInterrupted

use of com.netflix.spinnaker.halyard.core.tasks.v1.DaemonTaskInterrupted in project halyard by spinnaker.

the class GoogleDistributedService method sshTunnelIntoService.

default <S> URI sshTunnelIntoService(AccountDeploymentDetails<GoogleAccount> details, SpinnakerRuntimeSettings runtimeSettings, SpinnakerService<S> sidecar) {
    ServiceSettings settings = runtimeSettings.getServiceSettings(sidecar);
    RunningServiceDetails runningServiceDetails = getRunningServiceDetails(details, runtimeSettings);
    Integer enabledVersion = runningServiceDetails.getLatestEnabledVersion();
    if (enabledVersion == null) {
        throw new HalException(FATAL, "Cannot connect to " + getServiceName() + " when no server groups have been deployed yet");
    }
    List<RunningServiceDetails.Instance> instances = runningServiceDetails.getInstances().get(enabledVersion);
    if (instances == null || instances.isEmpty()) {
        throw new HalException(FATAL, "Cannot connect to " + getServiceName() + " when no instances have been deployed yet");
    }
    try {
        return GoogleProviderUtils.openSshTunnel(details, instances.get(0).getId(), settings);
    } catch (InterruptedException e) {
        throw new DaemonTaskInterrupted(e);
    }
}
Also used : ManagedInstance(com.google.api.services.compute.model.ManagedInstance) RunningServiceDetails(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) DaemonTaskInterrupted(com.netflix.spinnaker.halyard.core.tasks.v1.DaemonTaskInterrupted)

Example 7 with DaemonTaskInterrupted

use of com.netflix.spinnaker.halyard.core.tasks.v1.DaemonTaskInterrupted in project halyard by spinnaker.

the class KubernetesAccountValidator method ensureKubectlExists.

public void ensureKubectlExists(ConfigProblemSetBuilder p) {
    JobExecutor jobExecutor = DaemonTaskHandler.getJobExecutor();
    JobRequest request = new JobRequest().setTokenizedCommand(Collections.singletonList("kubectl")).setTimeoutMillis(TimeUnit.SECONDS.toMillis(10));
    JobStatus status;
    try {
        status = jobExecutor.backoffWait(jobExecutor.startJob(request));
    } catch (InterruptedException e) {
        throw new DaemonTaskInterrupted(e);
    }
    if (status.getResult() != JobStatus.Result.SUCCESS) {
        p.addProblem(FATAL, String.join(" ", "`kubectl` not installed, or can't be found by Halyard. It is needed for", "opening connections to your Kubernetes cluster to send commands to the Spinnaker deployment running there.")).setRemediation(String.join(" ", "Visit https://kubernetes.io/docs/tasks/kubectl/install/.", "If you've already installed kubectl via gcloud, it's possible updates to your $PATH aren't visible to Halyard."));
    }
}
Also used : JobStatus(com.netflix.spinnaker.halyard.core.job.v1.JobStatus) JobRequest(com.netflix.spinnaker.halyard.core.job.v1.JobRequest) JobExecutor(com.netflix.spinnaker.halyard.core.job.v1.JobExecutor) DaemonTaskInterrupted(com.netflix.spinnaker.halyard.core.tasks.v1.DaemonTaskInterrupted)

Aggregations

DaemonTaskInterrupted (com.netflix.spinnaker.halyard.core.tasks.v1.DaemonTaskInterrupted)7 JobRequest (com.netflix.spinnaker.halyard.core.job.v1.JobRequest)6 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)5 JobStatus (com.netflix.spinnaker.halyard.core.job.v1.JobStatus)5 JobExecutor (com.netflix.spinnaker.halyard.core.job.v1.JobExecutor)2 File (java.io.File)2 IOException (java.io.IOException)2 ManagedInstance (com.google.api.services.compute.model.ManagedInstance)1 RunningServiceDetails (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails)1 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1