code: func (s *Scheduler) findVolume(job *Job, req *ct.VolumeReq) *Volume {
  	for _, vol := range s.volumes {
  		// skip destroyed or decommissioned volumes
  		if vol.GetState() == ct.VolumeStateDestroyed || vol.DecommissionedAt != nil {
  			continue
  		}
  
  		// skip if the app, release, type or path do not match
  		if vol.AppID != job.AppID {
  			continue
  		}
  		if vol.ReleaseID != job.ReleaseID {
  			continue
  		}
  		if vol.JobType != job.Type {
  			continue
  		}
  		if vol.Path != req.Path {
  			continue
  		}
  
  		// skip if the volume is assigned to another job
  		if vol.JobID != nil && *vol.JobID != job.ID {
  			continue
  		}
  
  		// skip if we have already assigned the job to a host
  		// and this volume doesn't exist on that host
  		if job.HostID != "" && vol.HostID != job.HostID {
  			continue
  		}
  
  		// return the matching volume
  		return vol
  	}
  	return nil
  }
docs: // findVolume looks for an existing, unassigned volume which matches the given
  // job's app, release and type, and the volume request's path