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

cb-spider recognition failure error in docker-compose environment #1606

Open
dev4unet opened this issue Jun 5, 2024 · 11 comments
Open

cb-spider recognition failure error in docker-compose environment #1606

dev4unet opened this issue Jun 5, 2024 · 11 comments
Labels
enhancement New feature or request wip working in progress (do not merge)

Comments

@dev4unet
Copy link
Member

dev4unet commented Jun 5, 2024

What happened
: docker-compose 환경에서 cb-tumblebug이 cb-spider의 구동 상태를 확인 못해서 종료되는 이슈가 있습니다.

[에러 로그]
cb-tumblebug | 9:19AM INF ../../go/src/github.com/cloud-barista/cb-tumblebug/src/main.go:189 > CB-Spider at http://cb-spider:1024/spider is not ready. Attempt 57/60
cb-tumblebug | 9:19AM INF ../../go/src/github.com/cloud-barista/cb-tumblebug/src/main.go:189 > CB-Spider at http://cb-spider:1024/spider is not ready. Attempt 58/60
cb-tumblebug | 9:19AM INF ../../go/src/github.com/cloud-barista/cb-tumblebug/src/main.go:189 > CB-Spider at http://cb-spider:1024/spider is not ready. Attempt 59/60
cb-tumblebug | 9:19AM INF ../../go/src/github.com/cloud-barista/cb-tumblebug/src/main.go:189 > CB-Spider at http://cb-spider:1024/spider is not ready. Attempt 60/60
cb-tumblebug | panic: Failed to confirm CB-Spider readiness within the allowed time.
cb-tumblebug | Check the connection to CB-Spider.
cb-tumblebug |
cb-tumblebug | goroutine 1 [running]:
cb-tumblebug | main.setConfig()
cb-tumblebug | /go/src/github.com/cloud-barista/cb-tumblebug/src/main.go:195 +0xb25
cb-tumblebug | main.init.0()
cb-tumblebug | /go/src/github.com/cloud-barista/cb-tumblebug/src/main.go:118 +0x7ab
cb-tumblebug exited with code 2

What you expected to happen
:

How to reproduce it (as minimally and precisely as possible)
: 제 컴퓨터의 wsl2 환경의 docker-compose 환경에서 발생하고 있습니다.

[실행 명령]
$ cm-mayfly docker compose up

docker-compose.yaml.txt

[docker-compose.yaml]
services:

CB-Spider

cb-spider:
image: cloudbaristaorg/cb-spider:0.8.18
container_name: cb-spider
platform: linux/amd64
ports:
- "0.0.0.0:1024:1024"
- "0.0.0.0:2048:2048"
volumes:
- ./conf/cb-spider/:/root/go/src/github.com/cloud-barista/cb-spider/conf/
- ./data/cb-spider/meta_db/:/root/go/src/github.com/cloud-barista/cb-spider/meta_db/
- ./data/cb-spider/log/:/root/go/src/github.com/cloud-barista/cb-spider/log/
environment:
- PLUGIN_SW=OFF
- API_USERNAME=default
- API_PASSWORD=default

CB-Tumblebug

cb-tumblebug:
image: cloudbaristaorg/cb-tumblebug:0.8.13
container_name: cb-tumblebug
platform: linux/amd64
ports:
- "0.0.0.0:1323:1323"
links:
- cb-spider
depends_on:
- cb-spider
volumes:
- ./conf/cb-tumblebug/:/app/conf/
- ./data/cb-tumblebug/meta_db/:/app/meta_db/
- ./data/cb-tumblebug/log/:/app/log/
environment:
- SPIDER_REST_URL=http://cb-spider:1024/spider
- SELF_ENDPOINT=localhost:1323
- API_USERNAME=default
- API_PASSWORD=default

Anything else we need to know?
: 혹시나 해서 cm-mayfly를 docker 이미지로 만들어서 docker-compose와 같은 네트워크에서 실행되도록 하고 http://cb-spider:1024/spider/readyz 를 호출하면 정상 동작하고 있습니다.
cb-tumblebug에서만 http://cb-spider:1024/spider/를 인식 못하는 것 같네요.

Environment

  • Source version or branch:
  • OS: 우분투20.04(WSL2)
  • Others:

Proposed solution
:

Any other context
:

@dev4unet dev4unet added the bug Something isn't working label Jun 5, 2024
@seokho-son
Copy link
Member

