code: def _check_task(taskid):
      
      try:
          taskurl = taskid.get('ref', '0000')
      except AttributeError:
          taskurl = taskid
  
      taskid = taskurl.split('/tasks/')[-1]
  
      LOG.info('Checking taskid %s', taskid)
  
      url = '{}/tasks/{}'.format(API_URL, taskid)
      task_response = requests.get(url, headers=HEADERS, verify=GATE_CA_BUNDLE, cert=GATE_CLIENT_CERT)
  
      LOG.debug(task_response.json())
  
      assert task_response.ok, 'Spinnaker communication error: {0}'.format(task_response.text)
  
      task_state = task_response.json()
      status = task_state['status']
      LOG.info('Current task status: %s', status)
  
      if status == 'SUCCEEDED':  # pylint: disable=no-else-return
          return status
      elif status == 'TERMINAL':
          raise SpinnakerTaskError(task_state)
      else:
          raise ValueError
docs: Check Spinnaker Task status.
  
      Args:
          taskid (str): Existing Spinnaker Task ID.
  
      Returns:
          str: Task status.