Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: StartVmWithSnapshot + RegisterConsequentVolumes #1192

Conversation

jihoon-seo
Copy link
Member

@jihoon-seo jihoon-seo commented Oct 7, 2022

[주의]

  • 기존에는 각 MCIR object의 AssociatedObjectList에 하나 이상의 VM이 기재되어 있으면 해당 MCIR 삭제를 차단했지만
    이 PR에서는 모든 MCIR에 대해 해당 제한을 해제했습니다.
  • AssociatedObjectList에 하나 이상의 VM이 기재되어 있는 MCIR을 삭제 시도 하면
    삭제할 수 없는 자원의 경우 CB-Spider 또는 CSP 수준에서 에러를 반환할 것입니다.
  • CB-Spider에는 VMReq, VMInfo struct에 ImageType 필드가 추가되었고, 여기에 MyImage 라고 명시하는 방식인데
    이 PR에서는 CB-Tumblebug의 VMReq, VMInfo struct에 ImageType 필드를 추가하지 않았습니다.
    추후에 이 필드가 있는 것이 더 좋겠다고 결정되면, 추가할 수도 있겠습니다.

[StartVmWithSnapshot]

  • VM 생성 시, imageId 필드에
    미리 생성해 둔 TB customImage 객체의 ID를 입력
  • TB 내부적으로, 다음 순서로 시도
    • 해당 NS의 TB customImage 조회 (← 이 PR에서 추가됨)
    • 해당 NS의 TB image 조회
    • SystemCommonNs 의 TB image 조회
  • CreateVm 함수의 마지막 부분에서 'RegisterConsequentVolumes' 동작 수행

[RegisterConsequentVolumes]

  • VM snapshot으로 VM을 실행했을 때, 이로 인해 생성된 CSP 볼륨 자원을 TB dataDisk object로 등록

[AWS 테스트 기록]

[MCIS에 VM 추가]

(imageId 필드에: 미리 생성해 둔 TB customImage 객체의 ID를 입력)

[Request]
cb-tumblebug/src/testclient/scripts/8.mcis/add-vm-to-mcis.sh -n jhseo -c aws -r 1
POST http://$TumblebugServer/tumblebug/ns/$NSID/mcis/$MCISID/vm

{
  "name": "'${CONN_CONFIG[$INDEX,$REGION]}'",
  "imageId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
  "vmUserAccount": "cb-user",
  "connectionName": "'${CONN_CONFIG[$INDEX,$REGION]}'",
  "sshKeyId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
  "specId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
  "securityGroupIds": [
    "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'"
  ],
  "vNetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
  "subnetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
  "description": "description",
  "vmUserPassword": ""
}

[Response (VM info)]

{
...
  "dataDiskIds": [
    "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-0",
    "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1"
  ]
...
}

[TB dataDisk object 생성 확인]

cb-tumblebug/src/testclient/scripts/11.dataDisk/id-list-dataDisk.sh
GET http://$TumblebugServer/tumblebug/ns/$NSID/resources/dataDisk?option=id

{
  "output": [
    "aws-ap-southeast-1-jhseo",
    "jhseo-datadisk",
    "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-0",
    "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1"
  ]
}

cb-tumblebug/src/testclient/scripts/11.dataDisk/list-dataDisk.sh
GET http://$TumblebugServer/tumblebug/ns/$NSID/resources/dataDisk

[
  {
    "id": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-0",
    "name": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-0",
    "connectionName": "aws-ap-southeast-1",
    "diskType": "gp2",
    "diskSize": "77",
    "cspDataDiskId": "vol-0f48b09bfb318ce34",
    "cspDataDiskName": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-0",
    "status": "Attached",
    "associatedObjectList": [
      "/ns/ns01/mcis/jhseo/vm/aws-ap-southeast-1"
    ],
    "createdTime": "2022-10-07T08:23:53.275Z",
    "keyValueList": [
      {
        "Key": "Encrypted",
        "Value": "false"
      },
      {
        "Key": "Iops",
        "Value": "231"
      },
      {
        "Key": "MultiAttachEnabled",
        "Value": "false"
      }
    ],
    "systemLabel": "Registered from CB-Spider resource"
  },
  {
    "id": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1",
    "name": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1",
    "connectionName": "aws-ap-southeast-1",
    "diskType": "gp2",
    "diskSize": "100",
    "cspDataDiskId": "vol-0ecc7f32364c6b4f0",
    "cspDataDiskName": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1",
    "status": "Attached",
    "associatedObjectList": [
      "/ns/ns01/mcis/jhseo/vm/aws-ap-southeast-1"
    ],
    "createdTime": "2022-10-07T08:23:53.362Z",
    "keyValueList": [
      {
        "Key": "Encrypted",
        "Value": "false"
      },
      {
        "Key": "Iops",
        "Value": "300"
      },
      {
        "Key": "MultiAttachEnabled",
        "Value": "false"
      }
    ],
    "systemLabel": "Registered from CB-Spider resource"
  }
]

