cloud-barista / cb-tumblebug

Cloud-Barista Multi-Cloud Infra Management Framework
Apache License 2.0
56 stars 51 forks source link

I got an error when deleting vnet or subnet with force #1923

Closed sykim-etri closed 5 days ago

sykim-etri commented 1 week ago

일부 자원 상태가 꼬여서 CSP와 CB-SP에서 삭제한 일부 자원(vnet, subnet)에 대해 force 옵션으로 삭제하고자 하는 경우 CB-SP가 없는 자원이라 error를 리턴하고 있는데, 이로 인해 CB-TB내 자원 객체를 삭제하지 못하는 상황이 발생하는 것으로 보입니다.

추가로 force 옵션에 대한 CB-SP와 CB-TB가 convention(?)이 현재 어떻게 되어 있을까요? @powerkimhub @yunkon-kim @seokho-son

8:15AM INF src/api/rest/server/middlewares/zerologger.go:59 > request ID=1731572101508981182 Method=DELETE URI=/tumblebug/ns/ns01/resources/vNet/ns01-shared-aws-ap-northeast-2?action=force clientIP=129.254.180.180 latency=18.008594ms status=500
8:15AM INF src/core/resource/vnet.go:746 > DeleteVNet
8:15AM DBG src/core/resource/vnet.go:786 > subnetsKv: [{Key:/ns/ns01/resources/vNet/ns01-shared-aws-ap-northeast-2/subnet/ns01-shared-aws-ap-northeast-2 Value:{"resourceType":"subnet","id":"ns01-shared-aws-ap-northeast-2","uid":"csq8ifm3j7gdqdupv2o0","cspResourceName":"csq8ifm3j7gdqdupv2o0","cspResourceId":"subnet-0ee746a863db8fd23","name":"ns01-shared-aws-ap-northeast-2","connectionName":"aws-ap-northeast-2","connectionConfig":{"configName":"","providerName":"","driverName":"","credentialName":"","credentialHolder":"","regionZoneInfoName":"","regionZoneInfo":{"assignedRegion":"","assignedZone":""},"regionDetail":{"regionId":"","regionName":"","description":"","location":{"display":"","latitude":0,"longitude":0},"zones":null},"regionRepresentative":false,"verified":false},"cspVNetName":"csq8ifm3j7gdqdupv2ng","cspVNetId":"vpc-0b81508ee30b55273","status":"Deleting","ipv4_CIDR":"10.25.0.0/18","zone":"ap-northeast-2a","keyValueList":[{"key":"VpcId","value":"vpc-0b81508ee30b55273"},{"key":"MapPublicIpOnLaunch","value":"false"},{"key":"AvailableIpAddressCount","value":"16379"},{"key":"AvailabilityZone","value":"ap-northeast-2a"},{"key":"Status","value":"available"}],"description":""}} {Key:/ns/ns01/resources/vNet/ns01-shared-aws-ap-northeast-2/subnet/ns01-shared-aws-ap-northeast-2-01 Value:{"resourceType":"subnet","id":"ns01-shared-aws-ap-northeast-2-01","uid":"csq8ifm3j7gdqdupv2og","cspResourceName":"csq8ifm3j7gdqdupv2og","cspResourceId":"subnet-05bf9a84dfd9874b0","name":"ns01-shared-aws-ap-northeast-2-01","connectionName":"aws-ap-northeast-2","connectionConfig":{"configName":"","providerName":"","driverName":"","credentialName":"","credentialHolder":"","regionZoneInfoName":"","regionZoneInfo":{"assignedRegion":"","assignedZone":""},"regionDetail":{"regionId":"","regionName":"","description":"","location":{"display":"","latitude":0,"longitude":0},"zones":null},"regionRepresentative":false,"verified":false},"cspVNetName":"csq8ifm3j7gdqdupv2ng","cspVNetId":"vpc-0b81508ee30b55273","status":"Available","ipv4_CIDR":"10.25.64.0/18","zone":"ap-northeast-2b","keyValueList":[{"key":"VpcId","value":"vpc-0b81508ee30b55273"},{"key":"MapPublicIpOnLaunch","value":"false"},{"key":"AvailableIpAddressCount","value":"16379"},{"key":"AvailabilityZone","value":"ap-northeast-2b"},{"key":"Status","value":"available"}],"description":""}}]
8:15AM INF src/core/resource/subnet.go:610 > DeleteSubnet
8:15AM ERR src/core/resource/subnet.go:747 > error="[Error from: http://localhost:1024/spider/vpc/csq8ifm3j7gdqdupv2ng/subnet/csq8ifm3j7gdqdupv2o0?force=true] Status code: 500 Internal Server Error, Message: {\"message\":\"aws-ap-northeast-2, csq8ifm3j7gdqdupv2o0: does not exist!\"}\n"
8:15AM ERR src/core/resource/vnet.go:822 > error="[Error from: http://localhost:1024/spider/vpc/csq8ifm3j7gdqdupv2ng/subnet/csq8ifm3j7gdqdupv2o0?force=true] Status code: 500 Internal Server Error, Message: {\"message\":\"aws-ap-northeast-2, csq8ifm3j7gdqdupv2o0: does not exist!\"}\n"
8:15AM ERR src/api/rest/server/resource/vnet.go:215 > error="[Error from: http://localhost:1024/spider/vpc/csq8ifm3j7gdqdupv2ng/subnet/csq8ifm3j7gdqdupv2o0?force=true] Status code: 500 Internal Server Error, Message: {\"message\":\"aws-ap-northeast-2, csq8ifm3j7gdqdupv2o0: does not exist!\"}\n"

https://github.com/cloud-barista/cb-tumblebug/blob/23a0ca5a1824b973d6e8395a52a03e17cd8a4aa9/src/core/resource/subnet.go#L722-L749

yunkon-kim commented 1 week ago

@sykim-etri

말씀주신 내용을 이해한 바로는 #1808 와 유사한 현상이라고 생각됩니다. (혹시, 다른 부분이 있으면 알려주시기 바랍니다.)

이를 해결하기 위해 refine옵션을 활용하시면 될 것 같습니다. refine옵션으로 해결되지 않으면 알려주세요.

refine / force option 관련 Convention은 API docs를 참고하시기 바랍니다. :-) Ref) https://cloud-barista.github.io/api/?url=https://converter.swagger.io/api/convert?url=https://raw.githubusercontent.com/cloud-barista/cb-tumblebug/main/src/api/rest/docs/swagger.json#/%5BInfra%20Resource%5D%20Network%20Management/DelSubnet

sykim-etri commented 1 week ago

예전에도 유사하게 문의를 드렸던 내용이긴 하네요.^^ force: delete subnet regardless of the status of info/resource in Spider/CSP로 기재되어 있어서 혼동이 있었던 것 같습니다. 해당 설명을 개선하는 것이 맞을지는 검토가 필요해 보입니다.

yunkon-kim commented 1 week ago

@sykim-etri force: delete a subnet on a CSP regardless of the current resource status (e.g., attempt to delete even if in use) 이렇게 수정하면 괜찮으시려나요?

sykim-etri commented 5 days ago

@yunkon-kim refine 옵션으로 삭제가 되는 것으로 보입니다. 그런데 force 키워드가 먼가 상관없이 막 지울 것 같은 느낌이긴 합니다. 아무튼 가이드만 명확하다면 상관없을 것 같습니다.