12.3. 로그 및 디버깅 툴

이 섹션에서는 문제 해결에 사용할 수 있는 로그 및 디버깅 툴에 대해 설명합니다.

12.3.1. 마이그레이션 계획 리소스 보기

MTC 웹 콘솔 및 CLI(명령줄 인터페이스)를 사용하여 마이그레이션 계획 리소스를 확인하여 실행 중인 마이그레이션을 모니터링하거나 실패한 마이그레이션 문제를 해결할 수 있습니다.

절차

  1. MTC 웹 콘솔에서 마이그레이션 계획을 클릭합니다.
  2. 마이그레이션 계획 옆에 있는 마이그레이션 번호를 클릭하면 마이그레이션 페이지가 표시됩니다.
  3. 마이그레이션을 클릭하여 마이그레이션 세부 정보를 확인합니다.
  4. 마이그레이션 리소스를 확장하여 목록 보기에서 마이그레이션 리소스 및 해당 상태를 봅니다.

    참고

    실패한 마이그레이션 문제를 해결하려면 실패한 상위 수준 리소스부터 시작한 다음 리소스 트리를 하위 수준 리소스로 이동합니다.

  5. 리소스 옆에 있는 옵션 메뉴 kebab 를 클릭하고 다음 옵션 중 하나를 선택합니다.

    • oc describe 복사 명령은 명령을 클립보드에 복사합니다.

      • 관련 클러스터에 로그인한 다음 명령을 실행합니다.

        리소스의 조건 및 이벤트는 YAML 형식으로 표시됩니다.

    • oc logs 복사 명령은 명령을 클립보드에 복사합니다.

      • 관련 클러스터에 로그인한 다음 명령을 실행합니다.

        리소스가 로그 필터링을 지원하는 경우 필터링된 로그가 표시됩니다.

    • JSON 보기는 웹 브라우저에서 JSON 형식으로 리소스 데이터를 표시합니다.

      데이터는 oc get <resource> 명령의 출력과 동일합니다.

12.3.2. 마이그레이션 계획 로그 보기

마이그레이션 계획에 대한 집계된 로그를 볼 수 있습니다. MTC 웹 콘솔을 사용하여 클립보드에 명령을 복사한 다음 CLI(명령줄 인터페이스)에서 명령을 실행합니다.

명령은 다음 pod의 필터링된 로그를 표시합니다.

  • Migration Controller
  • Velero
  • Restic
  • Rsync
  • Stunnel
  • Registry

절차

  1. MTC 웹 콘솔에서 마이그레이션 계획을 클릭합니다.
  2. 마이그레이션 계획 옆에 있는 마이그레이션 번호를 클릭합니다.
  3. 로그 보기를 클릭합니다.
  4. 복사 아이콘을 클릭하여 oc logs 명령을 클립보드에 복사합니다.
  5. 해당 클러스터에 로그인하고 CLI에 명령을 입력합니다.

    마이그레이션 계획에 대해 집계된 로그가 표시됩니다.

12.3.3. 마이그레이션 로그 리더 사용

마이그레이션 로그 리더를 사용하여 모든 마이그레이션 로그에 대한 필터링된 보기를 표시할 수 있습니다.

절차

  1. mig-log-reader 포드를 가져옵니다.

    $ oc -n openshift-migration get pods | grep log
  2. 단일 마이그레이션 로그를 표시하려면 다음 명령을 입력합니다.

    $ oc -n openshift-migration logs -f <mig-log-reader-pod> -c color 1
    1
    -c plain 옵션은 색상 없이 로그를 표시합니다.

12.3.4. 성능 지표 액세스

MigrationController CR(사용자 정의 리소스)은 지표를 기록하고 클러스터 내부 모니터링 스토리지로 가져옵니다. PromQL(Prometheus Query Language)을 사용하여 마이그레이션 성능 문제를 진단하여 지표를 쿼리할 수 있습니다. Migration Controller Pod가 다시 시작되면 모든 메트릭이 재설정됩니다.

OpenShift Container Platform 웹 콘솔을 사용하여 성능 지표에 액세스하고 쿼리를 실행할 수 있습니다.

절차

  1. OpenShift Container Platform 웹 콘솔에서 모니터링메트릭 을 클릭합니다.
  2. PromQL 쿼리를 입력하고 표시할 시간 창을 선택한 다음 Run Queries(쿼리 실행 )를 클릭합니다.

    웹 브라우저에 모든 결과가 표시되지 않으면 Prometheus 콘솔을 사용합니다.