[해당 dataDisk detach]

cb-tumblebug/src/testclient/scripts/11.dataDisk/detach-dataDisk.sh -n jhseo -c aws -r 1
PUT http://$TumblebugServer/tumblebug/ns/$NSID/mcis/${MCISID}/vm/${CONN_CONFIG[$INDEX,$REGION]}/detachDataDisk

{
...
  "dataDiskId": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1"
...
}

cb-tumblebug/src/testclient/scripts/8.mcis/list-mcis.sh | less
GET http://$TumblebugServer/tumblebug/ns/$NSID/mcis

{
  "dataDiskIds": [
    "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-0"
  ]
}

cb-tumblebug/src/testclient/scripts/11.dataDisk/list-dataDisk.sh

{
  "id": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1",
  "name": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1",
  "connectionName": "aws-ap-southeast-1",
  "diskType": "gp2",
  "diskSize": "100",
  "cspDataDiskId": "vol-0ecc7f32364c6b4f0",
  "cspDataDiskName": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1",
  "status": "Available",
  "associatedObjectList": [],
  "createdTime": "2022-10-07T08:23:53.362Z",
  "keyValueList": [
    {
      "Key": "Encrypted",
      "Value": "false"
    },
    {
      "Key": "Iops",
      "Value": "300"
    },
    {
      "Key": "MultiAttachEnabled",
      "Value": "false"
    }
  ],
  "systemLabel": "Registered from CB-Spider resource"
}

(associatedObjectList 필드가 깨끗해졌음)

[해당 dataDisk 다시 attach]

cb-tumblebug/src/testclient/scripts/11.dataDisk/attach-dataDisk.sh -n jhseo -c aws -r 1
PUT http://$TumblebugServer/tumblebug/ns/$NSID/mcis/${MCISID}/vm/${CONN_CONFIG[$INDEX,$REGION]}/attachDataDisk

{
  "dataDiskId": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1"
}

cb-tumblebug/src/testclient/scripts/8.mcis/list-mcis.sh | less

{
  "dataDiskIds": [
    "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-0",
    "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1"
  ]
}

cb-tumblebug/src/testclient/scripts/11.dataDisk/list-dataDisk.sh

{
  "id": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1",
  "name": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1",
  "connectionName": "aws-ap-southeast-1",
  "diskType": "gp2",
  "diskSize": "100",
  "cspDataDiskId": "vol-0ecc7f32364c6b4f0",
  "cspDataDiskName": "ns01-jhseo-aws-ap-southeast-1-ccvu45t6qs8ajcsubh5g-disk-1",
  "status": "Attached",
  "associatedObjectList": [
    "/ns/ns01/mcis/jhseo/vm/aws-ap-southeast-1"
  ],
  "createdTime": "2022-10-07T08:23:53.362Z",
  "keyValueList": [
    {
      "Key": "Encrypted",
      "Value": "false"
    },
    {
      "Key": "Iops",
      "Value": "300"
    },
    {
      "Key": "MultiAttachEnabled",
      "Value": "false"
    }
  ],
  "systemLabel": "Registered from CB-Spider resource"
}

(associatedObjectList 에 VM key가 다시 기재됨)

[dataDisk가 attach 되어 있는 VM을 terminate]

(성공)

[남겨진 dataDisk들을 TB REST API 이용하여 삭제]

(성공)

@jihoon-seo jihoon-seo requested a review from seokho-son as a code owner October 7, 2022 10:26
@lgtm-com
Copy link

lgtm-com bot commented Oct 7, 2022

This pull request introduces 2 alerts when merging baf2c87 into 67ae28e - view on LGTM.com

new alerts:

  • 1 for Log entries created from user input
  • 1 for Useless assignment to local variable

@seokho-son
Copy link
Member

감사합니다아아아아 !! 👍 👍 👍
LGTM

@seokho-son seokho-son merged commit 4e16a99 into cloud-barista:main Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants