Giter Club home page Giter Club logo

cb-tumblebug's Introduction

CB-Tumblebug (Multi-Cloud Infra Management) 👋

Go Report Card Build Top Language GitHub go.mod Go version Repo Size GoDoc Swagger API Doc

Release Version Pre Release Version License Slack

All Contributors

CB-TB? ✨

CB-Tumblebug (CB-TB for short) is a system for managing multi-cloud infrastructure consisting of resources from multiple cloud service providers. (Cloud-Barista)


Note: Ongoing Development of CB-Tumblebug
CB-TB has not reached version 1.0 yet. We welcome any new suggestions, issues, opinions, and contributors!
Please note that the functionalities of Cloud-Barista are not yet stable or secure.
Be cautious if you plan to use the current release in a production environment.
If you encounter any difficulties using Cloud-Barista,
please let us know by opening an issue or joining the Cloud-Barista Slack.
Note: Localization and Globalization of CB-Tumblebug
As an open-source project initiated by Korean members,
we aim to encourage participation from Korean contributors during the initial stages of this project.
Therefore, the CB-TB repository will accept the use of the Korean language in its early stages.
However, we hope this project will thrive regardless of contributors' countries in the long run.
To facilitate this, the maintainers recommend using English at least for
the titles of Issues, Pull Requests, and Commits, while accommodating local languages in the contents.

Popular Use Case 🌟

  • Hot usecase of CB-Tumblebug
    • Deploy a Multi-Cloud Infra with GPUs and Enjoy muiltple LLMs in parallel (YouTube) Multi-Cloud LLMs in parallel
    • LLM-related scripts

Index 🔗

  1. Prerequisites
  2. How to Run
  3. How to Use
  4. How to Build
  5. How to Contribute

Prerequisites 🌍

Envionment

  • Linux (recommend: Ubuntu 22.04)
  • Docker and Docker Compose
  • Golang (recommend: v1.23.0) to build the source

Dependency

Open source packages used in this project


How to Run 🚀

(1) Download CB-Tumblebug

  • Clone the CB-Tumblebug repository:

    git clone https://github.com/cloud-barista/cb-tumblebug.git $HOME/go/src/github.com/cloud-barista/cb-tumblebug
    cd ~/go/src/github.com/cloud-barista/cb-tumblebug

    Optionally, you can register aliases for the CB-Tumblebug directory to simplify navigation:

    echo "alias cdtb='cd $HOME/go/src/github.com/cloud-barista/cb-tumblebug'" >> ~/.bashrc
    echo "alias cdtbsrc='cd $HOME/go/src/github.com/cloud-barista/cb-tumblebug/src'" >> ~/.bashrc
    echo "alias cdtbtest='cd $HOME/go/src/github.com/cloud-barista/cb-tumblebug/src/testclient/scripts'" >> ~/.bashrc
    source ~/.bashrc

(2) Run CB-TB and All Related Components

  • Check Docker Compose Installation:

    Ensure that Docker Engine and Docker Compose are installed on your system. If not, you can use the following script to install them (note: this script is not intended for production environments):

    cd ~/go/src/github.com/cloud-barista/cb-tumblebug
    ./scripts/installDocker.sh
  • Start All Components Using Docker Compose:

    To run all components, use the following command:

    cd ~/go/src/github.com/cloud-barista/cb-tumblebug
    sudo docker compose up

    This command will start all components as defined in the preconfigured docker-compose.yaml file. For configuration customization, please refer to the guide.

    The following components will be started:

    • ETCD: CB-Tumblebug KeyValue DB
    • CB-Spider: a Cloud API controller
    • CB-MapUI: a simple Map-based GUI web server
    • CB-Tumblebug: the system with API server

    image

    After running the command, you should see output similar to the following: image

    Now, the CB-Tumblebug API server is accessible at: http://localhost:1323/tumblebug/api Additionally, CB-MapUI is accessible at: http://localhost:1324

    Note: Before using CB-Tumblebug, you need to initialize it.


(3) Initialize CB-Tumblebug to configure Multi-Cloud info

To provisioning multi-cloud infrastructures with CB-TB, it is necessary to register the connection information (credentials) for clouds, as well as commonly used images and specifications.

  • Create credentials.yaml file and input your cloud credentials

    • Overview

      • credentials.yaml is a file that includes multiple credentials to use API of Clouds supported by CB-TB (AWS, GCP, AZURE, ALIBABA, etc.)
      • It should be located in the ~/.cloud-barista/ directory and securely managed.
      • Refer to the template.credentials.yaml for the template
    • Create credentials.yaml the file

      Automatically generate the credentials.yaml file in the ~/.cloud-barista/ directory using the CB-TB script

      cd ~/go/src/github.com/cloud-barista/cb-tumblebug
      ./init/genCredential.sh
    • Input credential data

      Put credential data to ~/.cloud-barista/credentials.yaml (Reference: How to obtain a credential for each CSP)

      ### Cloud credentials for credential holders (default: admin)
      credentialholder:
        admin:
          alibaba:
            # ClientId(ClientId): client ID of the EIAM application
            # Example: app_mkv7rgt4d7i4u7zqtzev2mxxxx
            ClientId:
            # ClientSecret(ClientSecret): client secret of the EIAM application
            # Example: CSEHDcHcrUKHw1CuxkJEHPveWRXBGqVqRsxxxx
            ClientSecret:
          aws:
            # ClientId(aws_access_key_id)
            # ex: AKIASSSSSSSSSSS56DJH
            ClientId:
            # ClientSecret(aws_secret_access_key)
            # ex: jrcy9y0Psejjfeosifj3/yxYcgadklwihjdljMIQ0
            ClientSecret:
          ...
      
  • Encrypt credentials.yaml into credentials.yaml.enc

    To protect sensitive information, credentials.yaml is not used directly. Instead, it must be encrypted using encCredential.sh. The encrypted file credentials.yaml.enc is then used by init.py. This approach ensures that sensitive credentials are not stored in plain text.

    • Encrypting Credentials
      init/encCredential.sh
      image

    If you need to update your credentials, decrypt the encrypted file using decCredential.sh, make the necessary changes to credentials.yaml, and then re-encrypt it.

    • Decrypting Credentials
      init/decCredential.sh
      image
  • (INIT) Register all multi-cloud connection information and common resources

    • How to register

      Refer to README.md for init.py, and execute the init.py script. (enter 'y' for confirmation prompts)

      cd ~/go/src/github.com/cloud-barista/cb-tumblebug
      ./init/init.sh
      • The credentials in ~/.cloud-barista/credentials.yaml.enc (encrypted file from the credentials.yaml) will be automatically registered (all CSP and region information recorded in cloudinfo.yaml will be automatically registered in the system)
        • Note: You can check the latest regions and zones of CSP using update-cloudinfo.py and review the file for updates. (contributions to updates are welcome)
      • Common images and specifications recorded in the cloudimage.csv and cloudspec.csv files in the assets directory will be automatically registered.

(4) Shutting down and Version Upgrade

  • Shutting down CB-TB and related components

    • Stop all containers by ctrl + c or type the command sudo docker compose stop / sudo docker compose down (When a shutdown event occurs to CB-TB, the system will be shutting down gracefully: API requests that can be processed within 10 seconds will be completed)

      image

    • In case of cleanup is needed due to internal system errors

      • Check and delete resources created through CB-TB
      • Delete CB-TB & CB-Spider metadata using the provided script
        cd ~/go/src/github.com/cloud-barista/cb-tumblebug
        ./init/cleanDB.sh
  • Upgrading the CB-TB & CB-Spider versions

    The following cleanup steps are unnecessary if you clearly understand the impact of the upgrade

    • Check and delete resources created through CB-TB
    • Delete CB-TB & CB-Spider metadata
      cd ~/go/src/github.com/cloud-barista/cb-tumblebug
      ./init/cleanDB.sh
    • Restart with the upgraded version

How to Use CB-TB Features 🌟

  1. Using CB-TB MapUI (recommended)
  2. Using CB-TB REST API (recommended)
  3. Using CB-TB Test Scripts

