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

Enhance NLB mgmt feature (2) #1178

Merged

Conversation

jihoon-seo
Copy link
Member

@jihoon-seo jihoon-seo commented Sep 23, 2022

CB-Spider v0.6.6 으로 테스트했습니다.

[주의]
'MCIS VmGroup에 VM을 추가/삭제했을 때
해당 VmGroup과 관련있는 NLB에도 VM을 추가/삭제하는 기능'은
이 PR에는 포함되어 있지 않습니다.


[As-is]

    "/ns/ns01/mcis/jhseo",
    "/ns/ns01/mcis/jhseo/vm/openstack-region01-0",
    "/ns/ns01/mcis/jhseo/vm/openstack-region01-1",
    "/ns/ns01/mcis/jhseo/vmgroup/openstack-region01",
    "/ns/ns01/nlb/openstack-region01-jhseo",

[To-be]

    "/ns/ns01/mcis/jhseo",
    "/ns/ns01/mcis/jhseo/vm/openstack-region01-0",
    "/ns/ns01/mcis/jhseo/vm/openstack-region01-1",
    "/ns/ns01/mcis/jhseo/vmgroup/openstack-region01",
    "/ns/ns01/mcis/jhseo/nlb/openstack-region01-jhseo",

  • Enable 'VmGroupId' field for CreateNLB()
    • CreateNLB() 시, 기존처럼 VM들을 나열할 수 없고, TB vmGroupId string을 명시하는 것만 가능합니다.
    • TbNLBReq.TargetGroup 필드 안에 VMs []string 필드가 남아 있기는 하지만, 여기에는 값을 적어도 무시됩니다.
      (이는 TbNLBReqTbNLBInfo 가 공통된 TBNLBTargetGroup struct를 활용하도록 되어 있기 때문입니다.
      Swagger 등에 표출되는 TbNLBReq 의 형식을 좀 더 정확히 나타내려면,
      TBNLBTargetGroup struct를 TbNLBReqTbNLBInfo 용으로 각각 분리할 수도 있겠습니다.)
    • TbNLBInfo.TargetGroup 필드 안의 VmGroupId 필드와 VMs []string 필드를 모두 활용하도록 하였습니다.
      즉, CreateNLB / AddVM / RemoveVM 하면, VmGroupId 필드에는 VmGroupId가, VMs []string 필드에는 NLB backend VM들이 나열됩니다.

[Request]
❯ ./create-NLB.sh -n jhseo -c azure -r 1
POST http://$TumblebugServer/tumblebug/ns/$NSID/mcis/${MCISID}/nlb

{
  "name": "${CONN_CONFIG[$INDEX,$REGION]}-${POSTFIX}",
  "connectionName": "${CONN_CONFIG[$INDEX,$REGION]}",
  "vNetId": "${CONN_CONFIG[$INDEX,$REGION]}-${POSTFIX}",
  "type": "PUBLIC",
  "scope": "REGION",
  "listener": {
    "Protocol": "TCP",
    "Port": "22",
    "DNSName": ""
  },
  "targetGroup": {
    "Protocol": "TCP",
    "Port": "22",
    "vmGroupId": "${CONN_CONFIG[$INDEX,$REGION]}"
  },
  "HealthChecker": {
    "Protocol": "TCP",
    "Port": "22",
    "Interval": "10",
    "Timeout": "9",
    "Threshold": "3"
  }
}

[Response]

{
  "id": "azure-westus-jhseo",
  "name": "azure-westus-jhseo",
  "connectionName": "azure-westus",
  "Type": "PUBLIC",
  "Scope": "REGION",
  "Listener": {
    "protocol": "TCP",
    "ip": "20.237.145.72",
    "port": "22",
    "dnsName": "",
    "cspID": "",
    "keyValueList": null
  },
  "targetGroup": {
    "protocol": "TCP",
    "port": "22",
    "vmGroupId": "azure-westus",
    "vms": [
      "azure-westus-0",
      "azure-westus-1"
    ],
    "CspID": "",
    "KeyValueList": null
  },
  "HealthChecker": {
    "protocol": "TCP",
    "port": "22",
    "interval": 10,
    "timeout": 0,
    "threshold": 3,
    "cspID": "",
    "keyValueList": null
  },
  "CreatedTime": "0001-01-01T00:00:00Z",
  "description": "",
  "cspNLBId": "/subscriptions/a20fed83-96bd-4480-92a9-140b8e3b7c3a/resourceGroups/cb-tumblebug-azure-westus-jhseo/providers/Microsoft.Network/loadBalancers/ns01-azur-ccmlec56qs8bn96rqgag",
  "cspNLBName": "ns01-azure-westus-jhseo",
  "status": "",
  "keyValueList": null,
  "associatedObjectList": [],
  "isAutoGenerated": false,
  "systemLabel": ""
}

  • Add 'Get NLB health' feature
    • SP의 NLB health REST API를 호출하고, 그 결과를 다듬어 출력합니다.
    • SP에서 출력한 결과에는 SP NameId & SystemId가 기재되어 있어서,
      'SP NameId에 해당되는 TB VM ID를 리턴하는 함수'를 추가하였고
      이 함수를 활용하여 TB VM ID로 변환하여 출력합니다.
    • 번외로, 현재 CreateNLB / AddVM / RemoveVM 시, SP의 응답에 SP NameId & SystemId가 기재되어 있는데,
      현재 TB의 구현은 이 SP NameId를 TB VM ID로 변환하여 출력하는 것이 아니고
      사용자가 입력한 VmGroupId으로 TB VM 리스트를 조회하거나, add/remove할 TB VM 리스트가 오면 이를 가감하여
      TB NLB 객체의 VM list에 저장 및 출력합니다.
      필요 시, 이 부분도 'SP NameId에 해당되는 TB VM ID를 리턴하는 함수'를 활용하도록 변경할 수도 있겠습니다.

[Request]
❯ ./health-NLB.sh -n jhseo -c azure -r 1
GET http://$TumblebugServer/tumblebug/ns/$NSID/mcis/${MCISID}/nlb/${CONN_CONFIG[$INDEX,$REGION]}-${POSTFIX}/healthz

[Response]

{
  "AllVMs": [
    "azure-westus-0",
    "azure-westus-1"
  ],
  "HealthyVMs": [
    "azure-westus-0",
    "azure-westus-1"
  ],
  "UnHealthyVMs": null
}

@jihoon-seo jihoon-seo linked an issue Sep 23, 2022 that may be closed by this pull request
@lgtm-com
Copy link

lgtm-com bot commented Sep 23, 2022

This pull request introduces 15 alerts when merging d5cf982 into ff8cf01 - view on LGTM.com

new alerts:

  • 15 for Log entries created from user input

Protocol string `json:"protocol" example:"TCP"` // TCP|HTTP|HTTPS
Port string `json:"port" example:"22"` // Listener Port or 1-65535

VmGroupId string `json:"vmGroupId"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VmGroupId string `json:"vmGroupId"`
VmGroupId string `json:"vmGroupId" example:"group"`

api 예시를 추가해두었습니다. :)

@seokho-son
Copy link
Member

@jihoon-seo Thanks!

LGTM :)

@seokho-son seokho-son merged commit 0f85fcc into cloud-barista:main Sep 23, 2022
@lgtm-com
Copy link

lgtm-com bot commented Sep 23, 2022

This pull request introduces 15 alerts when merging f82dcd4 into ff8cf01 - view on LGTM.com

new alerts:

  • 15 for Log entries created from user input

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.

Enhance NLB mgmt feature
2 participants