O-RAN SC에 오픈소스 기여를 해보자 3일차 - 리뷰 받기

0

opensource

목록 보기
3/6

지난 시간에 리뷰를 올린 이후로, 리뷰어께서 답변을 달아주셨다.


withness me!!

그러나 첫 review에 몇 가지 comment들이 달렸고 내용은 다음과 같았다.
https://gerrit.o-ran-sc.org/r/c/aiml-fw/awmf/modelmgmtservice/+/13217?tab=comments

  1. alpine image tag를 고정하도록 하자.
  2. image build 후에 정상 동작하는 지 확인하도록 하자.

뭔가 회사에서 받았던 리뷰와 다른 재미가 있는 것 같다.

1. Comments 확인하기

먼저 alpine image tag를 latest에서 특정 버전으로 고정하기로 하자.

  • Dockerfile
FROM alpine:3.20

현재 기준으로 가장 최신 tag으로 고정시켜주었다.

이제 image가 빌드되는 지 실행해보도록 하자.

sudo nerdctl run -d --name buildkitd --privileged moby/buildkit:latest

sudo buildctl --addr=nerdctl-container://buildkitd build \
    --frontend dockerfile.v0 \
    --opt filename=Dockerfile \
    --local dockerfile=modelmgmtservice \
    --local context=modelmgmtservice \
    --output type=oci,name=modelmgmtservice:1.0.3 | sudo nerdctl load --namespace k8s.io

다음의 script를 실행시켜주면 Dockerfile을 기반으로 image 빌드가 실행된다.

[+] Building 52.4s (17/17)                                                                                          
 => [builder 2/6] WORKDIR /home/app/                                                                           0.8s
[+] Building 52.5s (17/17) FINISHED   
...
 => => exporting config sha256:95f3bdbeea7c6910312775e4402d5dfdeebf512ee30d26e8cadfcfaa73e01707                0.0s
 => => sending tarball                                                                                         0.6s
Loaded image: modelmgmtservice:1.0.3

위와 같은 결과가 나왔다면 성공한 것이다.

실제로 image가 잘 빌드되었는 지 확인해보도록 하자.

sudo nerdctl images --namespace k8s.io | grep modelmgmtservice
...
modelmgmtservice                                                                 1.0.3                                              3b9a53de7b94    47 hours ago    linux/amd64    29.3 MiB     13.6 MiB

1.0.3이 빌드된 것을 볼 수 있다.

우리의 modelmgmtservice deployment의 image를 해당 image로 수정해주도록 하자.

sudo kubectl edit -n traininghost deployments.apps modelmgmtservice 

text editor가 열리고 image부분의 tag를 1.0.3으로만 바꾸면 된다. 자동으로 1.0.3 image가 적용된 pod가 재생성 될 것이다.

kubectl get po -n traininghost modelmgmtservice-5ccdd49cf8-mh6tq 
NAME                                READY   STATUS    RESTARTS   AGE
modelmgmtservice-5ccdd49cf8-mh6tq   1/1     Running   0          54s

정상 동작하는 것을 볼 수 있다.

이제 기능적으로도 정상 동작하는 지를 확인해보도록 하자.

  1. log file이 잘 남아있는 지 확인
  2. REST API가 잘 호출되는 지 확인

먼저 1번 log file이 잘 남아있는 지 확인해보도록 하자.

kubectl exec -it -n traininghost modelmgmtservice-5ccdd49cf8-mh6tq -- cat mmes.log
INFO:2024/07/31 13:08:35 Loggers loaded ..
INFO:2024/07/31 13:08:35 Creating single instance for S3Manager
INFO:2024/07/31 13:08:35 Starting api..

문제없이 남아있다.

다음으로 REST API를 호출하여 잘 동작하는 지 알아보도록 하자. code로 하나하나 보긴 귀찮으므로, GIN으로 동작하는 경우 시작 로그에 REST API들이 무엇이 있는 지 알려준다. 따라서, pod의 stdout log를 보도록 하자.

kubectl logs -n traininghost modelmgmtservice-5ccdd49cf8-mh6tq 
...

[GIN-debug] POST   /registerModel            --> gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/apis.(*MmeApiHandler).RegisterModel-fm (3 handlers)
[GIN-debug] GET    /getModelInfo             --> gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/apis.(*MmeApiHandler).GetModelInfo-fm (3 handlers)
[GIN-debug] GET    /getModelInfo/:modelName  --> gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/apis.(*MmeApiHandler).GetModelInfoByName-fm (3 handlers)
[GIN-debug] POST   /uploadModel/:modelName   --> gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/apis.(*MmeApiHandler).UploadModel-fm (3 handlers)
[GIN-debug] GET    /downloadModel/:modelName/model.zip --> gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/apis.(*MmeApiHandler).DownloadModel-fm (3 handlers)

먼저 POST /registerModel을 호출하여 model을 만들도록 하자.

curl --location 'http://localhost:32006/registerModel' \
      --header 'Content-Type: application/json' \
      --data '{
         "model-name":"qoe3",
         "rapp-id": "rapp_4",
         "meta-info" :
         {
             "accuracy":"90",
             "model-type":"timeseries",
             "feature-list":["pdcpBytesDl","pdcpBytesUl"]
         }
      }' -v
      
...
< HTTP/1.1 201 Created
< Content-Type: application/json; charset=utf-8
< Date: Wed, 31 Jul 2024 13:14:10 GMT
< Content-Length: 54
< 
* Connection #0 to host localhost left intact
{"code":201,"message":"Model registered successfully"}