12.3.4.1. 제공된 지표

MigrationController CR(사용자 정의 리소스)은 MigMigration CR 수 및 해당 API 요청에 대한 지표를 제공합니다.

12.3.4.1.1. cam_app_workload_migrations

이 메트릭은 시간 경과에 따른 MigMigration CR 수입니다. 마이그레이션 상태 변경과 함께 API 요청 정보를 수집하기 위해 mtc_client_request_countmtc_client_request_elapsed 지표를 확인하는 데 유용합니다. 이 지표는 Telemetry에 포함되어 있습니다.

표 12.1. cam_app_workload_migrations metric

쿼리 가능한 라벨 이름라벨 값 샘플레이블 설명

status

running, idle, failed, completed

MigMigration CR의 상태

type

단계, 최종

MigMigration CR의 유형

12.3.4.1.2. mtc_client_request_count

이 지표는 MigrationController 가 실행한 Kubernetes API 요청의 누적 수입니다. Telemetry에는 포함되어 있지 않습니다.

표 12.2. mtc_client_request_count 메트릭

쿼리 가능한 라벨 이름라벨 값 샘플레이블 설명

cluster

https://migcluster-url:443

요청이 발행된 클러스터

component

MigPlan, MigCluster

요청을 발급한 하위 컨트롤러 API

function

(*ReconcileMigPlan).Reconcile

요청이 발행된 기능

kind

SecretList, Deployment

요청이 발행된 Kubernetes 종류

12.3.4.1.3. mtc_client_request_elapsed

이 지표는 MigrationController가 발행한 Kubernetes API 요청의 누적 대기 시간(밀리초)입니다. Telemetry에는 포함되어 있지 않습니다.

표 12.3. mtc_client_request_elapsed 메트릭

쿼리 가능한 라벨 이름라벨 값 샘플레이블 설명

cluster

https://cluster-url.com:443

요청이 발행된 클러스터

component

migplan, migcluster

요청을 발급한 하위 컨트롤러 API

function

(*ReconcileMigPlan).Reconcile

요청이 발행된 기능

kind

SecretList, Deployment

요청이 발행된 Kubernetes 리소스

12.3.4.1.4. 유용한 쿼리

테이블에는 성능 모니터링에 사용할 수 있는 몇 가지 유용한 쿼리가 나열되어 있습니다.

표 12.4. 유용한 쿼리

쿼리설명

mtc_client_request_count

발급된 API 요청 수, 요청 유형별로 정렬

sum(mtc_client_request_count)

발행되는 총 API 요청 수

mtc_client_request_elapsed

API 요청 대기 시간, 요청 유형별로 정렬

sum(mtc_client_request_elapsed)

API 요청에 대한 총 대기 시간

sum(mtc_client_request_elapsed) / sum(mtc_client_request_count)

평균 API 요청 대기 시간

mtc_client_request_elapsed / mtc_client_request_count

요청 유형별로 정렬된 API 요청의 평균 대기 시간

cam_app_workload_migrations{status="running"} * 100

요청 수와 함께 더 쉽게 볼 수 있도록 실행 중인 마이그레이션 수, 100을 곱한 값

12.3.5. must-gather 툴 사용

must-gather 툴을 사용하여 MTC 사용자 정의 리소스에 대한 로그, 메트릭 및 정보를 수집할 수 있습니다.

must-gather 데이터는 모든 고객 사례에 첨부되어야 합니다.

1시간 또는 24시간 동안 데이터를 수집하고 Prometheus 콘솔을 사용하여 데이터를 볼 수 있습니다.

사전 요구 사항

  • cluster-admin 역할의 사용자로 OpenShift Container Platform 클러스터에 로그인해야 합니다.
  • OpenShift CLI(oc)가 설치되어 있어야 합니다.

절차

  1. must-gather 데이터를 저장하려는 디렉터리로 이동합니다.
  2. 다음 데이터 수집 옵션 중 하나에 대해 oc adm must-gather 명령을 실행합니다.

    • 지난 시간 동안 데이터를 수집하려면 다음을 수행하십시오.

      $ oc adm must-gather --image=registry.redhat.io/rhmtc/openshift-migration-must-gather-rhel8:v1.7

      데이터는 must-gather/must-gather.tar.gz 로 저장됩니다. Red Hat 고객 포털에서 해당 지원 사례에 이 파일을 업로드할 수 있습니다.

    • 지난 24 시간 동안 데이터를 수집하려면 다음을 수행하십시오.

      $ oc adm must-gather --image=registry.redhat.io/rhmtc/openshift-migration-must-gather-rhel8:v1.7 \
        -- /usr/bin/gather_metrics_dump

      이 작업에는 오랜 시간이 걸릴 수 있습니다. 데이터는 must-gather/metrics/prom_data.tar.gz 로 저장됩니다.

Prometheus 콘솔을 사용하여 메트릭 데이터 보기

Prometheus 콘솔을 사용하여 메트릭 데이터를 볼 수 있습니다.

절차

  1. prom_data.tar.gz 파일의 압축을 풉니다.

    $ tar -xvzf must-gather/metrics/prom_data.tar.gz
  2. 로컬 Prometheus 인스턴스를 생성합니다.

    $ make prometheus-run

    이 명령은 Prometheus URL을 출력합니다.

    출력 결과

    Started Prometheus on http://localhost:9090

  3. 웹 브라우저를 시작하고 URL로 이동하여 Prometheus 웹 콘솔을 사용하여 데이터를 확인합니다.
  4. 데이터를 보고 나면 Prometheus 인스턴스 및 데이터를 삭제합니다.

    $ make prometheus-cleanup

12.3.6. Velero CLI 툴을 사용하여 Velero 리소스 디버깅

BackupRestore CR(사용자 정의 리소스)을 디버그하고 Velero CLI 툴을 사용하여 로그를 검색할 수 있습니다.

Velero CLI 툴은 OpenShift CLI 툴보다 자세한 정보를 제공합니다.

구문

oc exec 명령을 사용하여 Velero CLI 명령을 실행합니다.

$ oc -n openshift-migration exec deployment/velero -c velero -- ./velero \
  <backup_restore_cr> <command> <cr_name>

$ oc -n openshift-migration exec deployment/velero -c velero -- ./velero \
  backup describe 0e44ae00-5dc3-11eb-9ca8-df7e5254778b-2d8ql

도움말 옵션

velero --help 옵션을 사용하여 모든 Velero CLI 명령을 나열합니다.

$ oc -n openshift-migration exec deployment/velero -c velero -- ./velero \
  --help
Describe 명령

velero describe 명령을 사용하여 Backup 또는 Restore CR과 관련된 경고 및 오류 요약을 검색합니다.

$ oc -n openshift-migration exec deployment/velero -c velero -- ./velero \
  <backup_restore_cr> describe <cr_name>

$ oc -n openshift-migration exec deployment/velero -c velero -- ./velero \
  backup describe 0e44ae00-5dc3-11eb-9ca8-df7e5254778b-2d8ql

Logs 명령

velero logs 명령을 사용하여 Backup 또는 Restore CR의 로그를 검색합니다.

$ oc -n openshift-migration exec deployment/velero -c velero -- ./velero \
  <backup_restore_cr> logs <cr_name>

$ oc -n openshift-migration exec deployment/velero -c velero -- ./velero \
  restore logs ccc7c2d0-6017-11eb-afab-85d0007f5a19-x4lbf

12.3.7. 부분적인 마이그레이션 실패 디버깅

Velero CLI를 사용하여 Restore CR(사용자 정의 리소스) 로그를 검사하여 부분적인 마이그레이션 실패 경고 메시지를 디버깅할 수 있습니다.

부분적인 오류는 Velero가 마이그레이션에 실패하지 않는 문제가 발생하면 발생합니다. 예를 들어 CRD(사용자 정의 리소스 정의)가 누락되거나 소스 및 대상 클러스터에서 CRD 버전 간에 불일치가 있는 경우 마이그레이션이 완료되지만 CR은 대상 클러스터에서 생성되지 않습니다.

Velero 를 부분적인 오류로 기록한 다음 Backup CR에서 나머지 오브젝트를 처리합니다.

