private void setupRemainingSlaves(final KubernetesClusterCreateTask currentState) {
    // Maintenance task should be singleton for any cluster.
    ClusterMaintenanceTaskService.State startState = new ClusterMaintenanceTaskService.State();
    startState.batchExpansionSize = currentState.slaveBatchExpansionSize;
    startState.documentSelfLink = currentState.clusterId;

    Operation postOperation =
        Operation.createPost(
                UriUtils.buildUri(getHost(), ClusterMaintenanceTaskFactoryService.SELF_LINK))
            .setBody(startState)
            .setCompletion(
                (Operation operation, Throwable throwable) -> {
                  if (null != throwable) {
                    failTaskAndPatchDocument(currentState, NodeType.KubernetesSlave, throwable);
                    return;
                  }

                  // The handleStart method of the maintenance task does not push itself to STARTED
                  // automatically.
                  // We need to patch the maintenance task manually to start the task immediately.
                  // Otherwise
                  // the task will wait for one interval to start.
                  startMaintenance(currentState);
                });
    sendRequest(postOperation);
  }
  private void startMaintenance(final KubernetesClusterCreateTask currentState) {
    ClusterMaintenanceTaskService.State patchState = new ClusterMaintenanceTaskService.State();
    patchState.taskState = new TaskState();
    patchState.taskState.stage = TaskState.TaskStage.STARTED;

    // Start the maintenance task async without waiting for its completion so that the creation task
    // can finish immediately.
    Operation patchOperation =
        Operation.createPatch(
                UriUtils.buildUri(
                    getHost(),
                    ClusterMaintenanceTaskFactoryService.SELF_LINK + "/" + currentState.clusterId))
            .setBody(patchState)
            .setCompletion(
                (Operation operation, Throwable throwable) -> {
                  // We ignore the failure here since maintenance task will kick in eventually.
                  TaskUtils.sendSelfPatch(this, buildPatch(TaskState.TaskStage.FINISHED, null));
                });
    sendRequest(patchOperation);
  }