@dev4unet

  • 일단 cb-tb log 메시지상, http://cb-spider:1024/spider 로 환경 설정은 정상적인 것 같습니다.
  • cb-tb 컨테이너 내부에서 cb-spider 로의 연결성 (dockercompose 네트워크상 내부 컨테이너간 해당 네임으로 서로 인지 가능해야 함)만 있다면, 정상적으로 동작해야 할 것 같습니다.
  • cb-tb 컨테이너 내부에서 http://cb-spider:1024/spider/readyz 호출 가능한지 확인해봐야 할 것 같습니다. 호출이 되지 않는다면
  • cb-tb 자체 이슈라기 보다는, dockercompose 및 wsl2 환경에 의한 이슈이지 않을까 싶습니다. (또는 굽혀있는 cb-tb의 컨테이너 이미지 이슈)

@seokho-son
Copy link
Member

@yunkon-kim 예전에 wsl2 활용시 이슈가 있다고 언급해주신 적이 있는데,
https://github.com/cloud-barista/cb-tumblebug/blob/main/scripts/runTumblebug.sh#L24
혹시 공유해주실만한 정보가 있으실까요? ^^

@yunkon-kim
Copy link
Member

@seokho-son

위 스크립트에 적용된 host.docker.internal은 조금 특별한 DNS name으로 컨테이너 내부에서 Host 시스템에 접근해야 할 때 사용됩니다. (see https://docs.docker.com/desktop/networking/)

저는 컨테이너를 Host 네트워크에서 구동하는 것을 선호하지 않는 편이라 Tumblebug container 구동시에 host.docker.internal을 선택하는 것을 runTumblebug.sh에 적용하였습니다.

이것이 문의주신 docker-compose.yaml과는 관련이 없는 것으로 생각됩니다.

추가로, 공유해주신 docker-compose.yaml을 간단히 테스트해 보았습니다.

docker-compose 실행 이후에 Tumblebug conatiner에 접속하여 curl http://cb-spider:1024/spider/readyz해보니 결과가 {"message":"Unauthorized"}로 나타나고 있는데요.

기존에 Spider, tumblebug을 각각 컨테이너로 띄울 때는 없었던 부분이라 확인이 필요해 보입니다.

docker exec -it cb-tumblebug /bin/sh
# curl -v http://cb-spider:1024/spider/readyz
* Host cb-spider:1024 was resolved.
* IPv6: (none)
* IPv4: 172.24.0.2
*   Trying 172.24.0.2:1024...
* Connected to cb-spider (172.24.0.2) port 1024
> GET /spider/readyz HTTP/1.1
> Host: cb-spider:1024
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Content-Type: application/json; charset=UTF-8
< Vary: Origin
< Www-Authenticate: basic realm=Restricted
< Date: Fri, 07 Jun 2024 06:30:20 GMT
< Content-Length: 27
<
{"message":"Unauthorized"}
* Connection #0 to host cb-spider left intact

@yunkon-kim
Copy link
Member

@dev4unet 안녕하세요.

현재 docker-compose로 구동하기 위해서는 Spider 환경 변수 부분을 아래와 같이 적용해 주셔야 할 것 같습니다.

    environment:
      - PLUGIN_SW=OFF
      # if you leave these values empty, REST Auth will be disabled.
      - API_USERNAME=
      - API_PASSWORD=
      #- SPIDER_LOG_LEVEL=error
      #- SPIDER_HISCALL_LOG_LEVEL=error

사유: default로 적용할 경우, /readyz API도 인증이 적용되어 있어서 그렇습니다.
https://github.com/cloud-barista/cb-spider/blob/master/setup.env

# If the value is empty, REST Auth disabed.
export API_USERNAME=
export API_PASSWORD=

@powerkimhub Spider의 /readyz API에 인증을 적용하지 않도록 개선이 필요해 보입니다.

@powerkimhub
Copy link
Member

@dev4unet @yunkon-kim @seokho-son


  • readyz 계열 호출은 항상 auth skip하도록 반영하였습니다.
  • 적용 버전: v0.8.19

[참고: v0.8.19 관련 시험 결과]

  • [Auth=OFF] API_USERNAMEAPI_PASSWORD 설정 없이 Spider 서버 가동시 (현재 Spider 직접 가동시 default 설정)

    • (1) readyz 계열 API 호출시

      • ID/PW 설정 없는 호출 예시
        curl -s http://localhost:1024/spider/readyz |json_pp
        {
           "message" : "CB-Spider is ready"
        }
        
      • ID/PW 설정 호출 예시
        curl -su default:default http://localhost:1024/spider/readyz |json_pp
        {
           "message" : "CB-Spider is ready"
        }
        
    • (2) 일반 API 호출시

      • ID/PW 설정 없는 호출 예시

        curl -s http://localhost:1024/spider/cloudos |json_pp
        {
           "cloudos" : [
              "AWS",
              "AZURE",
              "GCP",
              "ALIBABA",
              ...
           ]
        }
        
      • ID/PW 설정 호출 예시

         curl -su default:default http://localhost:1024/spider/cloudos |json_pp
        {
           "cloudos" : [
              "AWS",
              "AZURE",
              "GCP",
              "ALIBABA",
              ...
           ]
        }
        
  • [Auth=ON] API_USERNAMEAPI_PASSWORD 설정 후 Spider 서버 가동시 (현재 Docker compose 가동시 환경)

    • (1) readyz 계열 API 호출시

      • ID/PW 설정 없는 호출 예시
        curl -s http://localhost:1024/spider/readyz |json_pp
        {
           "message" : "CB-Spider is ready"     <======= # 변경된 동작, 기존에는 Unauthorized 에러 반환
        }
        
      • ID/PW 설정 호출 예시
        curl -su default:default http://localhost:1024/spider/readyz |json_pp
        {
           "message" : "CB-Spider is ready"
        }
        
    • (2) 일반 API 호출시

      • ID/PW 설정 없는 호출 예시

        curl -s http://localhost:1024/spider/cloudos |json_pp
        {
           "message" : "Unauthorized"
        }
        
      • ID/PW 설정 호출 예시

         curl -su default:default http://localhost:1024/spider/cloudos |json_pp
        {
           "cloudos" : [
              "AWS",
              "AZURE",
              "GCP",
              "ALIBABA",
              ...
           ]
        }
        

@dev4unet
Copy link
Member Author

답변 감사합니다.^^
답변들 참고해서 우선은 인증 정보가 필요 없도록 개선된 spider를 이용하거나 기존 spider를 인증 정보 없이 구동되도록 임시로 설정하겠습니다.

다만, 개인적으로 인증 정보와 상관없이 readyz가 동작하도록 변경된 경우 readyz 호출이 정상적인 응답을 리턴 한다면...
cb-spider는 정상적으로 구동되고 있다는 것은 확인되었지만 cb-tumblebug에서 올바른 인증 정보로 cb-spider를 정상적으로 호출하고 있다는 보장은 없기 때문에 cb-tumblebug에서는 관련 부분에 대해서 체크하는 로직은 별도로 있어야 하지 않을까 싶습니다.

만약, cb-spider의 인증 정보는 test/test로 설정하고 cb-tumblebug의 인증 정보는 default/default를 사용한다고 가정할 경우 현재 임시 방변에서는 cb-tumblebug의 초기 환경을 체크하는 로직에서 cb-spider와의 연결에 이상이 없다고 판단되어서 정상 구동으로 통과되고 나중에 cb-tumblebug의 cb-spider를 이용하는 특정 로직에서 인증 정보가 틀려서 정상 동작하지 않는 경우도 발생할 수 있을 것으로 판단됩니다.

cb-tumblebug의 시스템 구동전 연계 시스템의 환경 설정을 체크하는 용도의 경우 위 상황에 대해 둘 다 보장이 필요하다면 readyz가 정상적으로 호출되었다면 모든 상황이 보장될 수 있도록 readyz에 기존처럼 인증 정보를 부여하고 호출하는 쪽에서 올바른 인증 정보로 호출하거나, 새롭게 변경된 것처럼 인증 정보 없이 readyz가 호출되도록 동작한다면 readyz로 시스템 상태를 먼저 확인 후 다른 API를 호출해서 인증 정보가 올바른지 검증하는 추가 로직도 진행하면 좋지 않을까 싶습니다.

그 외 별도로 cb-tumblebug의 환경 설정을 보면 인증 정보가 하나만 보이네요.
@seokho-son cb-spider의 URL 정보는 SPIDER_REST_URL 환경 변수를 이용하고 있는데 혹시 cb-spider의 인증 정보는 어떻게 설정하나요?
모든 프레임워크가 default 처럼 공통된 비번을 사용하거나 인증 정보 없이 구동 시키면 문제 없어 보이지만...
앞에서 설명 드린것처럼 test/test , default/default처럼 각 연계 프레임워크들이 각각 서로 다른 비번을 사용할 수 있는 경우를 고려해서, 호출하려는 연계 시스템의 인증 정보를 설정하는 방법(환경 변수 등) 이 필요할 것 같은데 잠깐 훑어 봤을 때 안 보이는 것 같습니다.
제가 참고할 정보가 있으면 링크 부탁드리며, 만약 호출하려는 각 프레임워크의 인증 정보를 설정할 수 있는 기능이 없다면 나중에 cb-tumblebug에서 사용할 cb-spider등의 인증 정보(예:SPIDER_API_USERNAME / SPIDER_API_PASSWORD)를 환경 변수 등으로 설정 또는 전달 받는 방법이 필요할 듯싶습니다.

@dev4unet
Copy link
Member Author

인증 정보는 설정해 놓고 readyz만 통과하도록 cb-spider v0.8.19 버전으로 잠깐 확인해 보니 현재는 cb-spider에 인증 정보를 설정하면 cb-tumblebug의 일부 로직에서 에러가 발생하는 것 같습니다.

cb-tumblebug | 2:27AM INF ../../go/src/github.com/cloud-barista/cb-tumblebug/src/main.go:186 > CB-Spider is now ready. Initializing CB-Tumblebug...
cb-tumblebug | 2:27AM ERR ../../go/src/github.com/cloud-barista/cb-tumblebug/src/core/common/utility.go:576 > error="[Error from: http://cb-spider:1024/spider/driver] Status code: 401 Unauthorized, Message: {"message":"Unauthorized"}\n"
cb-tumblebug | 2:27AM ERR ../../go/src/github.com/cloud-barista/cb-tumblebug/src/core/common/utility.go:538 > error="[Error from: http://cb-spider:1024/spider/driver] Status code: 401 Unauthorized, Message: {"message":"Unauthorized"}\n"
cb-tumblebug | 2:27AM ERR ../../go/src/github.com/cloud-barista/cb-tumblebug/src/core/common/utility.go:576 > error="[Error from: http://cb-spider:1024/spider/driver] Status code: 401 Unauthorized, Message: {"message":"Unauthorized"}\n"
cb-tumblebug | 2:27AM ERR ../../go/src/github.com/cloud-barista/cb-tumblebug/src/core/common/utility.go:538 > error="[Error from: http://cb-spider:1024/spider/driver] Status code: 401 Unauthorized, Message: {"message":"Unauthorized"}\n"
cb-tumblebug | 2:27AM ERR ../../go/src/github.com/cloud-barista/cb-tumblebug/src/core/common/utility.go:576 > error="[Error from: http://cb-spider:1024/spider/driver] Status code: 401 Unauthorized, Message: {"message":"Unauthorized"}\n"

위 요청 사항과 관련된 내용 같은데 혹시라도 제가 cb-tumblebug에 다른 추가 설정을 빼 먹은 것이 아니라면 cb-spider 버전과 상관없이 우선은 cb-spider 구동 시 인증 정보를 비활성화 시켜야겠네요.

@seokho-son
Copy link
Member

@dev4unet 네넵. 확인 감사합니다.

  • CB-TB에서 CB-SP의 basic auth를 활성화하여 사용하고 있지 않았었습니다. (CB-TB를 사용하는 경우, 주로 CB-SP를 내부적으로 사용)
  • 활용을 위해서는 내부적인 코드 변경이 필요하며 및 환경변수(인증정보)를 추가해야 합니다.
  • 따라서, 인증없이 readyz 를 통과하더라도, 실제 API를 활용하면서 인증 오류가 발생하는 것이 당연합니다.

어떤식으로 대응할지는 사실 고민이 좀 되는 부분입니다. (현재는 CB-TB, CB-SP간 민감한 정보가 API를 타는 상황. 어짜피 basic auth는 보안이 지원되는 auth가 아님. CB-TB-SP의 인터렉션이 사용자에게 노출될 필요가 없을 가능성이 높음 등) 향후에 개선/결정이 필요할 것으로 보입니다.
이에, 우선, DockerCompose 에서는 CB-Spider 컨테이너 구동시, basicAuth는 disable 되도록 구성 부탁드립니다.

(cc @powerkimhub @yunkon-kim )

@powerkimhub
Copy link
Member

@dev4unet

  • Spider-basicAuth disable일 경우,
  • 일단, Spider-1024, 2048을 Tumblebug 내부에서만 호출 가능하도록 설정 부탁 드립니다.

@dev4unet
Copy link
Member Author

@powerkimhub 네, cb-spider만 별도의 네트워크에서 구동되도록 망을 분리하고 cb-tumbluebug에서만 해당 네트워크에 접근 가능한 방향으로 고려해 보겠습니다.

@seokho-son seokho-son added enhancement New feature or request wip working in progress (do not merge) and removed bug Something isn't working labels Jun 10, 2024
@powerkimhub
Copy link
Member

@dev4unet

  • 캄사합니다~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wip working in progress (do not merge)
Projects
None yet
Development

No branches or pull requests

4 participants