프로세스

  1. MigMigration CR의 상태를 확인합니다.

    $ oc get migmigration <migmigration> -o yaml

    출력 예

    status:
      conditions:
      - category: Warn
        durable: true
        lastTransitionTime: "2021-01-26T20:48:40Z"
        message: 'Final Restore openshift-migration/ccc7c2d0-6017-11eb-afab-85d0007f5a19-x4lbf: partially failed on destination cluster'
        status: "True"
        type: VeleroFinalRestorePartiallyFailed
      - category: Advisory
        durable: true
        lastTransitionTime: "2021-01-26T20:48:42Z"
        message: The migration has completed with warnings, please look at `Warn` conditions.
        reason: Completed
        status: "True"
        type: SucceededWithWarnings

  2. Velero describe 명령을 사용하여 Restore CR의 상태를 확인합니다.

    $ oc -n {namespace} exec deployment/velero -c velero -- ./velero \
      restore describe <restore>

    출력 예

    Phase:  PartiallyFailed (run 'velero restore logs ccc7c2d0-6017-11eb-afab-85d0007f5a19-x4lbf' for more information)
    
    Errors:
      Velero:     <none>
      Cluster:    <none>
      Namespaces:
        migration-example:  error restoring example.com/migration-example/migration-example: the server could not find the requested resource

  3. Velero logs 명령을 사용하여 Restore CR 로그를 확인합니다.

    $ oc -n {namespace} exec deployment/velero -c velero -- ./velero \
      restore logs <restore>

    출력 예

    time="2021-01-26T20:48:37Z" level=info msg="Attempting to restore migration-example: migration-example" logSource="pkg/restore/restore.go:1107" restore=openshift-migration/ccc7c2d0-6017-11eb-afab-85d0007f5a19-x4lbf
    time="2021-01-26T20:48:37Z" level=info msg="error restoring migration-example: the server could not find the requested resource" logSource="pkg/restore/restore.go:1170" restore=openshift-migration/ccc7c2d0-6017-11eb-afab-85d0007f5a19-x4lbf

    Restore CR 로그 오류 메시지인 the server could not find the requested resource은 부분적으로 실패한 마이그레이션의 원인을 나타냅니다.

12.3.8. 문제 해결을 위해 MTC 사용자 정의 리소스 사용

다음 MTC(Migration Toolkit for Containers) 사용자 정의 리소스(CR)를 확인하여 마이그레이션 실패 문제를 해결할 수 있습니다.

  • MigCluster
  • MigStorage
  • MigPlan
  • BackupStorageLocation

    BackupStorageLocation CR에는 CR을 생성한 MTC 인스턴스를 식별하는 migrationcontroller 레이블이 포함되어 있습니다.

        labels:
          migrationcontroller: ebe13bee-c803-47d0-a9e9-83f380328b93
  • VolumeSnapshotLocation

    VolumeSnapshotLocation CR에는 CR을 생성한 MTC 인스턴스를 식별하는 migrationcontroller 레이블이 포함되어 있습니다.

        labels:
          migrationcontroller: ebe13bee-c803-47d0-a9e9-83f380328b93
  • MigMigration
  • Backup

    MTC는 대상 클러스터에서 PV(영구 볼륨)를 Retain으로 마이그레이션한 PV(영구 볼륨)의 회수 정책을 변경합니다. Backup CR에는 원래 회수 정책을 나타내는 openshift.io/orig-reclaim-policy 주석이 포함되어 있습니다. 마이그레이션된 PV의 회수 정책을 수동으로 복원할 수 있습니다.

  • Restore

절차

  1. openshift-migration 네임스페이스에 MigMigration CR을 나열합니다.

    $ oc get migmigration -n openshift-migration

    출력 예

    NAME                                   AGE
    88435fe0-c9f8-11e9-85e6-5d593ce65e10   6m42s

  2. MigMigration CR을 검사합니다.

    $ oc describe migmigration 88435fe0-c9f8-11e9-85e6-5d593ce65e10 -n openshift-migration

    출력은 다음 예제와 유사합니다.

MigMigration 예제 출력

name:         88435fe0-c9f8-11e9-85e6-5d593ce65e10
namespace:    openshift-migration
labels:       <none>
annotations:  touch: 3b48b543-b53e-4e44-9d34-33563f0f8147
apiVersion:  migration.openshift.io/v1alpha1
kind:         MigMigration
metadata:
  creationTimestamp:  2019-08-29T01:01:29Z
  generation:          20
  resourceVersion:    88179
  selfLink:           /apis/migration.openshift.io/v1alpha1/namespaces/openshift-migration/migmigrations/88435fe0-c9f8-11e9-85e6-5d593ce65e10
  uid:                 8886de4c-c9f8-11e9-95ad-0205fe66cbb6
spec:
  migPlanRef:
    name:        socks-shop-mig-plan
    namespace:   openshift-migration
  quiescePods:  true
  stage:         false
