oracle / oci-go-sdk

Go SDK for Oracle Cloud Infrastructure
https://cloud.oracle.com/cloud-infrastructure
Other
177 stars 82 forks source link

issues with datasafe autonmous registration #208

Closed eugsim1 closed 4 years ago

eugsim1 commented 4 years ago

Hello this updated code for autonomous and datasafe works the api detects the state : ListAutoNomousRep, err := DataBaseClient.ListAutonomousDatabases(context.Background() , GetListAutonomousDatabasesRequest) if err != nil { fmt.Println("Error from ListAutoNomousRep", err) return }

fmt.Printf("Nb of records : %d\n", len(ListAutoNomousRep.Items)) for i, v:= range ListAutoNomousRep.Items { fmt.Printf("Autonomous Db[%d]: %s %d %d %s %s %s %s\n", i, v.DbName , v.CpuCoreCount, v.DataStorageSizeInTBs , v.LifecycleState , v.DisplayName , *v.DbVersion , v.DataSafeStatus ) }

this code fails : /// deregister datasafe / for , v:= range ListAutoNomousRep.Items { if ( v.DataSafeStatus == "REGISTERED" ) { DeregisterDSF :=database.DeregisterAutonomousDatabaseDataSafeRequest { AutonomousDatabaseId : v.Id, } , err := DataBaseClient.DeregisterAutonomousDatabaseDataSafe(context.Background(), DeregisterDSF) if err != nil { fmt.Println("Error from DeregisterAutonomousDatabaseDataSafe", err) return } } } /
i cant un register a registered datasafe autonomous the state of the registration is FAILED and i cant recover it back to the previous state.

Actually according to the spec the call has to be done by a local oci user which is having data_safe rights ... if i have created a local datasafe user lets say datasafe01 , with the password "Hello1234ADW!" can you please help me to understand how i have to make the correct call sequend to run the previous code ?

the failed code was run with the identity of and admin user for the tenant, the Dergister has to be run with the local user

Thanks Ps i m internal you can ping me on slack esimos

eugsim1 commented 4 years ago

Hi i used a configured datasafe user and i m getting the same failure

for _, v := range ListAutoNomousRep.Items {

    if v.LifecycleState == database.AutonomousDatabaseSummaryLifecycleStateAvailable {
        if ( v.DataSafeStatus == "NOT_REGISTERED" || v.DataSafeStatus == "FAILED" ) {
            RegisterDSF := database.RegisterAutonomousDatabaseDataSafeRequest{
                AutonomousDatabaseId: v.Id,
            }
            respRegisterAutonomousDatabaseDataSafe, err := DataBaseClient.RegisterAutonomousDatabaseDataSafe(context.Background(), RegisterDSF)
            if err != nil {
                fmt.Println("Error from RegisterAutonomousDatabaseDataSafe", err)
                return
            }

            fmt.Printf("resp details\n")
            fmt.Printf("RawResponse %s\n",  *respRegisterAutonomousDatabaseDataSafe.RawResponse)
            fmt.Printf("OpcWorkRequestId %s\n", *respRegisterAutonomousDatabaseDataSafe.OpcWorkRequestId )
            fmt.Printf("OpcRequestId %s\n",  *respRegisterAutonomousDatabaseDataSafe.OpcRequestId )

        }

    }
}

could you please explain how i cant get back the result of the async call ? on the first execution i dont have any results and the code simple exits thanks

eugsim1 commented 4 years ago

