Skip to content

Commit

Permalink
Merge pull request #1370 from tomaslin/titus-use-terminate
Browse files Browse the repository at this point in the history
Titus: use v2 terminate task endpoint
  • Loading branch information
tomaslin authored Jan 11, 2017
2 parents 1a5614e + c8d54ed commit d729efa
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,6 @@ public void terminateJob(TerminateJobRequest terminateJobRequest) {
execute("killJob", titusRestAdapter.killJob(terminateJobRequest));
}

@Override
public void terminateTask(String taskId) {
execute("terminateTask", titusRestAdapter.terminateTask(taskId));
}

@Override
public void terminateTasksAndShrink(TerminateTasksAndShrinkJobRequest terminateTasksAndShrinkJob) {
if(terminateTasksAndShrinkJob.getUser() == null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ public interface TitusClient {
*/
public void terminateJob(TerminateJobRequest terminateJobRequest);

/**
*
* @param taskId
*/
public void terminateTask(String taskId);

/**
*
* @param terminateTasksAndShrinkJob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ public interface TitusRestAdapter {
@GET("/v2/jobs")
Call<List<Job>> getJobsByApplication(@Query("appName") String application);

@POST("/v2/tasks/terminate/{taskId}")
Call<Void> terminateTask(@Path("taskId") String taskId);

@POST("/api/v2/tasks/kill")
Call<Void> terminateTasksAndShrink(@Body TerminateTasksAndShrinkJobRequest terminateTasksAndShrinkJobRequest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ package com.netflix.spinnaker.clouddriver.titus.deploy.description
class TerminateTitusInstancesDescription extends AbstractTitusCredentialsDescription {
String region
List<String> instanceIds
String user
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
*/

package com.netflix.spinnaker.clouddriver.titus.deploy.ops

import com.netflix.spinnaker.clouddriver.data.task.Task
import com.netflix.spinnaker.clouddriver.data.task.TaskRepository
import com.netflix.spinnaker.clouddriver.orchestration.AtomicOperation
import com.netflix.spinnaker.clouddriver.titus.TitusClientProvider
import com.netflix.spinnaker.clouddriver.titus.client.model.TerminateTasksAndShrinkJobRequest
import com.netflix.spinnaker.clouddriver.titus.deploy.description.TerminateTitusInstancesDescription
import com.netflix.spinnaker.clouddriver.titus.client.TitusClient

Expand All @@ -39,10 +41,8 @@ class TerminateTitusInstancesAtomicOperation implements AtomicOperation<Void> {
TitusClient titusClient = titusClientProvider.getTitusClient(description.credentials, description.region)
task.updateStatus PHASE, "Terminating titus tasks: ${description.instanceIds}..."

description.instanceIds.each {
titusClient.terminateTask(it)
task.updateStatus PHASE, "Successfully issued terminate task request to titus for task: ${it}"
}
titusClient.terminateTasksAndShrink(new TerminateTasksAndShrinkJobRequest().withTaskIds(description.instanceIds).withShrink(false).withUser(description.user))
task.updateStatus PHASE, "Successfully issued terminate task request to titus for task: ${description.instanceIds.toString()}"

task.updateStatus PHASE, "Completed terminate instances operation for ${description.instanceIds}"
null
Expand Down

0 comments on commit d729efa

Please sign in to comment.