libopenstorage / cloudops

Apache License 2.0
7 stars 13 forks source link

[PWX-35366][Oracle] Fixed DevicePath() API for Oracle cloud. #157

Closed vinayakshnd closed 10 months ago

vinayakshnd commented 10 months ago

What this PR does / why we need it: Currently, cloudops only looks at the first volumeattachment from list of volumeattachements for a given volume in order to get its device path. But in case of failovers, (ie. existing storage node is deleted), same volume gets attached to new node creating a new volumeattachment which exists along with old volumeattachment for old node (in DETACHED state).

With this new PR, cloudops will go through list of all volumeattachements for a given volume and will use volumeattachement obj that is in ATTACHED state to find out device path.

Which issue(s) this PR fixes (optional) Closes # https://portworx.atlassian.net/browse/PWX-35366

Special notes for your reviewer:

Scenario 1: When device is detached.

Screenshot 2023-12-13 at 7 13 59 PM
[opc@oke-cii3qdqu64q-nxlffs5mlra-sraq6gvhj3a-0 oracle]$ go test -v .
=== RUN   TestAll
    cloudops.go:336: 
                Error Trace:    /home/opc/go/src/github.com/libopenstorage/cloudops/oracle/cloudops.go:336
                                                        /home/opc/go/src/github.com/libopenstorage/cloudops/oracle/cloudops.go:59
                                                        /home/opc/go/src/github.com/libopenstorage/cloudops/oracle/oracle_test.go:49
                Error:          Received unexpected error:
                                Volume is detached
                Test:           TestAll
                Messages:       get device path returned error
--- FAIL: TestAll (0.11s)
FAIL
FAIL    github.com/libopenstorage/cloudops/oracle       0.118s
FAIL

Scenario 2: Device attached to an different instance (remote/ instance other than where code is running)

Screenshot 2023-12-13 at 7 17 19 PM
[opc@oke-cii3qdqu64q-nxlffs5mlra-sraq6gvhj3a-0 oracle]$ go test -v .
=== RUN   TestAll
    cloudops.go:336: 
                Error Trace:    /home/opc/go/src/github.com/libopenstorage/cloudops/oracle/cloudops.go:336
                                                        /home/opc/go/src/github.com/libopenstorage/cloudops/oracle/cloudops.go:59
                                                        /home/opc/go/src/github.com/libopenstorage/cloudops/oracle/oracle_test.go:49
                Error:          Received unexpected error:
                                Volume attached on "ocid1.instance.oc1.iad.anuwcljrxypu2kicvjypaug4uimrnqlr4jis7nwg2g6uj4ad2ua3vxp3fc7a" current instance "ocid1.instance.oc1.iad.anuwcljsxypu2kicdj2jz4qvep7sfarg5f5senbzqjlhca7gy7szol4sm3va"
                Test:           TestAll
                Messages:       get device path returned error
--- FAIL: TestAll (0.32s)
FAIL
FAIL    github.com/libopenstorage/cloudops/oracle       0.332s
FAIL

Scenario 3: Device attached on the same/local node where code is running.

Screenshot 2023-12-13 at 7 26 09 PM
[opc@oke-cii3qdqu64q-nxlffs5mlra-sraq6gvhj3a-0 oracle]$ go test -v .
=== RUN   TestAll
time="2023-12-13T13:54:15Z" level=info msg="disk: ocid1.volume.oc1.iad.abuwcljs3m3r5tudbxk5rdkeddni5bk47jrk66fn4jzdbin4lderucxfu4vq device path is: /dev/oracleoci/oraclevdb"
--- PASS: TestAll (0.10s)
PASS
ok      github.com/libopenstorage/cloudops/oracle       0.112s
[opc@oke-cii3qdqu64q-nxlffs5mlra-sraq6gvhj3a-0 oracle]$ 

Scenario 4: Device detached and re-attached with different path. Only the latest volumeattachment with updated devicepath reported.

Screenshot 2023-12-13 at 7 28 13 PM
[opc@oke-cii3qdqu64q-nxlffs5mlra-sraq6gvhj3a-0 oracle]$ go test -v .
=== RUN   TestAll
Running all oracle teststime="2023-12-13T13:59:14Z" level=info msg="Trying to get device path for ocid1.volume.oc1.iad.abuwcljs3m3r5tudbxk5rdkeddni5bk47jrk66fn4jzdbin4lderucxfu4vq\n"
time="2023-12-13T13:59:14Z" level=info msg="disk: ocid1.volume.oc1.iad.abuwcljs3m3r5tudbxk5rdkeddni5bk47jrk66fn4jzdbin4lderucxfu4vq device path is: /dev/oracleoci/oraclevdc"
--- PASS: TestAll (0.13s)
PASS
ok      github.com/libopenstorage/cloudops/oracle       0.146s
codecov-commenter commented 10 months ago

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (6dce65c) 8.10% compared to head (c669efd) 8.08%. Report is 2 commits behind head on master.

Files Patch % Lines
oracle/oracle.go 0.00% 24 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #157 +/- ## ========================================= - Coverage 8.10% 8.08% -0.02% ========================================= Files 18 18 Lines 4716 4727 +11 ========================================= Hits 382 382 - Misses 4312 4323 +11 Partials 22 22 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.