Using CB-TB MapUI

  • With CB-MapUI, you can create, view, and control Mutli-Cloud infra.
    • CB-MapUI is a project to visualize the deployment of MCI in a map GUI.
    • CB-MapUI also run with CB-Tumblebug by default (edit dockercompose.yaml to disable)
      • If you run the CB-MapUI container using the CB-TB script, excute
        cd ~/go/src/github.com/cloud-barista/cb-tumblebug
        ./scripts/runMapUI.sh
    • Access via web browser at http://{HostIP}:1324 image

Using CB-TB REST API


Using CB-TB Scripts

src/testclient/scripts/ provides Bash shell-based scripts that simplify and automate the MCI (MC-Infra) provisioning procedures, which require complex steps.

[Note] Details

Setup Test Environment

  1. Go to src/testclient/scripts/
  2. Configure conf.env
    • Provide basic test information such as CB-Spider and CB-TB server endpoints, cloud regions, test image names, test spec names, etc.
    • Much information for various cloud types has already been investigated and input, so it can be used without modification. (However, check for charges based on the specified spec)
  3. Configure testSet.env
    • Set the cloud and region configurations to be used for MCI provisioning in a file (you can change the existing testSet.env or copy and use it)
    • Specify the types of CSPs to combine
      • Change the number in NumCSP= to specify the total number of CSPs to combine
      • Specify the types of CSPs to combine by rearranging the lines in L15-L24 (use up to the number specified in NumCSP)
      • Example: To combine aws and alibaba, change NumCSP=2 and rearrange IndexAWS=$((++IX)), IndexAlibaba=$((++IX))
    • Specify the regions of the CSPs to combine
      • Go to each CSP setting item # AWS (Total: 21 Regions)
      • Specify the number of regions to configure in NumRegion[$IndexAWS]=2 (in the example, it is set to 2)
      • Set the desired regions by rearranging the lines of the region list (if NumRegion[$IndexAWS]=2, the top 2 listed regions will be selected)
    • Be aware!
      • Be aware that creating VMs on public CSPs such as AWS, GCP, Azure, etc. may incur charges.
      • With the default setting of testSet.env, TestClouds (TestCloud01, TestCloud02, TestCloud03) will be used to create mock VMs.
      • TestCloud01, TestCloud02, TestCloud03 are not real CSPs. They are used for testing purposes (do not support SSH into VM).
      • Anyway, please be aware of cloud usage costs when using public CSPs.

