oracle / oci-go-sdk

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

Not able to run oci-go-sdk inside a kubernetes cluster #209

Closed PraveenViswanathan closed 4 years ago

PraveenViswanathan commented 4 years ago

We are trying to run a oci-go-sdk script inside a cluster to create a Resource Manager Stack in OCI but we are getting below error when running from the cluster. The same go code works in my local machine. As a platform independent language I expect oci-go-sdk to work the same way how it was working in my local mac. Could you please review the error and provide your suggestion whether any additional setups has to be done when we run it inside a kubernetes cluster. You can reach out to me via slack.

Creation of stack failed : panicked while retrying operation. Panic was: runtime error: invalid memory address or nil pointer dereference Stack: goroutine 10 [running]: github.com/oracle/oci-go-sdk/common.Retry.func1.1(0xc0001423c0) /go/pkg/mod/github.com/oracle/oci-go-sdk@v14.0.0+incompatible/common/retry.go:118 +0xb5 panic(0x7307c0, 0xa28d20) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/oracle/oci-go-sdk/common.BaseClient.CallWithDetails(0x0, 0x0, 0x0, 0x0, 0x0, 0xc00001cd30, 0x8, 0x79a792, 0x4, 0x0, ...) /go/pkg/mod/github.com/oracle/oci-go-sdk@v14.0.0+incompatible/common/client.go:284 +0x1d1 github.com/oracle/oci-go-sdk/common.BaseClient.Call(...) /go/pkg/mod/github.com/oracle/oci-go-sdk@v14.0.0+incompatible/common/client.go:263 github.com/oracle/oci-go-sdk/resourcemanager.ResourceManagerClient.createStack(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x79a792, 0x4, 0x0, ...) /go/pkg/mod/github.com/oracle/oci-go-sdk@v14.0.0+incompatible/resourcemanager/resourcemanager_client.go:237 +0x21b github.com/oracle/oci-go-sdk/common.Retry.func1(0xc0001423c0, 0x1, 0x7b4fc8, 0x7b4fd0, 0xc000124690, 0x816dc0, 0xc0000d6008, 0x8141c0, 0xc000096780, 0xc000

Note: Earlier I was getting "User agent can not be blank" error when I try to run create stack code inside kubernetes but in my local machine it was working fine. I had to add below line in my script to get past that step.

rmClient, _ := resourcemanager.NewResourceManagerClientWithConfigurationProvider(config) rmClient.UserAgent = "asdf"

buzhidao77 commented 4 years ago

@PraveenViswanathan the UserAgent is used to fill in the User-Agent header value and the common format contains product name, version, etc. By default, it'll try to collect some values from runtime: runtime.GOOS, runtime.GOARCH, runtime.Version()

I'm wondering if your kubernetes cluster environment has the environment for gosdk set up properly. If it is not able to get those values from runtime, GOSDK will report "user agent cannot be blank" error.

jhorwit2 commented 4 years ago

There's numerous folks using oci go sdk in Kubernetes clusters especially on OKE. This sounds like a problem with your build/setup when you deploy to k8s.

brusMX commented 4 years ago

I found the error for anyone chasing their tails. This issue comes from the GO version you are using. This SDK is using runtime that only exists in GO >=1.7

ZiyaoQiao commented 4 years ago

@PraveenViswanathan Please see the above discussion, I'm closing this issue as it's not related to our go sdk. If you still have any problem, feel free to reopen this and provide more info to us. Thanks

amikugup commented 3 years ago

@PraveenViswanathan , how did you solve this problem? Are you still getting this issue? I am also facing the same issue. This would be helpful if you can share some information regarding this.

Thanks in advance!

prabhakarp-dev commented 3 years ago

@amikugup , did you rootcause the issue? Could you please share the details?

bookmist commented 3 years ago

Try to set environment variable OCI_SDK_APPEND_USER_AGENT to any non-empty value. It helps me in a similar case.

ZiyaoQiao commented 3 years ago

@amikugup could you share more details? The GoSDK use UA template like this: SDK/SDKVersion (OS/OSVersion; Lang/LangVersion), please double check if your environment supports runtime.GOOS runtime.GOARCH runtime.Version()