201 Created가 나왔다. 응답 msg들도 성공한 것으로 보인다.

다음으로 GET /getModelInfo/:modelName으로 우리의 qoe3 model을 가져와보자.

curl http://localhost:32006/getModelInfo/qoe3

{"code":200,"message":"{\"model-name\":\"qoe3\",\"rapp-id\":\"rapp_4\",\"meta-info\":{\"accuracy\":\"90\",\"feature-list\":[\"pdcpBytesDl\",\"pdcpBytesUl\"],\"model-type\":\"timeseries\"}}"}

성공하였다!!

마지막으로 우리의 golang binary가 정말 container안에 있는 지 알아보도록 하자.

  • Dockerfile
COPY --from=builder /home/app/mme_bin .

#Start the app
ENTRYPOINT ["/app/mme_bin"]

mme_bin으로 golang binary가 만들어졌으므로, exec 명령어로 확인하면 된다.

ubectl exec -it -n traininghost modelmgmtservice-5ccdd49cf8-mh6tq -- ls
mme_bin   mmes.log

mme_bin가 있으므로, 성공이다. 추가적으로 ps명령어로 process가 동작 중인지 확인해보도록 하자.

kubectl exec -it -n traininghost modelmgmtservice-5ccdd49cf8-mh6tq -- ps aux
PID   USER     TIME  COMMAND
    1 root      0:00 /app/mme_bin
   68 root      0:00 ps aux

PID 1번으로 잘 동작하고 있는 것을 확인하였다. 이제 comment에 대한 내용들을 모두 확인하였으므로, review를 새로 작성해보도록 하자.

2. Review 다시 올리기


그런데, 예상하지 못한 점이 하나있다.

git의 경우는 어차피 다시 git commit하여 pull request를 올려주면 된다. 그러면 이전 pull request에 commit이 포함되어 적용되는 방식이다.

그런데, gerrit은 과연 그럴까??

https://squarelab.co/blog/git-gerrit-review-demo/
https://d2.naver.com/helloworld/9767525

확인해보니 몇 가지 경우들에 따라 다르게 review를 다시올려야하는데, 가령 필자의 경우는 앞선 commit들이 따로 없기 때문에, 굳이 rebase를 하지 않아도 된다.

즉, 정리해보면

(commit1) --> (다시 review할 commit) --> (commit2) --> (commit3)

이 경우에 '다시 review할 commit'으로 rebase시켜 review를 다시 올리면 된다고 한다.

필자의 경우는 다음과 같은데,

(commit1) --> (commit2) --> (다시 review할 commit)

이 경우는 rebase할 것도 없으므로, git commit --amend로 수정하면 된다. 그러면 change-id는 동일하고 새로운 commit이 생겨 review가 반영되는 것이다. 단, 이전의 commit id는 사라지만, 이전 반영 내용은 그대로 남아있다.

먼저 git status로 확인해보자.

git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   Dockerfile

no changes added to commit (use "git add" and/or "git commit -a")

alpine:3.20이 working directory에 반영된 것을 볼 수 있다.

이제 staging area로 보내버리자.

git add ./Dockerfile

git status

On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   Dockerfile

반영된 것을 확인할 수 있다.

이제 새로운 commit은 만들되 change-id는 건드리지 말아야한다. 따라서 git commit --amend를 사용하도록 하자.

git commit --amend

반영한 내용을 commit에 추가해주도록 하자.

마지막으로 한 번 더 확인해보도록 하자. commit들을 확인하여 change-id는 그대로이고, commit은 새로 생겼는 지 보면 된다.

git log

commit 76cdfd05482b9fbf9cd30c396df809e28f047d40 (HEAD -> master)
Author: gyuyoung <gyoue200125@gmail.com>
Date:   Mon Jul 29 22:36:38 2024 +0900

    Reduce image size of modelmgmtservice
    
    - Updated stage1 to build modelmgmtservice golang binary
    - Added stage2 to run modelmgmtservice golang binary with compact
      environment
    - Change alpine tag from 'latest' to '3.20' for fixing development environment
    
    Issue-ID: AIMLFW-116
    
    Change-Id: Idce95bef25c4505f0edb0a810bfebdc96b89283a
    Signed-off-by: gyuyoung <gyoue200125@gmail.com>
...

Idce95bef25c4505f0edb0a810bfebdc96b89283a은 동일하고, commit id는 이전과 달라진 것을 확인하도록 하자.

이제 올리도록 하자.

git review

remote: 
remote: Processing changes: (\)        
remote: Processing changes: refs: 1, updated: 1 (\)        
remote: Processing changes: refs: 1, updated: 1, done            
remote: 
remote: SUCCESS        
remote: 
remote:   https://gerrit.o-ran-sc.org/r/c/aiml-fw/awmf/modelmgmtservice/+/13217 Reduce image size of modelmgmtservice        
remote: 
remote: The following approvals got outdated and were removed:        
remote: * Verified+1 by ORAN Jobbuilder        
remote: * Verified+1 by ORAN Required GHA        
remote: 
remote: 
To ssh://gerrit.o-ran-sc.org:29418/aiml-fw/awmf/modelmgmtservice
 * [new reference]   HEAD -> refs/for/master

성공하였고, 반영되었는 지 gerrit을 통해 확인하자.
https://gerrit.o-ran-sc.org/r/c/aiml-fw/awmf/modelmgmtservice/+/13217

이번엔... 되겠지?!

0개의 댓글