실행 중인 작업 검사하기
실행 중인 작업 검사하기 (Inspect running jobs)
작업 제출이 성공했다고 해서 작업이 성공적으로 실행 중이라는 뜻은 아니에요. 이것은 낙관적(highly-optimistic) 스케줄러의 특성이에요. 성공적인 작업 제출은 서버가 올바른 스케줄링 명령을 발행할 수 있었다는 뜻이에요. 작업이 실제로 실행 중이라는 의미는 아니에요. 작업이 실행 중이고 정상인지 확인하려면 그 상태를 검사해야 할 수 있어요.
이 섹션은 "docs"라는 작업을 사용하지만, 이러한 작업과 명령은 Nomad의 모든 작업에 대체로 적용돼요.
출처: 문서
본문
작업 상태 조회하기 (Query the job status)
작업이 제출되면 job status 명령으로 해당 작업의 상태를 조회할 수 있어요:
$ nomad job status
ID Type Priority Status
docs service 50 running
높은 수준에서 작업이 현재 실행 중임을 관찰할 수 있지만, "running"이 실제로 무엇을 의미하는지가 궁금할 수 있어요. job status 명령에 작업 이름을 제공하면 Nomad에 더 자세한 작업 정보를 요청할 수 있어요:
$ nomad job status docs
ID = docs
Name = docs
Type = service
Priority = 50
Datacenters = dc1
Status = running
Periodic = false
Summary
Task Group Queued Starting Running Failed Complete Lost
example 0 0 3 0 0 0
Allocations
ID Eval ID Node ID Task Group Desired Status Created At
04d9627d 42d788a3 a1f934c9 example run running <timestamp>
e7b8d4f5 42d788a3 012ea79b example run running <timestamp>
5cbf23a1 42d788a3 1e1aa1e0 example run running <timestamp>
이 출력은 이 태스크의 인스턴스 3개가 각각 자신의 할당과 함께 실행 중임을 보여줘요. status 명령에 대한 자세한 내용은 nomad job status 명령 문서를 참조하세요.
평가의 상태 가져오기 (Fetch an evaluation's status)
평가(evaluation)를 스케줄러에 대한 제출이라고 생각할 수 있어요. 아래 예제는 일부 할당은 성공적으로 배치되었지만, 원하는 모든 할당을 배치하기에 충분한 리소스가 없었던 작업에 대한 상태 출력을 보여줘요.
-evals 플래그로 status 명령을 실행하면 출력에 이 가상 작업에 대한 미해결 평가가 있음을 보여줘요:
$ nomad job status -evals docs
ID = docs
Name = docs
Type = service
Priority = 50
Datacenters = dc1
Status = running
Periodic = false
Evaluations
ID Priority Triggered By Status Placement Failures
5744eb15 50 job-register blocked N/A - In Progress
8e38e6cf 50 job-register complete true
Placement Failure
Task Group "example":
* Resources exhausted on 1 nodes
* Dimension "cpu" exhausted on 1 nodes
Allocations
ID Eval ID Node ID Task Group Desired Status Created At
12681940 8e38e6cf 4beef22f example run running <timestamp>
395c5882 8e38e6cf 4beef22f example run running <timestamp>
4d7c6f84 8e38e6cf 4beef22f example run running <timestamp>
843b07b8 8e38e6cf 4beef22f example run running <timestamp>
a8bc6d3e 8e38e6cf 4beef22f example run running <timestamp>
b0beb907 8e38e6cf 4beef22f example run running <timestamp>
da21c1fd 8e38e6cf 4beef22f example run running <timestamp>
출력은 작업에 진행 중인 "blocked" 평가가 있음을 나타내요. Nomad가 원하는 모든 할당을 배치할 수 없으면 더 많은 리소스가 사용 가능해질 때까지 기다리는 차단된 평가를 만들어요.
eval status 명령은 모든 평가를 더 자세히 검사할 수 있게 해줘요. 대부분의 경우 이것은 필요하지 않아요. 하지만 특정 평가를 무엇이 트리거했는지와 현재 상태를 이해하는 데 유용할 수 있어요. "complete" 평가에 대해 실행하면 다음과 유사한 출력을 제공해요:
$ nomad eval status 8e38e6cf
ID = 8e38e6cf
Status = complete
Status Description = complete
Type = service
TriggeredBy = job-register
Job ID = docs
Priority = 50
Placement Failures = true
Failed Placements
Task Group "example" (failed to place 3 allocations):
* Resources exhausted on 1 nodes
* Dimension "cpu" exhausted on 1 nodes
Evaluation "5744eb15" waiting for additional capacity to place remainder
이 출력은 평가가 "job-register" 이벤트에 의해 생성되었고 배치 실패가 있었음을 나타내요. 평가는 또한 배치가 실패한 이유에 대한 정보를 가져요. 또한 생성된 후속 평가의 평가도 출력돼요.
이 출력에 대해 더 알아보려면 nomad eval status 명령 문서를 참조하세요.
할당의 상태 검색하기 (Retrieve an allocation's status)
할당(allocation)을 스케줄하라는 지시로 생각할 수 있어요. 애플리케이션이나 서비스처럼 할당은 로그와 상태를 가져요. alloc status 명령은 태스크에 발생한 가장 최근 이벤트, 리소스 사용량, 포트 할당 등을 제공해요:
$ nomad alloc status 04d9627d
ID = 04d9627d
Eval ID = 42d788a3
Name = docs.example[2]
Node ID = a1f934c9
Job ID = docs
Client Status = running
Task "server" is "running"
Task Resources
CPU Memory Disk Addresses
0/100 MHz 728 KiB/10 MiB 300 MiB http: 10.1.1.196:5678
Recent Events:
Time Type Description
10/09/16 00:36:06 UTC Started Task started by client
10/09/16 00:36:05 UTC Received Task received by client
nomad alloc status 명령은 시작하지 못한 애플리케이션을 디버깅하기 좋은 시작점이에요. 가상으로 사용자가 "redis:2.8"이라는 Docker 컨테이너를 시작하려 했지만 실수로 마침표 대신 쉼표를 넣어 "redis:2,8"이라고 입력했다고 가정해 봐요.
작업이 실행되면 실패한 할당이 생겨요. nomad alloc status 명령이 그 이유를 알려줘요.
$ nomad alloc status 04d9627d
ID = 04d9627d
...
Recent Events:
Time Type Description
06/28/16 15:50:22 UTC Not Restarting Error was unrecoverable
06/28/16 15:50:22 UTC Driver Failure failed to create image: Failed to pull `redis:2,8`: API error (500): invalid tag format
06/28/16 15:50:22 UTC Received Task received by client
안타깝게도 모든 실패가 할당 상태 출력에서 이렇게 잘 보이는 것은 아니에요. alloc status 명령이 많은 재시작을 보여준다면 시작 중 애플리케이션 수준 문제가 있을 가능성이 높아요. 예를 들어:
$ nomad alloc status 04d9627d
ID = 04d9627d
...
Recent Events:
Time Type Description
06/28/16 15:56:16 UTC Restarting Task restarting in 5.178426031s
06/28/16 15:56:16 UTC Terminated Exit Code: 1, Exit Message: "Docker container exited with non-zero exit code: 1"
06/28/16 15:56:16 UTC Started Task started by client
06/28/16 15:56:00 UTC Restarting Task restarting in 5.00123931s
06/28/16 15:56:00 UTC Terminated Exit Code: 1, Exit Message: "Docker container exited with non-zero exit code: 1"
06/28/16 15:55:59 UTC Started Task started by client
06/28/16 15:55:48 UTC Received Task received by client
이러한 실패를 디버깅하려면 nomad alloc logs 명령을 사용할 수 있어요. 이 문서의 로그 접근 섹션에서 논의해요.
alloc status 명령에 대한 자세한 내용은 nomad alloc status 명령 문서를 참조하세요.
웹 UI에서 작업 모니터링하기 (Monitoring a job in the web UI)
웹 UI에서 작업의 개요 페이지를 보려면 Jobs 페이지의 목록에서 작업 이름을 클릭해요. 개요 페이지 상단에는 실행 중인 작업에 대한 더 자세한 내용을 보기 위한 여러 연결된 하위 페이지가 있어요.
- Overview: 작업 이름, 유형, 우선순위, 네임스페이스, 현재 및 이전 모든 할당의 상태, 배치 실패, 관련 태스크 그룹을 포함한 작업에 대한 일반 정보 페이지.
- Definition: 작업 정의를 JSON으로 표시하는 페이지.
- Versions: 작업의 모든 버전을 타임라인 보기로 보여주는 페이지. 이 페이지에서 작업 버전 간의 차이를 비교할 수 있어요.
- Deployments: 작업 배포, 관련 태스크 그룹, 할당에 대한 상태 정보가 있는 페이지.
- Allocations: 관련 할당 목록이 있는 페이지.
- Evaluations: 관련 평가 목록이 있는 페이지.
- Services: 서비스 디스커버리를 위해 등록된 서비스와 관련 할당 목록이 있는 페이지.
- Variables: 작업이 사용하는 관련 Nomad 변수가 있는 페이지.