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

Fix JSON unmarshaling error #432

Conversation

jihoon-seo
Copy link
Member

  • Resolves Error occurs in JSON unmarshaling #426
    • UpdateAssociatedObjectList 함수의 "delete" 파트에는 여전히 SJSON 을 사용하도록 두었습니다.
      UpdateAssociatedObjectList 함수의 "delete" 파트는 문제 없이 동작하고 있습니다.
  • 하지만, 다른 문제가 있습니다.
    이 PR로 업데이트되는 UpdateAssociatedObjectList 함수의 "add" 파트와 관련이 있습니다.

[문제에 대한 설명]
현재 test/official/sequentialFullTest/testAll-mcis-mcir-ns-cloud.sh 스크립트는
3개의 VM으로 구성되는 1개의 MCIS를 생성합니다.

❯ ./testAll-mcis-mcir-ns-cloud.sh mock 1 jhseo

...
      "targetStatus" : "None",
      "installMonAgent" : "no",
      "masterVmId" : "mock-seoul-jhseo-0",
      "masterIp" : "4.3.2.1",
      "status" : "Running-(3/3)",
      "name" : "mock-seoul-jhseo",
      "targetAction" : "None",
      "id" : "mock-seoul-jhseo"
   }
}

이 스크립트를 실행하면, 먼저

  • vNet
  • securityGroup
  • sshKey
  • image
  • spec

5종류의 CB-Tumblebug MCIR object 를 1개씩 생성하고,
이후 3개의 VM으로 구성되는 1개의 MCIS를 생성하면서
위에서 생성한 MCIR 들의 associatedObjectList 필드를 업데이트 합니다.

그러므로, associatedObjectList 필드에는 VM 3개의 key가 기록되어 있어야 정상입니다.

❯ ./list-image.sh

{
         "id" : "mock-seoul-jhseo",
         "name" : "mock-seoul-jhseo",
         "cspImageId" : "mock-vmimage-01",
         "associatedObjectList" : [
            "/ns/ns-01/mcis/mock-seoul-jhseo/vm/mock-seoul-jhseo-1",
            "/ns/ns-01/mcis/mock-seoul-jhseo/vm/mock-seoul-jhseo-2",
            "/ns/ns-01/mcis/mock-seoul-jhseo/vm/mock-seoul-jhseo-0"
         ],
         "guestOS" : "Ubuntu",
         "connectionName" : "mock-seoul",
         "keyValueList" : [
            {
               "Key" : "",
               "Value" : ""
            },
            {
               "Key" : "",
               "Value" : ""
            }
         ],
         "isAutoGenerated" : false,
         "description" : "Canonical, Ubuntu, 18.04 LTS, amd64 bionic"
      }
   ]
}

문제는, key가 3개 기록되는 경우도 있고, 간헐적으로 key가 2개 기록되는 경우도 있다는 것입니다.

❯ ./list-image.sh

{
   "image" : [
      {
         "guestOS" : "Ubuntu",
         "description" : "Canonical, Ubuntu, 18.04 LTS, amd64 bionic",
         "cspImageName" : "",
         "name" : "mock-seoul-jhseo",
         "connectionName" : "mock-seoul",
         "id" : "mock-seoul-jhseo",
         "cspImageId" : "mock-vmimage-01",
         "keyValueList" : [
            {
               "Value" : "",
               "Key" : ""
            },
            {
               "Value" : "",
               "Key" : ""
            }
         ],
         "associatedObjectList" : [
            "/ns/ns-01/mcis/mock-seoul-jhseo/vm/mock-seoul-jhseo-0",
            "/ns/ns-01/mcis/mock-seoul-jhseo/vm/mock-seoul-jhseo-2"
         ],
         "isAutoGenerated" : false
      }
   ]
}

[다른 회차]
❯ ./list-image.sh

{
   "image" : [
      {
         "cspImageName" : "",
         "cspImageId" : "mock-vmimage-01",
         "name" : "mock-seoul-jhseo",
         "associatedObjectList" : [
            "/ns/ns-01/mcis/mock-seoul-jhseo/vm/mock-seoul-jhseo-1",
            "/ns/ns-01/mcis/mock-seoul-jhseo/vm/mock-seoul-jhseo-2"
         ],
         "guestOS" : "Ubuntu",
         "keyValueList" : [
            {
               "Value" : "",
               "Key" : ""
            },
            {
               "Key" : "",
               "Value" : ""
            }
         ],
         "description" : "Canonical, Ubuntu, 18.04 LTS, amd64 bionic",
         "isAutoGenerated" : false,
         "connectionName" : "mock-seoul",
         "id" : "mock-seoul-jhseo"
      }
   ]
}

[추정]

  • CreateMcis 함수는 goroutine 을 사용하여 AddVmToMcis 함수를 실행합니다.
  • AddVmToMcis => CreateVm => UpdateAssociatedObjectList 의 콜체인이 있습니다.
  • UpdateAssociatedObjectList 의 "add" 부분 안에, associatedObjectList 리스트를 읽고 쓰는 동작이 있습니다.
  • 이 때, associatedObjectList 리스트에 대한 락이 없기 때문에, 이런 현상이 생기는 것으로 추정합니다.
    • 예: 거의 동시에 jhseo-0jhseo-1 을 기록하려고 하면,
      거의 동시에 UpdateAssociatedObjectList 함수가 실행되고,
      이 함수 인스턴스에서 associatedObjectList 리스트를 Key-Value store 에서 읽으면
      두 함수 인스턴스 모두에서 associatedObjectList 리스트가 비어 있는 것으로 나옴.
      두 함수 인스턴스가 각각 jhseo-0jhseo-1 을 기록하고 Key-Value store 에 저장하면,
      둘 중 빨리 수행된 쪽의 결과만 남게 됨

@jihoon-seo jihoon-seo changed the title Fix error on UpdateAssociatedObjectList() Fix JSON unmarshaling error Apr 1, 2021
@seokho-son
Copy link
Member

/lgtm

@github-actions github-actions bot added the lgtm This PR is acceptable by at least one reviewer label Apr 1, 2021
@seokho-son
Copy link
Member

/approve

@seokho-son seokho-son merged commit f7872f6 into cloud-barista:master Apr 1, 2021
@jihoon-seo jihoon-seo deleted the 210401-Fix-error-on-UpdateAssociatedObjectList branch October 22, 2021 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR is acceptable by at least one reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error occurs in JSON unmarshaling
2 participants