Nb of records : 2 Autonomous Db[0]: ebsadw0 1 1 UNAVAILABLE student0 NULL_VALUE NOT_REGISTERED Autonomous Db[1]: ebsadw1 1 1 AVAILABLE student1 18c FAILED resp details RawResponse Status 202 Accepted RawResponse StatusCode 202 RawResponse Proto HTTP/1.1 RawResponse Body &{%!s(func()=0x657be0) {} %!s(func() bool=0x6631a0)} RawResponse Request {POST https://database.eu-frankfurt-1.oraclecloud.com/20160918/autonomousDatabases/ocid1.autonomousdatabase.oc1.eu-frankfurt-1.abtheljrw2zzdezqngzt7v6cdglgs5njny5kwx4tqlu4mhzhxplthwtf4vjq/actions/registerDataSafe HTTP/1.1 %!s(int=1) %!s(int=1) map[Accept:[/] Authorization:[Signature version="1",headers="date (request-target) host content-length content-type x-content-sha256",keyId="ocid1.tenancy.oc1..aaaaaaaahe24eabqyiylme5zi2gpernbx7blo5vs3hkntxvlfvtzv2ciix5q/ocid1.user.oc1..aaaaaaaam3sh4zxweatc3k7zkgwijjc4koocackt7dblzzcthh66q4gi5asa/b2:40:7a:31:27:f9:e8:76:21:82:9c:d7:dd:4b:14:0e",algorithm="rsa-sha256",signature="txkTHlP00lE1hWrtYLqSVxzATP4B9Cmj8QijdZyrKDGOncg4huc+yU3yQwt3aJDASeX8dvKa0Hk6JH+cDe3TsZChHSyUngtZEQTM1F/9KE2TE07T2ga0TwyUUHWGw90zURlB1wZoqTyEIoIut8mrB/a2JSQhMMVpcIh6EKPtw/C2zBct6+4D0eHu6n2GxeuwzIRo4UP7Tjg+ZPYrZUx3V6hj99WNYOBn9K6yHunmfvxl36r2rXq1kNshkpKvaKAx45VXobgVLBu2EHus652BejSLv3hhebFeWyvYxJ6FMR+c//TdpspC+55qlZZMhBxTZ3fnjyFIHTMDSQrLRhzQuA=="] Content-Length:[0] Content-Type:[application/json] Date:[Wed, 18 Dec 2019 16:13:53 GMT] Opc-Client-Info:[Oracle-GoSDK/13.1.0] Opc-Request-Id:[fc8be3343eb6c2af0f66cd34345b76ef] User-Agent:[Oracle-GoSDK/13.1.0 (linux/amd64; go/go1.13.4)] X-Content-Sha256:[47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=]] %!s(func() (io.ReadCloser, error)=) %!s(int64=0) [] %!s(bool=false) map[] map[] %!s(multipart.Form=) map[] %!s(tls.ConnectionState=) %!s(<-chan struct {}=0xc000183c20) %!s(http.Response=) %!s(context.emptyCtx=0xc0000180a0)} RawResponse Request URL https://database.eu-frankfurt-1.oraclecloud.com/20160918/autonomousDatabases/ocid1.autonomousdatabase.oc1.eu-frankfurt-1.abtheljrw2zzdezqngzt7v6cdglgs5njny5kwx4tqlu4mhzhxplthwtf4vjq/actions/registerDataSafe Header field "Date", Value ["Wed, 18 Dec 2019 16:13:54 GMT"] Header field "Content-Type", Value ["application/octet-stream"] Header field "Content-Length", Value ["0"] Header field "Connection", Value ["keep-alive"] Header field "Opc-Request-Id", Value ["fc8be3343eb6c2af0f66cd34345b76ef/B22821D969D5D57231622DE27E2514DB/95644F27F131DEA7DE40E8D291E4D36A"] Header field "Opc-Work-Request-Id", Value ["ocid1.coreservicesworkrequest.oc1.eu-frankfurt-1.abtheljrhvbr5ijoeh2aktdyotxcforzx3exmxbggccqqbwscwkvcyfuavoa"] Header field "X-Content-Type-Options", Value ["nosniff"] Request field "Content-Length", Value ["0"] Request field "Opc-Request-Id", Value ["fc8be3343eb6c2af0f66cd34345b76ef"] Request field "Content-Type", Value ["application/json"] Request field "X-Content-Sha256", Value ["47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="] Request field "Authorization", Value ["Signature version=\"1\",headers=\"date (request-target) host content-length content-type x-content-sha256\",keyId=\"ocid1.tenancy.oc1..aaaaaaaahe24eabqyiylme5zi2gpernbx7blo5vs3hkntxvlfvtzv2ciix5q/ocid1.user.oc1..aaaaaaaam3sh4zxweatc3k7zkgwijjc4koocackt7dblzzcthh66q4gi5asa/b2:40:7a:31:27:f9:e8:76:21:82:9c:d7:dd:4b:14:0e\",algorithm=\"rsa-sha256\",signature=\"txkTHlP00lE1hWrtYLqSVxzATP4B9Cmj8QijdZyrKDGOncg4huc+yU3yQwt3aJDASeX8dvKa0Hk6JH+cDe3TsZChHSyUngtZEQTM1F/9KE2TE07T2ga0TwyUUHWGw90zURlB1wZoqTyEIoIut8mrB/a2JSQhMMVpcIh6EKPtw/C2zBct6+4D0eHu6n2GxeuwzIRo4UP7Tjg+ZPYrZUx3V6hj99WNYOBn9K6yHunmfvxl36r2rXq1kNshkpKvaKAx45VXobgVLBu2EHus652BejSLv3hhebFeWyvYxJ6FMR+c//TdpspC+55qlZZMhBxTZ3fnjyFIHTMDSQrLRhzQuA==\""] Request field "Date", Value ["Wed, 18 Dec 2019 16:13:53 GMT"] Request field "Opc-Client-Info", Value ["Oracle-GoSDK/13.1.0"] Request field "Accept", Value ["/"] Request field "User-Agent", Value ["Oracle-GoSDK/13.1.0 (linux/amd64; go/go1.13.4)"]

OpcWorkRequestId ocid1.coreservicesworkrequest.oc1.eu-frankfurt-1.abtheljrhvbr5ijoeh2aktdyotxcforzx3exmxbggccqqbwscwkvcyfuavoa OpcRequestId fc8be3343eb6c2af0f66cd34345b76ef/B22821D969D5D57231622DE27E2514DB/95644F27F131DEA7DE40E8D291E4D36A

this is a more detailed output i cant find the REST API =>https://database.eu-frankfurt-1.oraclecloud.com/20160918/autonomousDatabases/ocid1.autonomousdatabase.oc1.eu-frankfurt-1.abtheljrw2zzdezqngzt7v6cdglgs5njny5kwx4tqlu4mhzhxplthwtf4vjq/actions/registerDataSafe ... can you please help ?

eugsim1 commented 4 years ago

Hi actually the issue is related to an internal error on the adw database for some reason the adw which is created from terraform is using an old name of and adw which was dropped and recreated withour been properly deregistered every time that my terraform script was creating the adw from scratch then this issue was popping when i created a brand new name for my adw then the calls are working with out issues. However i would like to know how should i treat the return of the calls as these are asychronous in my code i have added a time.sleep but this is not clean can you please help on that ? Ping me on slack esimos thanks