Integrated Tests

  • You can test the entire process at once by executing create-all.sh and clean-all.sh included in src/testclient/scripts/sequentialFullTest/

    └── sequentialFullTest # Automatic testing from cloud information registration to NS creation, MCIR creation, and MCI creation
        ├── check-test-config.sh # Check the multi-cloud infrastructure configuration specified in the current testSet
        ├── create-all.sh # Automatic testing from cloud information registration to NS creation, MCIR creation, and MCI creation
        ├── gen-sshKey.sh # Generate SSH key files to access MCI
        ├── command-mci.sh # Execute remote commands on the created MCI (multiple VMs)
        ├── deploy-nginx-mci.sh # Automatically deploy Nginx on the created MCI (multiple VMs)
        ├── create-mci-for-df.sh # Create MCI for hosting CB-Dragonfly
        ├── deploy-dragonfly-docker.sh # Automatically deploy CB-Dragonfly on MCI and set up the environment
        ├── clean-all.sh # Delete all objects in reverse order of creation
        ├── create-k8scluster-only.sh # Create a K8s cluster for the multi-cloud infrastructure specified in the testSet
        ├── get-k8scluster.sh # Get K8s cluster information for the multi-cloud infrastructure specified in the testSet
        ├── clean-k8scluster-only.sh # Delete the K8s cluster for the multi-cloud infrastructure specified in the testSet
        ├── force-clean-k8scluster-only.sh # Force delete the K8s cluster for the multi-cloud infrastructure specified in the testSet if deletion fails
        ├── add-k8snodegroup.sh # Add a new K8s node group to the created K8s cluster
        ├── remove-k8snodegroup.sh # Delete the newly created K8s node group in the K8s cluster
        ├── set-k8snodegroup-autoscaling.sh # Change the autoscaling setting of the created K8s node group to off
        ├── change-k8snodegroup-autoscalesize.sh # Change the autoscale size of the created K8s node group
        ├── deploy-weavescope-to-k8scluster.sh # Deploy weavescope to the created K8s cluster
        └── executionStatus # Logs of the tests performed (information is added when testAll is executed and removed when cleanAll is executed. You can check the ongoing tasks)
  • MCI Creation Test

    • ./create-all.sh -n shson -f ../testSetCustom.env # Create MCI with the cloud combination configured in ../testSetCustom.env

    • Automatically proceed with the process to check the MCI creation configuration specified in ../testSetCustom.env

    • Example of execution result

      Table: All VMs in the MCI : cb-shson
      
      ID              Status   PublicIP       PrivateIP      CloudType  CloudRegion     CreatedTime
      --              ------   --------       ---------      ---------  -----------     -----------
      aws-ap-southeast-1-0   Running  xx.250.xx.73   192.168.2.180  aws        ap-southeast-1  2021-09-17   14:59:30
      aws-ca-central-1-0   Running  x.97.xx.230    192.168.4.98   aws        ca-central-1    2021-09-17   14:59:58
      gcp-asia-east1-0  Running  xx.229.xxx.26  192.168.3.2    gcp        asia-east1      2021-09-17   14:59:42
      
      [DATE: 17/09/2021 15:00:00] [ElapsedTime: 49s (0m:49s)] [Command: ./create-mci-only.sh all 1 shson ../testSetCustom.env 1]
      
      [Executed Command List]
      [MCIR:aws-ap-southeast-1(28s)] create-mcir-ns-cloud.sh (MCIR) aws 1 shson ../testSetCustom.env
      [MCIR:aws-ca-central-1(34s)] create-mcir-ns-cloud.sh (MCIR) aws 2 shson ../testSetCustom.env
      [MCIR:gcp-asia-east1(93s)] create-mcir-ns-cloud.sh (MCIR) gcp 1 shson ../testSetCustom.env
      [MCI:cb-shsonvm4(19s+More)] create-mci-only.sh (MCI) all 1 shson ../testSetCustom.env
      
      [DATE: 17/09/2021 15:00:00] [ElapsedTime: 149s (2m:29s)] [Command: ./create-all.sh -n shson -f ../testSetCustom.env -x 1]
  • MCI Removal Test (Use the input parameters used in creation for deletion)

    • ./clean-all.sh -n shson -f ../testSetCustom.env # Perform removal of created resources according to ../testSetCustom.env
    • Be aware!
      • If you created MCI (VMs) for testing in public clouds, the VMs may incur charges.
      • You need to terminate MCI by using clean-all to avoid unexpected billing.
      • Anyway, please be aware of cloud usage costs when using public CSPs.
  • Generate MCI SSH access keys and access each VM

    • ./gen-sshKey.sh -n shson -f ../testSetCustom.env # Return access keys for all VMs configured in MCI

    • Example of execution result

      ...
      [GENERATED PRIVATE KEY (PEM, PPK)]
      [MCI INFO: mc-shson]
       [VMIP]: 13.212.254.59   [MCIID]: mc-shson   [VMID]: aws-ap-southeast-1-0
       ./sshkey-tmp/aws-ap-southeast-1-shson.pem
       ./sshkey-tmp/aws-ap-southeast-1-shson.ppk
       ...
      
      [SSH COMMAND EXAMPLE]
       [VMIP]: 13.212.254.59   [MCIID]: mc-shson   [VMID]: aws-ap-southeast-1-0
       ssh -i ./sshkey-tmp/aws-ap-southeast-1-shson.pem [email protected] -o StrictHostKeyChecking=no
       ...
       [VMIP]: 35.182.30.37   [MCIID]: mc-shson   [VMID]: aws-ca-central-1-0
       ssh -i ./sshkey-tmp/aws-ca-central-1-shson.pem [email protected] -o StrictHostKeyChecking=no
  • Verify MCI via SSH remote command execution

    • ./command-mci.sh -n shson -f ../testSetCustom.env # Execute IP and hostname retrieval for all VMs in MCI
  • K8s Cluster Test (WIP: Stability work in progress for each CSP)

    ./create-mcir-ns-cloud.sh -n tb -f ../testSet.env` # Create MCIR required for K8s cluster creation
    ./create-k8scluster-only.sh -n tb -f ../testSet.env -x 1 -z 1` # Create K8s cluster (-x maximum number of nodes, -z additional name for K8s node group and K8s cluster)
    ./get-k8scluster.sh -n tb -f ../testSet.env -z 1` # Get K8s cluster information
    ./add-k8snodegroup.sh -n tb -f ../testSet.env -x 1 -z 1` # Add a new K8s node group to the K8s cluster
    ./change-k8snodegroup-autoscalesize.sh -n tb -f ../testSet.env -x 1 -z 1` # Change the autoscale size of the specified K8s node group
    ./deploy-weavescope-to-k8scluster.sh -n tb -f ../testSet.env -y n` # Deploy weavescope to the created K8s cluster
    ./set-k8snodegroup-autoscaling.sh -n tb -f ../testSet.env -z 1` # Change the autoscaling setting of the new K8s node group to off
    ./remove-k8snodegroup.sh -n tb -f ../testSet.env -z 1` # Delete the newly created K8s node group
    ./clean-k8scluster-only.sh -n tb -f ../testSet.env -z 1` # Delete the created K8s cluster
    ./force-clean-k8scluster-only.sh -n tb -f ../testSet.env -z 1` # Force delete the created K8s cluster if deletion fails
    ./clean-mcir-ns-cloud.h -n tb -f ../testSet.env` # Delete the created MCIR

Multi-Cloud Infrastructure Use Cases

Deploying an MCI Xonotic (3D FPS) Game Server

Distributed Deployment of MCI Weave Scope Cluster Monitoring

Deploying MCI Jitsi Video Conferencing

Automatic Configuration of MCI Ansible Execution Environment


How to Build 🛠️

(1) Setup Prerequisites

  • Setup required tools

    • Install: git, gcc, make

      sudo apt update
      sudo apt install make gcc git
    • Install: Golang

      • Check https://golang.org/dl/ and setup Go

        • Download

          wget https://go.dev/dl/go1.23.0.linux-amd64.tar.gz;
          sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.23.0.linux-amd64.tar.gz
        • Setup environment

          echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.bashrc
          echo 'export GOPATH=$HOME/go' >> ~/.bashrc
          source ~/.bashrc
          echo $GOPATH
          go env
          go version

(2) Build and Run CB-Tumblebug

(2-1) Option 1: Run CB-Tumblebug with Docker Compose (Recommended)

  • Run Docker Compose with the build option

    To build the current CB-Tumblebug source code into a container image and run it along with the other containers, use the following command:

    cd ~/go/src/github.com/cloud-barista/cb-tumblebug
    sudo DOCKER_BUILDKIT=1 docker compose up --build

    This command will automatically build the CB-Tumblebug from the local source code and start it within a Docker container, along with any other necessary services as defined in the docker-compose.yml file. DOCKER_BUILDKIT=1 setting is used to speed up the build by using the go build cache technique.

(2-2) Option 2: Run CB-Tumblebug from the Makefile

  • Build the Golang source code using the Makefile

    cd ~/go/src/github.com/cloud-barista/cb-tumblebug/src
    make

    All dependencies will be downloaded automatically by Go.

    The initial build will take some time, but subsequent builds will be faster by the Go build cache.

    Note To update the Swagger API documentation, run make swag

  • Set environment variables required to run CB-TB (in another tab)

    • Check and configure the contents of cb-tumblebug/conf/setup.env (CB-TB environment variables, modify as needed)
      • Apply the environment variables to the system
        cd ~/go/src/github.com/cloud-barista/cb-tumblebug
        source conf/setup.env
      • (Optional) Automatically set the TB_SELF_ENDPOINT environment variable (an externally accessible address) using a script if needed
        • This is necessary if you want to access and control the Swagger API Dashboard from outside when CB-TB is running
        cd ~/go/src/github.com/cloud-barista/cb-tumblebug
        source ./scripts/setPublicIP.sh
  • Execute the built cb-tumblebug binary by using make run

    cd ~/go/src/github.com/cloud-barista/cb-tumblebug/src
    make run

How to Contribute 🙏

CB-TB welcomes improvements from both new and experienced contributors!

Check out CONTRIBUTING.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Seokho Son
Seokho Son

🚧 🤔 💻 👀
Jihoon Seo
Jihoon Seo

🚧 🤔 💻 👀
Yunkon (Alvin) Kim
Yunkon (Alvin) Kim

🤔 💻 👀 🚧
jmleefree
jmleefree

💻 👀
ByoungSeob Kim
ByoungSeob Kim

🤔
Sooyoung Kim
Sooyoung Kim

🐛 🤔
KANG DONG JAE
KANG DONG JAE

🤔
Youngwoo-Jung
Youngwoo-Jung

🤔
Sean Oh
Sean Oh

🤔
MZC-CSC
MZC-CSC

🐛 🤔
Eunsang
Eunsang

📓
hyokyungk
hyokyungk

📓
pjini
pjini

📓
sunmi
sunmi

📓
sglim
sglim

📖 💻
jangh-lee
jangh-lee

📖 💻
이도훈
이도훈

📖 💻
Park Beomsu
Park Beomsu

💻
Hassan Alsamahi
Hassan Alsamahi

💻
Taegeon An
Taegeon An

💻
INHYO
INHYO

💻
Modney
Modney

📖 💻
Seongbin Bernie Cho
Seongbin Bernie Cho

💻 📖
Gibaek Nam
Gibaek Nam

💻
Abidin Durdu
Abidin Durdu

💻
soyeon Park
soyeon Park

💻
Jayita Pramanik
Jayita Pramanik

📖
Mukul Kolpe
Mukul Kolpe

📖
EmmanuelMarianMat
EmmanuelMarianMat

💻
Carlos Felix
Carlos Felix

💻
Stuart Gilbert
Stuart Gilbert

💻
Ketan Deshmukh
Ketan Deshmukh

💻
Tríona Barrow
Tríona Barrow

💻
BamButz
BamButz

💻
dogfootman
dogfootman

📓
Okhee Lee
Okhee Lee

📓
joowon
joowon

📓
Sanghong Kim
Sanghong Kim

💻
Rohit Rajput
Rohit Rajput

💻
Arshad
Arshad

💻
Jongwoo Han
Jongwoo Han

💻
Yoo Jae-Sung
Yoo Jae-Sung

📓
Minhyeok LEE
Minhyeok LEE

👀
SungWoongz
SungWoongz

📓


License

FOSSA Status


cb-tumblebug's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cb-tumblebug's Issues

Need to extract core codes from rest api funcs to support gRPC

이슈

  • CB-Tumblebug은 현재 REST API를 통한 인터페이스만 제공하고 있으나, 향후 gRPC를 통한 제어도 지원하고자 합니다.

해결 방법

  • REST API 처리를 위한 API 리소스 함수에서 기능 함수 분리 및 재정의
  • REST API에 해당하는 gRPC를 위한 함수 생성

gRPC 컨트리뷰션 작업 소스코드 가이드라인

  • gRPC 서비스를 제공하기 위한 컨트리뷰션 가이드라인은 다음과 같습니다.
    • 일반적인 함수(리소스 오브젝트에 대한 CRUD)인 경우 #173 의 방식(네임스페이스에 대한 처리 완료)을 준용하여 REST 리소스 함수에서 기능 함수 분리
      • REST 리소스 함수 내용 정리 (기능에 관련된 코드 제거)
      • 기능에 관련된 코드를 신규 기능 함수로 생성
      • 일관성 유지를 위한 기능 함수의 명칭 수정 등 수행
    • 일반적인 함수가 아니고 REST 리소스 함수의 내용이 복잡하여, 기능 함수명을 특정하기 어려운 경우, 신규 기능 함수명에 임의의 prefix(core)를 추가 (예: func RestPostMcis 의 경우, 신규 생성 함수의 명칭은 func CorePostMcis 으로 지정
      • 해당 함수들의 명칭은 향후 업스트림에 머지 시 전체적으로 수정될 예정
    • 추가되는 함수 및 함수의 명칭 수정은 기존 .go 파일에서 작업 진행 (예: src/common/namespace.go 에 있는 func RestGetNs 를 정리하여 func GetNs를 신규 생성하는 경우 동일한 namespace.go 에 생성
    • 작업 대상 소스 (및 작업 순서)

gRPC 컨트리뷰션 워크플로우 가이드라인

Issues about MCIR Spec mgmt feature

  • 현재: Tumblebug 에서 Spec 을 등록하면 UUID 가 생성되어 UUID 로 관리되며, connectionName 필드도 있음
  • TODO: UUID 삭제, [connectionName 남겨놓거나, 또는 region 필드 추가], cspSpecID / cspSpecName 을 Identifier 로 사용
  • 고려해야 하는 사항: AWS 는 Region/AZ 별로 사용 가능한 flavor 가 다를 수 있음

  • 현재: RegisterSpecWithInfo API 제공, RegisterSpecWithID API (unstable) 제공
  • TODO: RegisterSpecWithID API 안정화, GetSpecInfo API 제공 (아니면, 이 기능을 Webtool 에서 제공하는 방안도 있음)

  • TODO: vCPU, RAM 등을 제시하면 조건을 만족하는 Spec 제시 (예: normalized weighted distance 기반)

TB 오브젝트 ID 생성 방식 변경 (UUID->사용자지정ID)

[개요]
TB 오브젝트 ID 생성 방식 변경 (UUID->사용자지정ID)

[현황]
TB는 오브젝트의 ID (예: MCIS ID)를 시스템이 생성한 UUID로 사용하고 있음.
오브젝트의 Name은 사용자가 지정하는 부가 정보로 사용함.
이 방식에는 장단점이 있으며, 선택의 문제임. 다만 아래의 단점을 고려하기로 함.

  • 주요 연동 프레임워크인 CB-Spider와 처리 방식에 일관성이 다소 떨어짐.
  • UUID는 사람이 인지하기 어려운 ID의 형태이며, 이에 의해 Test 등이 다소 까다로운 측면이 있음.

[수정방향] TB 오브젝트 ID 생성 방식을 변경 (UUID->사용자지정ID)

  • 기존 API 및 처리 방식은 유지하되, API Call시 사용자가 지정한 오브젝트의 Name을 기반으로 ID를 생성.
  • 오브젝트의 ID와 Name은 동일한 값을 가지게 됨. (예: Spec의 Name="goodSpec", ID="goodSpec")
  • 사용자는 오브젝트의 Name을 Namespace 내에서 유일한 값으로 사용해야 함. (예: SpecNameList:["spec1", "spec2", "spec3"]인 경우, Spec의 Name으로 "spec2"를 사용하면, 중복 오류를 리턴)

[수정방식]
GenUuid() 함수 코드 수정.

  • ID 중복 확인 로직 추가 (가능한 별도의 함수로 구성)
  • UUID 스트링 생성 주석 처리
  • Name을 ID로 리턴

Issues about MCIR Image mgmt feature

  • 현재: Tumblebug 에서 Image 를 등록하면 UUID 가 생성되어 UUID 로 관리되며, connectionName 필드도 있음
  • TODO: UUID 삭제, [connectionName 남겨놓거나, 또는 region 필드 추가], cspImageID / cspImageName 을 Identifier 로 사용
  • 고려해야 하는 사항: AWS 는 Region 별로 cspImageID (ami-xxxxxxxxx) 가 다름

  • 현재: RegisterImageWithInfo API 제공, RegisterImageWithID API (unstable) 제공
  • TODO: RegisterImageWithID API 안정화, GetImageInfo API 제공 (아니면, 이 기능을 Webtool 에서 제공하는 방안도 있음)

Spider 의 API 변경에 대한 대응

[JSON Array -> JSON Object]
cloud-barista/cb-spider#136

[관련 Spider REST API]

  • CloudOS

    • {"GET", "/cloudos", listCloudOS},
  • CIM (Cloud Info Mgmt)

    • {"GET", "/driver", listCloudDriver},
    • {"GET", "/credential", listCredential},
    • {"GET", "/region", listRegion},
    • {"GET", "/connectionconfig", listConnectionConfig},
  • VM Resources

    • {"GET", "/vmimage", listImage},
    • {"GET", "/vmspec/:RegionName", listVMSpec},
    • {"GET", "/vmorgspec/:RegionName", listOrgVMSpec},
    • {"GET", "/vnetwork", listVNetwork},
    • {"GET", "/securitygroup", listSecurity},
    • {"GET", "/keypair", listKey},
    • {"GET", "/vnic", listVNic},
    • {"GET", "/publicip", listPublicIP},
  • VM

    • {"GET", "/vm", listVM},
    • {"GET", "/vmstatus", listVMStatus},

[Added /spider/ prefix for REST APIs]
cloud-barista/cb-spider#139

Suggestion: Organize JSON field name

@seokho-son

Current valid JSON body of "Create MCIS" request: (from test/official/6.mcis/create-mcis.sh)

...
"vm": [ {
                        "name": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'-01",
                        "config_name": "'${CONN_CONFIG[$INDEX,$REGION]}'",
                        "image_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "ssh_key_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "spec_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "security_group_ids": [
                                "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'"
                        ],
                        "vnet_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "subnet_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "description": "description",
                        "vm_access_id": "cb-user",
                        "vm_access_passwd": ""
                },
...

Suggestion: (Other field name candidates are also welcome.)

As-is To-be
name -
config_name connectionName
image_id tbImageId or imageId
ssh_key_id tbSshKeyId or sshKeyId
spec_id tbSpecId or specId
security_group_ids tbSecurityGroupIds or securityGroupIds
vnet_id tbVNetId or vNetId
subnet_id tbSubnetId or subnetId
description -
vm_access_id vmUserAccount
vm_access_passwd vmUserPassword

FYI: CB-Spider, and CB-Tumblebug MCIR REST API uses camelCase for JSON field names.

  • cb-tumblebug/test/official/1.vNet/create-vNet.sh
{
                "name": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                "connectionName": "'${CONN_CONFIG[$INDEX,$REGION]}'",
                "cidrBlock": "192.168.0.0/16",
                "subnetInfoList": [ {
                        "Name": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "IPv4_CIDR": "192.168.1.0/24"
                } ]
        }
  • cb-tumblebug/test/official/2.securityGroup/create-securityGroup.sh
{
                "name": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                "connectionName": "'${CONN_CONFIG[$INDEX,$REGION]}'",
                "vNetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                "description": "test description",
                    "firewallRules": [
                            {
                                    "FromPort": "1",
                                    "ToPort": "65535",
                                    "IPProtocol": "tcp",
                                    "Direction": "inbound"
                            },
                                {
                                    "FromPort": "-1",
                                    "ToPort": "-1",
                                    "IPProtocol": "icmp",
                                    "Direction": "inbound"
                            }
                    ]
            }

Enhance source code tree and names

Let's enhance source code tree and names.

I suggest as follows,
cb-tumblebug/
----------------/README.md
----------------config/
------------------------setup.env
------------------------log_conf.yaml
------------------------store_conf.yaml
----------------doc/
----------------source/
------------------------apiserver.go (mcism_server.go)
------------------------common/
-----------------------------------utility.go (some common utilities in mcism_server.go)
-----------------------------------namespace.go (mcism_namespace.go)
------------------------mcir/
-------------------------------image.go (mcir_image.go)
-------------------------------spec.go (mcir_spec.go)
....
-------------------------------vnic.go (mcir_vnic.go)
------------------------mcism/
--------------------------------control.go (mcism_mcis.go)
--------------------------------(will be extende)

NS, MCIS emptiness check

#25 에서 이슈가 제기되었고
#28 PR을 통해
'삭제하려는 NS에 적어도 하나의 MCIS, Image, Network, SecurityGroup, Spec, SshKey, Subnet이 있으면 NS 삭제 실패를 리턴하는 로직' 을
delNs() 함수에 추가하였습니다.

이렇게 하니, 사용자가 '삭제하려는 NS에 적어도 하나의 MCIS, Image, Network, SecurityGroup, Spec, SshKey, Subnet이 있더라도 NS를 강제로 삭제' 할 수는 없는 상태입니다.

또한, delMcis() 함수는 #28 의 delNs() 함수와 다르게, 삭제하려는 MCIS 아래에 VM이 있으면 이를 Terminate & Delete 하고, 최종적으로 MCIS를 삭제하는 로직으로 작성되어 있습니다.


[Emptiness check 로직을 어디에 둘 것인가]

  • 1안: delNs() 함수와 같이 del**() 함수 안에 둔다
    • Webtool 등에서 restDelNs() / delNs() 함수만 호출해도 Emptiness check이 수행됨
    • 강제 삭제 함수는 없는 상태임 (필요 시 구현 가능)
    • 1안으로 결정되면, delMcis() 함수를 업데이트 해야 합니다.
  • 2안: del**() 함수 안에 두지 않는다
    • Webtool 등에서 restGetAllMcis, restGetAllImage, ... 등을 호출하여 Emptiness check을 수행하고, 통과되면 restDelNs() / delNs() 를 호출하여 실제로 삭제 (SEO 의견: 이렇게 하면 API call이 너무 많음)
    • del**() 함수 자체가 강제 삭제 함수의 역할을 함
    • 2안으로 결정되면 delNs() 함수를 업데이트 해야 합니다.

Issue: GCP does not accept upper case for resource name

@seokho-son @powerkimhub

일단은: Spider & TB 테스트 스크립트들에서, 리소스 이름을 소문자로만 사용하도록 변경되었습니다.

  • 리소스 이름에 underscore 를 넣으면 안 되는 CSP 도 있습니다.

향후:

  1. 사용자에게, 리소스 이름에 대문자를 넣지 말고 소문자로만 쓰라고 명시한다.
  2. 사용자가 제시한 리소스 이름에 대문자가 있는지 체크하는 로직을 웹도구에 넣는다.
    (문제점: 웹도구를 쓰지 않고 Spider & TB 에 직접 API call 을 날리는 경우가 있을 수도 있음)
  3. 사용자가 제시한 리소스 이름에 대문자가 있는지 체크하는 로직을 Spider & TB 에 넣는다.
  4. ...

TODO: Forbid deleting NS/MCIS

  1. Forbid deleting NS when there is at least one MCIS or one of resources.

  2. Forbid deleting MCIS when there is at least one VM.

Suggestion: Organize paths of core code files

As-is:
in cb-tumblebug/src

❯ tree -h
├── [4.0K]  api/
├── [4.0K]  cli/
├── [4.0K]  common/
├── [ 156]  Makefile
├── [4.0K]  mcir/
├── [4.0K]  mcis/
├── [3.2K]  mcism.go
├── [4.0K]  resource/
│   └── [5.5K]  cloudlocation.csv
└── [4.0K]  webadmin/

To-be:

❯ tree -h
├── [4.0K]  api/
├── [4.0K]  cli/
├── [4.0K]  core/
│   └── [4.0K]  common/
│   └── [4.0K]  mcir/
│   └── [4.0K]  mcis/
├── [ 156]  Makefile
├── [3.2K]  mcism.go
├── [4.0K]  resource/
│   └── [5.5K]  cloudlocation.csv
└── [4.0K]  webadmin/

For reference:
in cb-tumblebug/src/api/rest

❯ tree -h
└── [4.0K]  server
    ├── [4.0K]  common
    │   ├── [3.9K]  namespace.go
    │   └── [1.4K]  utility.go
    ├── [4.0K]  mcir
    │   ├── [6.7K]  common.go
    │   ├── [3.6K]  image.go
    │   ├── [3.7K]  securitygroup.go
    │   ├── [6.5K]  spec.go
    │   ├── [3.7K]  sshkey.go
    │   └── [3.4K]  vnet.go
    ├── [4.0K]  mcis
    │   ├── [ 24K]  control.go
    │   └── [1.2K]  utility.go
    └── [ 10K]  server.go

TODO: Organize paths of gRPC server code files

@jmleefree
gRPC 작업하실 때, 아래 사항도 함께 작업해 주시면 감사하겠습니다.


in cb-tumblebug/src/api/grpc/server

As-is:

❯ tree -h
├── [4.2K]  image.go
├── [3.5K]  namespace.go
├── [ 978]  server.go
└── [4.2K]  spec.go

To-be:

❯ tree -h
├── [4.0K]  common
│   ├── [3.9K]  namespace.go
│   └── [1.4K]  utility.go
├── [4.0K]  mcir
│   ├── [6.7K]  common.go
│   ├── [3.6K]  image.go
│   ├── [3.7K]  securitygroup.go
│   ├── [6.5K]  spec.go
│   ├── [3.7K]  sshkey.go
│   └── [3.4K]  vnet.go
├── [4.0K]  mcis
│   ├── [ 24K]  control.go
│   └── [1.2K]  utility.go
└── [ 10K]  server.go

For reference:
in cb-tumblebug/src/api/rest/server

❯ tree -h
├── [4.0K]  common
│   ├── [3.9K]  namespace.go
│   └── [1.4K]  utility.go
├── [4.0K]  mcir
│   ├── [6.7K]  common.go
│   ├── [3.6K]  image.go
│   ├── [3.7K]  securitygroup.go
│   ├── [6.5K]  spec.go
│   ├── [3.7K]  sshkey.go
│   └── [3.4K]  vnet.go
├── [4.0K]  mcis
│   ├── [ 24K]  control.go
│   └── [1.2K]  utility.go
└── [ 10K]  server.go

Need to determine a database(s) for Spec and Image objects

@seokho-son
현재, Spec 에 대해서는 MySQL 도입이 확정되었습니다.
검색 등의 기능을 고려하면 Image 도 같은 상황 같습니다.

위의 사항을 고려할 때

  • 1안: MySQL + K-V store 동시 저장
    consistency (정합성) 이슈, 불일치 시 롤백 이슈.. 등이 있을 수 있습니다.
    각 이슈/상황에 대한 로직을 넣어 해결할 수 있겠습니다.
  • 2안: K-V store 사용하지 않고 MySQL 만 사용
    이럴 경우, 다른 MCIR, MCIS, NS 등이 K-V store 를 사용하는 것과 배치/상충됩니다.
  • 3안: 모든 MCIR, MCIS, NS 에 대해 K-V store 대신 MySQL 사용하는 것으로 전환
    (이 안으로 선택될 확률은 낮을 것 같습니다.)

1안과 2안, 또는 다른 새로운 안에 대해 고민이 필요할 것 같습니다.

CB-Spider 의 connection_name 수신 방식 변경에 대한 대응

Spider 리모델링에 대한 대응

[2020-04-22 (수) 이메일]

  • 연결설정(ConnectionConfig) 등록: 기존 방법과 동일
  • 변경 인터페이스 및 Full 기능 시험 도구: 아래 내용 참조

<인터페이스/통합시험도구>

  • 위치: cb-spider/api-runtime/rest-runtime/test/full-test/*

  • 1.aws-test.sh: 통합 시험 완료 --> TB AWS로 통합 시작

    • 1.aws-test.sh 내부: 연결설정이름과 이미지이름 설정
    • 실행: 특별한 에러 메시지가 출력 없으면, AWS 기반 현재 CB-Spider full 기능 성공
    • CB-Spider REST API 및 예시: ./full_test.sh 내용 참조
  • 2.azure-test.sh: 현재 디버깅 중

    • 연결설정 및 이미지 설정 외에 AWS와 동일

<이슈/계획>

  • Azure 통합 디버깅
  • New Driver 통합 시험: OpenStack --> GCP --> Alibaba
  • IID Meta 정보와 CSP 자원 불일치시 지원 방법(도구)
  • cblog 및 오류 메시지 refine
  • ROLLBACK 처리 보완 및 시험
  • 그외 주요 리모델링 추진

[2020-04-24 (금) 이메일]

<드라이버 리모델링(IID, VPC/Subnet 등) 추진 현황>

  1. Azure(이노): 통합시험 완료 (일부 수정 요청)
  2. AWS(메가): 통합시험 완료
  3. GCP(메가): 지연중 --> 차주 통합 예정(VMHandler 마감 처리 중)
  4. OpenStack(이노): 통합시험 완료 (일부 수정 요청)
  5. Alibaba(메가): 차주 통합 예정
  6. Cloudit(이노): 차주 통합 예정

Suggestion: Refine structs in MCIS codes

@seokho-son

MCIR 코드에서
예를 들어 image.go 를 보면


type SpiderImageReqInfo struct { // Spider
	ConnectionName string
	ReqInfo        ImageReqInfo
}

이것은 TB 가 Spider 에 API call 날릴 때 JSON body 를 만들기 위해 넣은 struct 입니다.
위 struct 를 Marshal 하여 JSON body 를 만듭니다.
=> 현재는 SpiderImageReqInfoWrapper 로 이름을 바꿨습니다.


type ImageReqInfo struct { // Spider
	//IId   IID 	// {NameId, SystemId}
	Name string
	// @todo
}

type ImageInfo struct { // Spider
	//IId     IID    // {NameId, SystemId}
	Name    string
	GuestOS string // Windows7, Ubuntu etc.
	Status  string // available, unavailable

	KeyValueList []common.KeyValue
}

ImageReqInfo 는 위의 SpiderImageReqInfo 에서 필요로 하고,
ImageInfo 는 Spider 의 응답을 Unmarshal 하기 위해 넣은 것입니다.
=> 현재는 SpiderImageReqInfo 는 사용하지 않고 있고,
ImageInfo -> SpiderImageInfo 로 이름을 바꿔서
Req unmarshal & Response unmarshal 에 공통으로 활용하고 있습니다.


type imageReq struct {
	//Id             string `json:"id"`
	Name           string `json:"name"`
	ConnectionName string `json:"connectionName"`
	CspImageId     string `json:"cspImageId"`
	CspImageName   string `json:"cspImageName"`
	//CreationDate   string `json:"creationDate"`
	Description string `json:"description"`
}

type imageInfo struct {
	Id             string            `json:"id"`
	Name           string            `json:"name"`
	ConnectionName string            `json:"connectionName"`
	CspImageId     string            `json:"cspImageId"`
	CspImageName   string            `json:"cspImageName"`
	CreationDate   string            `json:"creationDate"`
	Description    string            `json:"description"`
	GuestOS        string            `json:"guestOS"` // Windows7, Ubuntu etc.
	Status         string            `json:"status"`  // available, unavailable
	KeyValueList   []common.KeyValue `json:"keyValueList"`
}

imageReq 는 사용자가 TB 에 날리는 JSON body 를 Unmarshal 할 때에도 쓰이고,
func createSshKey(nsId string, u *sshKeyReq) (sshKeyInfo, int, []byte, error) { 등에도 쓰입니다.

imageInfo 는 TB Object 생성 결과를 API 로 내어 주기 위해 JSON 으로 Marshal 할 때에도 쓰이고,
func createSshKey(nsId string, u *sshKeyReq) (sshKeyInfo, int, []byte, error) { 등에도 쓰입니다.

=> 각각 TbImageReq, TbImageInfo 로 이름을 바꿨습니다.


위와 같이,
대문자로 시작하는 struct 는 Spider 와 통신하기 위해 넣은 것이며
소문자로 시작하는 struct 는 TB 에서 사용하기 위해 넣은 것입니다.


MCIS 코드에서도 비슷하게 되어 있는 것 같은데
좀 더 정리가 되었으면 좋겠고..
(예: 제가 올릴 예정인 PR 에서 vmCspViewInfo struct 를 주석처리 했습니다.)


struct 내 항목들, JSON 으로 나가는 항목들이
MCIR 코드에는 camelCase 로 되어 있고
MCIS 코드에는 snake_case 로 되어 있는 것도 있습니다.
통일감을 주는 방안도 있고, 그대로 두는 방안도 있겠습니다.

=> Resolved by Change snakeCase to camelCase in MCIS #490

Bug: Fail to delete vNet

GET {{tb_ip}}:{{tb_port}}/tumblebug/ns/{{ns_id}}/resources/vNet/{{cbNetworkId}}

[Response]

{
    "id": "VPC-01",
    "name": "VPC-01",
    "connectionName": "aws-us-east-1-config",
    "cspVNetId": "",
    "cspVNetName": "",
    "cidrBlock": "192.168.0.0/16",
    "subnetInfoList": [
        {
            "Name": "",
            "IPv4_CIDR": "192.168.1.0/24",
            "KeyValueList": [
                {
                    "Key": "VpcId",
                    "Value": "vpc-0c8f9e245d3720fd4"
                },
                {
                    "Key": "MapPublicIpOnLaunch",
                    "Value": "false"
                },
                {
                    "Key": "AvailableIpAddressCount",
                    "Value": "251"
                },
                {
                    "Key": "AvailabilityZone",
                    "Value": "us-east-1d"
                },
                {
                    "Key": "Status",
                    "Value": "pending"
                }
            ]
        }
    ],
    "description": "",
    "status": "",
    "keyValueList": null
}

DELETE {{tb_ip}}:{{tb_port}}/tumblebug/ns/{{ns_id}}/resources/vNet/{{cbNetworkId}}

[Response]

{
    "message": "Not Found"
}

Suggestion: Add `/tumblebug/` prefix for REST APIs

As-Is:

  • /ns
  • /ns/{ns_id}/mcis
  • ...

To-Be:

  • /tumblebug/ns
  • /tumblebug/ns/{ns_id}/mcis
  • ...

[사유]

  • API-GW 에서 지금은 각 API (/ns, /ns/{ns_id}/mcis, ...) 별로 rule 을 적고 있습니다.
  • 향후 http://api-gw:8000/tumblebug/* 로 오는 모든 요청을 http://cb-tumblebug:1323/* 로 보내고 싶습니다.
  • 예를 들어 API-GW 테스트 시 Tumblebug 에 API 요청할 때 1) Tumblebug 로 직접 보내기, 2) API-GW 로 보내기 를 계속 왔다갔다 해야 하는데, 이 때 Tumblebug API 도 /tumblebug/ (또는 /cb-tumblebug/) 로 시작하도록 통일되어 있으면, 테스트도 편리하고, 향후에도 편리할 것으로 예상됩니다.

  • 영향: Tumblebug API 를 이용하는 Dragonfly, Webtool 등도 Tumblebug API 변경에 대한 대응이 필요합니다.
  • 기타: Spider, Dragonfly, Webtool 등도 모두 이런 스타일로 갔으면 좋겠습니다.

TODO: Implement some functions

As-is:
There are some missing functions in:

  • mcism_namespace.go
  • mcism_mcis.go
  • mcism_resource_manage_image.go
  • mcism_resource_manage_network.go
  • mcism_resource_manage_securityGroup.go
  • mcism_resource_manage_spec.go
  • mcism_resource_manage_sshKey.go
  • mcism_resource_manage_subnet.go

e.g. mcism_resource_manage_image.go

REST-handling func Actual func
restDelAllImage - The logic is implemented in restDelAllImage function.
restDelImage delImage
restGetAllImage getImageList
restGetImage - The logic is implemented in restGetImage function.
restPostImage createImage, registerImage
restPutImage - e.g. modifyImageInfo() function might be needed or not.

Since there is no delAllImage() or getImage() function,
a user cannot delete all images or get image info using gRPC.


To-be:
e.g. mcism_resource_manage_image.go

REST-handling func Actual func
restDelAllImage delAllImage The logic is implemented in delAllImage function.
restDelImage delImage
restGetAllImage getImageList
restGetImage getImageInfo The logic is implemented in getImageInfo function.
restPostImage createImage, registerImage
restPutImage (modifyImageInfo) modifyImageInfo() function might be implemented or not.

Suggestion: Integrate struct pair xxxReq and xxxInfo

E.g.

As-is:

type NsReq struct {
	//Id          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type NsInfo struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

To-be:

type NsInfo struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

nutsdb dbpath issue

Related: cloud-barista/cb-spider@38e5537

File with issue: https://github.com/cloud-barista/cb-tumblebug/blob/master/conf/store_conf.yaml#L9

Currently:

  dbpath: "/home/son/go/src/github.com/cloud-barista/cb-tumblebug/meta_db/dat"

It was:
https://github.com/cloud-barista/cb-tumblebug/blame/edb245563594fbc2a080b82125247b2eaf584eb0/conf/store_conf.yaml#L9

  dbpath: "/root/go/src/github.com/cloud-barista/cb-tumblebug/meta_db/dat"

FYI:

  dbpath: "~/go/src/github.com/cloud-barista/cb-spider/meta_db/dat"

is not a good solution.

Suggestion: code separation by file

As-is:

[mcism_master.go]

  • struct definitions
    • vmReq
    • mcisReq
    • mcisInfo
    • vmInfo
    • vmStatusInfo
  • func apiServer()
  • func main()
  • func nsValidation()
  • func rest*Mcis()
  • func addVmToMcis
  • func updateVmInfo
  • func getMcisList
  • func getVmList
  • func delMcis
  • func createMcis
  • func createVm
  • func terminateMcis
  • func terminateVm
  • func genUuid()
  • func insertAgent
  • func getVmIp
  • func monitorVm

[mcism_resource_manage_image.go]

  • struct definitions
    • nsReq
    • nsInfo
    • imageReq
    • imageInfo
  • func rest*Ns()
  • func createNs
  • func getNsList
  • func delNs
  • func checkNs
  • func rest*Image()
  • func createImage
  • func registerImage
  • func getImageList
  • func delImage

To-be:

[mcism_main.go]

  • func apiServer()
  • func main()
  • func genUuid()

[mcism_namespace.go]

  • struct definitions
    • nsReq
    • nsInfo
  • func nsValidation()
  • func rest*Ns()
  • func createNs
  • func getNsList
  • func delNs
  • func checkNs

[mcism_mcis.go]

  • struct definitions
    • mcisReq
    • mcisInfo
    • vmReq
    • vmInfo
    • vmStatusInfo
  • func rest*Mcis()
  • func addVmToMcis
  • func updateVmInfo
  • func getMcisList
  • func getVmList
  • func delMcis
  • func createMcis
  • func createVm
  • func terminateMcis
  • func terminateVm
  • func insertAgent
  • func getVmIp
  • func monitorVm

[mcism_resource_manage_image.go]

  • struct definitions
    • imageReq
    • imageInfo
  • func rest*Image()
  • func createImage
  • func registerImage
  • func getImageList
  • func delImage

Info: JSON input/output of CreateMcis() will be changed

Ref: @dev4unet @jazmandorf (cb-webtool might need some updates)


As-is:

[Request]

...
"vm": [ {
                        "name": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'-01",
                        "config_name": "'${CONN_CONFIG[$INDEX,$REGION]}'",
                        "image_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "ssh_key_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "spec_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "security_group_ids": [
                                "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'"
                        ],
                        "vnet_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "subnet_id": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                        "description": "description",
                        "vm_access_id": "cb-user",
                        "vm_access_passwd": ""
                },
...

[Response]


To-be:

cb-tumblebug/test/official/6.mcis/create-mcis.sh aws 1 jhseo

[Request]

{
                "name": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
                "description": "Tumblebug Demo",
                "vm": [ {
                        "name": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'-01",
                        "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" : [
      {
         "vmBootDisk" : "/dev/sda1",
         "vmUserPassword" : "",
         "vmUserId" : "",
         "specId" : "aws-us-east-1-jhseo",
         "privateDNS" : "ip-192-168-1-33.ec2.internal",
         "publicIP" : "3.84.238.186",
         "region" : {
            "Region" : "us-east-1",
            "Zone" : "us-east-1e"
         },
         "connectionName" : "aws-us-east-1",
         "targetAction" : "None",
         "securityGroupIds" : [
            "aws-us-east-1-jhseo"
         ],
         "vmBlockDisk" : "/dev/sda1",
         "imageId" : "aws-us-east-1-jhseo",
         "vmUserAccount" : "",
         "sshKeyId" : "aws-us-east-1-jhseo",
         "publicDNS" : "",
         "cspViewVmDetail" : {
            "Name" : "",
            "VPCName" : "",
            "SecurityGroupIIds" : [
               {
                  "SystemId" : "sg-0d455f6e1e2327732",
                  "NameId" : "aws-us-east-1-jhseo"
               }
            ],
            "NetworkInterface" : "eni-attach-0c401cb286c87c54b",
            "ImageIId" : {
               "SystemId" : "ami-085925f297f89fce1",
               "NameId" : "ami-085925f297f89fce1"
            },
            "PrivateDNS" : "ip-192-168-1-33.ec2.internal",
            "ImageName" : "",
            "StartTime" : "2020-07-01T02:00:08Z",
            "PublicDNS" : "",
            "KeyValueList" : [
               {
                  "Value" : "running",
                  "Key" : "State"
               },
               {
                  "Value" : "x86_64",
                  "Key" : "Architecture"
               },
               {
                  "Value" : "vpc-0b3f0f47cffb47f40",
                  "Key" : "VpcId"
               },
               {
                  "Value" : "subnet-092a30316dfb67011",
                  "Key" : "SubnetId"
               },
               {
                  "Value" : "aws-us-east-1-jhseo",
                  "Key" : "KeyName"
               }
            ],
            "SecurityGroupNames" : null,
            "SubnetName" : "",
            "IId" : {
               "NameId" : "aws-us-east-1-jhseo-01",
               "SystemId" : "i-0007a4a800ead78a1"
            },
            "VMUserId" : "",
            "KeyPairIId" : {
               "SystemId" : "aws-us-east-1-jhseo",
               "NameId" : "aws-us-east-1-jhseo"
            },
            "SubnetIID" : {
               "SystemId" : "subnet-092a30316dfb67011",
               "NameId" : "aws-us-east-1-jhseo"
            },
            "VMBlockDisk" : "/dev/sda1",
            "VMSpecName" : "t2.micro",
            "KeyPairName" : "",
            "VMBootDisk" : "/dev/sda1",
            "PrivateIP" : "192.168.1.33",
            "VMUserPasswd" : "",
            "PublicIP" : "3.84.238.186",
            "Region" : {
               "Zone" : "us-east-1e",
               "Region" : "us-east-1"
            },
            "VpcIID" : {
               "SystemId" : "vpc-0b3f0f47cffb47f40",
               "NameId" : "aws-us-east-1-jhseo"
            }
         },
         "privateIP" : "192.168.1.33",
         "subnetId" : "aws-us-east-1-jhseo",
         "vmUserPasswd" : "",
         "vNetId" : "aws-us-east-1-jhseo",
         "description" : "description",
         "targetStatus" : "None",
         "name" : "aws-us-east-1-jhseo-01",
         "id" : "aws-us-east-1-jhseo-01",
         "status" : "Running",
         "location" : {
            "briefAddr" : "Virginia",
            "cloudType" : "aws",
            "latitude" : "38.1300",
            "longitude" : "-78.4500",
            "nativeRegion" : "us-east-1"
         }
      }
   ],
   "description" : "Tumblebug Demo",
   "name" : "aws-us-east-1-jhseo",
   "targetStatus" : "Running",
   "id" : "aws-us-east-1-jhseo",
   "targetAction" : "Create",
   "status" : "Running-(3/3)",
   "placement_algo" : ""
}

Need to apply goroutine for MCIS creation

Need to apply goroutine for MCIS creation

VM creations for MCIS creation are sequential. This reduces the speed of MCIS creation.
Need to make VM creations parallel.

Info: Go struct / JSON field name match table

Ref: #180

[VM Create Request flow]

TbVmReq struct TbVmInfo struct
(Name→) Id
Description Description
Status="Creating"
Name Name
ConnectionName ConnectionName
SpecId SpecId
ImageId ImageId
VNetId VNetId
SubnetId SubnetId
SecurityGroupIds SecurityGroupIds
SshKeyId SshKeyId
TbVmInfo JSON (#180) TbVmInfo struct Req to Spider
[struct = JSON]
name Name→ ReqInfo.Name
connectionName ConnectionName→ ConnectionName
specId SpecId→ (ReqInfo.VMSpecName)
imageId ImageId→ (ReqInfo.ImageName)
securityGroupIds SecurityGroupIds→ ReqInfo.SecurityGroupNames
vNetId VNetId→ ReqInfo.VPCName
subnetId SubnetId→ ReqInfo.SubnetName
sshKeyId SshKeyId→ ReqInfo.KeyPairName
vmUserAccount VmUserAccount→ ReqInfo.VMUserId
vmUserPassword VmUserPassword→ ReqInfo.VMUserPasswd
description Description (no Description)
Resp from Spider
[struct = JSON]
TbVmInfo struct TbVmInfo JSON
[Whole struct]→ CspViewVmDetail cspViewVmDetail
IId
(no ConnectionName)
VMSpecName
ImageIId
SecurityGroupIIds
VpcIID
SubnetIID
KeyPairIId
VMUserId→ VmUserAccount vmUserAccount
VMUserPasswd→ VmUserPassword vmUserPassword
StartTime
Region→ Region region
NetworkInterface
PublicIP→ PublicIP publicIP
PublicDNS→ PublicDNS publicDNS
PrivateIP→ PrivateIP privateIP
PrivateDNS→ PrivateDNS privateDNS
VMBootDisk→ VMBootDisk vmBootDisk
VMBlockDisk→ VMBlockDisk vmBlockDisk
KeyValueList
(no Description)

conf path issue

환경

  • Ubuntu 18.04
  • Golang 을 apt 로 설치 (apt install golang)

원인 1

  • Golang 을 apt 로 설치한다고 해서, $GOPATH 환경변수가 설정되는 것은 아님 ($GOROOT 도 마찬가지)

원인 2

  • conf/setup.env 에는
export CBSTORE_ROOT=$GOPATH/src/github.com/cloud-barista/cb-tumblebug
export CBLOG_ROOT=$GOPATH/src/github.com/cloud-barista/cb-tumblebug
export SPIDER_URL=http://localhost:1024

이렇게 되어 있음


재현 방법

$GOPATH 환경변수가 설정되어 있지 않은 상태에서

CB-Tumblebug 을 실행하기 위해
cd conf
source setup.env
cd ../src
make (= go build -o cb-tumblebug)
make run (= ./cb-tumblebug)
실행하면

error: open /src/github.com/cloud-barista/cb-tumblebug/conf/log_conf.yaml: no such file or directory

라고 나옴


우리는 다음 중 어떤 가정을 택할 것인가

  1. 사용자 컴퓨터에 $GOPATH 환경변수가 설정되어 있어야 CB-Tumblebug 실행 가능
    => 현재 코드를 수정하지 않아도 됨
    (=> CB-Tumblebug README.md$GOPATH 설정하는 내용을 추가했음:
    https://github.com/golang/go/wiki/SettingGOPATH 에 기재되어 있는 대로
    .bashrcexport GOPATH=$HOME/go 추가 후 shell 재시작)

  2. 사용자 컴퓨터에 $GOPATH 환경변수가 설정되어 있지 않아도 CB-Tumblebug 실행 가능
    => 수정 필요

수정 (안)

  • $HOME 환경변수는 설정되어 있을테니, $GOPATH 대신 $HOME/go 라고 기재
    • 문제점: $GOPATH$HOME/go 이 아닌 다른 곳으로 사용하고 있는 사용자가 있을 수도 있음
  • ...

Suggestion: Change MCIS funcs' params and returns

@seokho-son

발단:

func createMcis(nsId string, req *mcisReq) string {

check, _ := checkMcis(nsId, req.Name)

if check {
	//temp := mcisInfo{}
	//err := fmt.Errorf("The mcis " + req.Name + " already exists.")
	return ""
}

부분을 넣었더니
TB 가 오동작 합니다.
(API 호출 시 "Internal Server Error" 반환)

"" (빈 string) 을 리턴해서 그런 것으로 보입니다.

그런데 현재 함수의 리턴값이 string 하나만 있어서
에러 발생 시 에러가 발생했음을 모함수에 알려 줄 방법을 모르겠습니다.


  • 다음 함수들이
    sthReq 를 param 으로 받고
    sthInfo 를 return 하도록 하면
    직관적이지 않을까 합니다.
    • func createMcis(nsId string, req *mcisReq) string {
    • func createVm(nsId string, mcisId string, vmInfoData *vmInfo) error {

Call chain 이 다음과 같은데
에러 처리 로직이 필요합니다.
위의 사항들을 적용하면서 에러 처리 로직을 넣을 수도 있겠습니다.

  1. func RestPostMcis(c echo.Context) error {
  2. func createMcis(nsId string, req *mcisReq) string {
  3. func addVmToMcis(wg *sync.WaitGroup, nsId string, mcisId string, vmInfoData *vmInfo) error {
  4. func createVm(nsId string, mcisId string, vmInfoData *vmInfo) error {

Need a guideline for Localization and Globalization of CB-Tumblebug

We don't have a guideline for Localization and Globalization of CB-Tumblebug.

I would like to suggest the following guideline.


Localization and Globalization of CB-Tumblebug.

As an opensource project initiated by Korean members, we would like to promote participation of Korean contributors during initial stage of this project. So, CB-Tumblebug Repo will accept use of Korean language in its early stages.

On the other hand, we hope this project flourishes regardless of contributor's country eventually.
So, the maintainers recommend using English at least for the title of Issues, Pull Requests, and Commits, while CB-Tumblebug Repo accommodates local languages in the contents of them.


CB-Tumblebug의 현지화 및 세계화

한국인이 시작한 오픈 소스 프로젝트로서이 프로젝트의 초기 단계에 한국 기여자들의 참여를 촉진하고자합니다. 따라서 초기 단계의 CB-Tumblebug 저장소는 한국어 사용을 받아 들일 것입니다.

다른 한편으로, 우리는이 프로젝트가 기여자의 국가에 관계없이 번성하기를 희망합니다.
따라서 최소한 이슈, 풀 요청, 커밋에 대해서는 제목을 영어로 사용하는 것을 추천하며, 내용에는 현지 언어 사용을 수용할 것입니다.

Enhancements for MCIS and MCIR (backlog)

[근시일]

  • 파일 새로 만들기
    • mcism_resource_manage_publicIp.go
    • mcism_resource_manage_vNic.go
  • "csp": "aws" 로 되어 있는 부분을 "connectionName": "aws-connect01" 으로 변경
  • CSP 와 통신하는 부분이 farmoni 코드로 되어 있는데, 이를 Spider 에서 제공할 REST API 로 변경. HTTP client 는 "net/http" 사용. cb-spider/cloud-control-manager/cloud-driver/drivers/cloudit/client 참고. HTTP client 코드는 많이 쓰일 것이므로 모듈화를 잘 해놓는 것이 좋을 것임. Published Postman doc 에서 Go 코드를 얻을 수도 있음. Echo 를 client 로 사용할 수도 있음.

[추후]

  • (Spider 에서 interfaces_v2 가 완성되면) cb-spider/cloud-control-manager/cloud-driver/interfaces/new-resources 에 적혀 있는 struct 를 Tumblebug 에도 도입
  • Tumblebug 에서, Create-Delete 는 메타정보 추가/삭제 + CSP에 명령 이고, Register-Unregister 는 메타정보 추가/삭제만 하는 것임. Register-Unregister 는 Spider 에서는 처리하지 않을 것이고, Tumblebug 에서 처리해야 함
  • Spider 에서 CSP 에 있는 VM / 자원 전체를 긁어오지는 않을 것임. (CB 를 통하지 않고 만들어진 것도 있을 수 있어서.) Tumblebug 에서 메타정보를 보고 loop 을 돌려 긁어와야 할 것임.

[2019-10-17 추가]
TODO:
Support for

  • All files - KeyValueList []KeyValue
  • SecurityHandler.go
    • SecurityRules *[]SecurityRuleInfo
  • VMHandler.go
    • SecurityGroupIds []string
    • Region RegionInfo
  • VNicHandler.go
    • SecurityGroupIds []string

[2019-10-23 추가]
TODO:

Suggestion: Move RestXxx functions into src/api/rest

As-is:
RestXxx functions are in

  • src/common/namespace.go
  • src/common/utility.go
  • src/mcir/common.go
  • src/mcir/image.go
  • src/mcir/securitygroup.go
  • src/mcir/spec.go
  • src/mcir/sshkey.go
  • src/mcir/vnet.go
  • src/mcis/control.go
  • src/mcis/utility.go

To-be:
RestXxx functions are in

  • src/api/rest/xxx.go

Suggestion: `mcism` -> `cb-tumblebug`

https://github.com/cloud-barista/cb-tumblebug/blob/master/README.md
여기에 mcism 이라고 기술되어 있는데,
처음 보는 사람은 이것이 무엇을 가리키는 것인지 알기 어려울 수 있고, 직관성이 떨어집니다.

Related:
https://github.com/cloud-barista/cb-tumblebug/blob/master/src/Makefile
여기에도, build 결과물로 생성되는 바이너리의 파일명이 mcism 으로 되어 있습니다.

FYI:
https://github.com/cloud-barista/cb-tumblebug/blob/master/Dockerfile
여기에서는,

  • 임시로 생성되는 컨테이너 안의, 바이너리의 파일명
  • docker build 의 결과물인 컨테이너 이미지 안의, 바이너리의 파일명

cb-tumblebug 이라고 하였습니다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.