status:
  conditions:
    category:              Advisory
    durable:               True
    lastTransitionTime:  2019-08-29T01:03:40Z
    message:               The migration has completed successfully.
    reason:                Completed
    status:                True
    type:                  Succeeded
  phase:                   Completed
  startTimestamp:         2019-08-29T01:01:29Z
events:                    <none>

PV 데이터를 설명하는 Velero 백업 CR #2 예제 출력

apiVersion: velero.io/v1
kind: Backup
metadata:
  annotations:
    openshift.io/migrate-copy-phase: final
    openshift.io/migrate-quiesce-pods: "true"
    openshift.io/migration-registry: 172.30.105.179:5000
    openshift.io/migration-registry-dir: /socks-shop-mig-plan-registry-44dd3bd5-c9f8-11e9-95ad-0205fe66cbb6
    openshift.io/orig-reclaim-policy: delete
  creationTimestamp: "2019-08-29T01:03:15Z"
  generateName: 88435fe0-c9f8-11e9-85e6-5d593ce65e10-
  generation: 1
  labels:
    app.kubernetes.io/part-of: migration
    migmigration: 8886de4c-c9f8-11e9-95ad-0205fe66cbb6
    migration-stage-backup: 8886de4c-c9f8-11e9-95ad-0205fe66cbb6
    velero.io/storage-location: myrepo-vpzq9
  name: 88435fe0-c9f8-11e9-85e6-5d593ce65e10-59gb7
  namespace: openshift-migration
  resourceVersion: "87313"
  selfLink: /apis/velero.io/v1/namespaces/openshift-migration/backups/88435fe0-c9f8-11e9-85e6-5d593ce65e10-59gb7
  uid: c80dbbc0-c9f8-11e9-95ad-0205fe66cbb6
spec:
  excludedNamespaces: []
  excludedResources: []
  hooks:
    resources: []
  includeClusterResources: null
  includedNamespaces:
  - sock-shop
  includedResources:
  - persistentvolumes
  - persistentvolumeclaims
  - namespaces
  - imagestreams
  - imagestreamtags
  - secrets
  - configmaps
  - pods
  labelSelector:
    matchLabels:
      migration-included-stage-backup: 8886de4c-c9f8-11e9-95ad-0205fe66cbb6
  storageLocation: myrepo-vpzq9
  ttl: 720h0m0s
  volumeSnapshotLocations:
  - myrepo-wv6fx
status:
  completionTimestamp: "2019-08-29T01:02:36Z"
  errors: 0
  expiration: "2019-09-28T01:02:35Z"
  phase: Completed
  startTimestamp: "2019-08-29T01:02:35Z"
  validationErrors: null
  version: 1
  volumeSnapshotsAttempted: 0
  volumeSnapshotsCompleted: 0
  warnings: 0

Kubernetes 리소스를 설명하는 Velero 복원 CR #2 예제 출력

apiVersion: velero.io/v1
kind: Restore
metadata:
  annotations:
    openshift.io/migrate-copy-phase: final
    openshift.io/migrate-quiesce-pods: "true"
    openshift.io/migration-registry: 172.30.90.187:5000
    openshift.io/migration-registry-dir: /socks-shop-mig-plan-registry-36f54ca7-c925-11e9-825a-06fa9fb68c88
  creationTimestamp: "2019-08-28T00:09:49Z"
  generateName: e13a1b60-c927-11e9-9555-d129df7f3b96-
  generation: 3
  labels:
    app.kubernetes.io/part-of: migration
    migmigration: e18252c9-c927-11e9-825a-06fa9fb68c88
    migration-final-restore: e18252c9-c927-11e9-825a-06fa9fb68c88
  name: e13a1b60-c927-11e9-9555-d129df7f3b96-gb8nx
  namespace: openshift-migration
  resourceVersion: "82329"
  selfLink: /apis/velero.io/v1/namespaces/openshift-migration/restores/e13a1b60-c927-11e9-9555-d129df7f3b96-gb8nx
  uid: 26983ec0-c928-11e9-825a-06fa9fb68c88
spec:
  backupName: e13a1b60-c927-11e9-9555-d129df7f3b96-sz24f
  excludedNamespaces: null
  excludedResources:
  - nodes
  - events
  - events.events.k8s.io
  - backups.velero.io
  - restores.velero.io
  - resticrepositories.velero.io
  includedNamespaces: null
  includedResources: null
  namespaceMapping: null
  restorePVs: true
status:
  errors: 0
  failureReason: ""
  phase: Completed
  validationErrors: null
  warnings: 15