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

Deploy failure when deploy account does not have direct permission #11

Open
truesilver92 opened this issue Jul 18, 2022 · 1 comment
Open

Comments

@truesilver92
Copy link

truesilver92 commented Jul 18, 2022

Beluga has deploy errors when deploying to portainer if the account being used has Administrator access instead of directly assigned permissions.

The error is a panic trying to access a nil map (probably list of endpoints the user has access to)

time="2022-07-16T00:40:37Z" level=info msg="response:
[{\"Id\":21,\"Name\":\"swarm-docker1\",\"Type\":2,\"URL\":\"tcp://swarm-docker1[masked url]:9001\",\"GroupId\":7,\"PublicURL\":\"swarm-docker1[masked url]\",\"TLSConfig\":{\"TLS\":true,\"TLSSkipVerify\":true},\"Extensions\":[],\"AzureCredentials\":{\"ApplicationID\":\"\",\"TenantID\":\"\",\"AuthenticationKey\":\"\"},\"TagIds\":[],\"Status\":1,\"Snapshots\":[{\"Time\":1657931868,\"DockerVersion\":\"20.10.17\",\"Swarm\":true,\"TotalCPU\":24,\"TotalMemory\":25022361600,\"RunningContainerCount\":21,\"StoppedContainerCount\":19,\"HealthyContainerCount\":3,\"UnhealthyContainerCount\":0,\"VolumeCount\":35,\"ImageCount\":49,\"ServiceCount\":20,\"StackCount\":5,\"DockerSnapshotRaw\":{\"Containers\":null,\"Volumes\":null,\"Networks\":null,\"Images\":null,\"Info\":null,\"Version\":null}}],\"UserAccessPolicies\":{},\"TeamAccessPolicies\":{},\"EdgeKey\":\"\",\"EdgeCheckinInterval\":0,\"Kubernetes\":{\"Snapshots\":[],\"Configuration\":{\"UseLoadBalancer\":false,\"UseServerMetrics\":false,\"StorageClasses\":[],\"IngressClasses\":[]}},\"ComposeSyntaxMaxVersion\":\"3.9\",\"AuthorizedUsers\":null,\"AuthorizedTeams\":null,\"Tags\":null},{\"Id\":23,\"Name\":\"swarm-docker2\",\"Type\":2,\"URL\":\"tcp://swarm-docker2[masked url]:9001\",\"GroupId\":7,\"PublicURL\":\"swarm-docker2[masked url]\",\"TLSConfig\":{\"TLS\":true,\"TLSSkipVerify\":true},\"Extensions\":[],\"AzureCredentials\":{\"ApplicationID\":\"\",\"TenantID\":\"\",\"AuthenticationKey\":\"\"},\"TagIds\":[],\"Status\":1,\"Snapshots\":[{\"Time\":1657931869,\"DockerVersion\":\"20.10.17\",\"Swarm\":true,\"TotalCPU\":24,\"TotalMemory\":25022361600,\"RunningContainerCount\":21,\"StoppedContainerCount\":19,\"HealthyContainerCount\":3,\"UnhealthyContainerCount\":0,\"VolumeCount\":35,\"ImageCount\":49,\"ServiceCount\":20,\"StackCount\":5,\"DockerSnapshotRaw\":{\"Containers\":null,\"Volumes\":null,\"Networks\":null,\"Images\":null,\"Info\":null,\"Version\":null}}],\"UserAccessPolicies\":{},\"TeamAccessPolicies\":{},\"EdgeKey\":\"\",\"EdgeCheckinInterval\":0,\"Kubernetes\":{\"Snapshots\":[],\"Configuration\":{\"UseLoadBalancer\":false,\"UseServerMetrics\":false,\"StorageClasses\":[],\"IngressClasses\":[]}},\"ComposeSyntaxMaxVersion\":\"3.9\",\"AuthorizedUsers\":null,\"AuthorizedTeams\":null,\"Tags\":null},{\"Id\":24,\"Name\":\"swarm-docker3\",\"Type\":2,\"URL\":\"tcp://swarm-docker3[masked url]:9001\",\"GroupId\":7,\"PublicURL\":\"swarm-docker3[masked url]\",\"TLSConfig\":{\"TLS\":true,\"TLSSkipVerify\":true},\"Extensions\":[],\"AzureCredentials\":{\"ApplicationID\":\"\",\"TenantID\":\"\",\"AuthenticationKey\":\"\"},\"TagIds\":[],\"Status\":1,\"Snapshots\":[{\"Time\":1657931869,\"DockerVersion\":\"20.10.17\",\"Swarm\":true,\"TotalCPU\":24,\"TotalMemory\":25022361600,\"RunningContainerCount\":21,\"StoppedContainerCount\":19,\"HealthyContainerCount\":3,\"UnhealthyContainerCount\":0,\"VolumeCount\":35,\"ImageCount\":49,\"ServiceCount\":20,\"StackCount\":5,\"DockerSnapshotRaw\":{\"Containers\":null,\"Volumes\":null,\"Networks\":null,\"Images\":null,\"Info\":null,\"Version\":null}}],\"UserAccessPolicies\":{},\"TeamAccessPolicies\":{},\"EdgeKey\":\"\",\"EdgeCheckinInterval\":0,\"Kubernetes\":{\"Snapshots\":[],\"Configuration\":{\"UseLoadBalancer\":false,\"UseServerMetrics\":false,\"StorageClasses\":[],\"IngressClasses\":[]}},\"ComposeSyntaxMaxVersion\":\"3.9\",\"AuthorizedUsers\":null,\"AuthorizedTeams\":null,\"Tags\":null}]\n"
time="2022-07-16T00:40:37Z" level=info msg="GET [masked portainer endpoint]"
panic: assignment to entry in nil map
goroutine 1 [running]:
github.com/duckbrain/beluga/internal/portainer.Env.UnmarshalJSON(0x0, 0xc00025233e, 0x9d, 0x7ac2, 0xc0005c6310, 0xc000252000)
	/code/internal/portainer/portainer_client.go:131 +0xfe
encoding/json.(*decodeState).array(0xc0005c62e8, 0x8f1300, 0xc0000d0250, 0x195, 0xc0005c6310, 0x5b)
	/usr/local/go/src/encoding/json/decode.go:503 +0xc10
encoding/json.(*decodeState).value(0xc0005c62e8, 0x8f1300, 0xc0000d0250, 0x195, 0x8f1300, 0xc0000d0250)
	/usr/local/go/src/encoding/json/decode.go:360 +0xfd
encoding/json.(*decodeState).object(0xc0005c62e8, 0x9112a0, 0xc0000d0230, 0x199, 0xc0005c6310, 0x7b)
	/usr/local/go/src/encoding/json/decode.go:765 +0x12e0
encoding/json.(*decodeState).value(0xc0005c62e8, 0x9112a0, 0xc0000d0230, 0x199, 0x9112a0, 0xc0000d0230)
	/usr/local/go/src/encoding/json/decode.go:370 +0x6d
encoding/json.(*decodeState).array(0xc0005c62e8, 0x89fa20, 0xc000564180, 0x16, 0xc0005c6310, 0x5b)
	/usr/local/go/src/encoding/json/decode.go:558 +0x1a7
encoding/json.(*decodeState).value(0xc0005c62e8, 0x89fa20, 0xc000564180, 0x16, 0xc000687240, 0x76e23e)
	/usr/local/go/src/encoding/json/decode.go:360 +0xfd
encoding/json.(*decodeState).unmarshal(0xc0005c62e8, 0x89fa20, 0xc000564180, 0x0, 0x1)
	/usr/local/go/src/encoding/json/decode.go:180 +0x1f0
encoding/json.(*Decoder).Decode(0xc0005c62c0, 0x89fa20, 0xc000564180, 0x7f8b21da4280, 0xc0000c26e0)
	/usr/local/go/src/encoding/json/stream.go:73 +0x166
github.com/duckbrain/beluga/internal/portainer.(*Client).do(0xc00011c240, 0x9489e9, 0x3, 0xc000028690, 0x2f, 0x8e0660, 0xc000582200, 0x0, 0x0, 0x89fa20, ...)
	/code/internal/portainer/portainer_client.go:186 +0x505
github.com/duckbrain/beluga/internal/portainer.(*Client).Stacks(0xc00011c240, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/code/internal/portainer/portainer_client.go:255 +0x174
github.com/duckbrain/beluga.(*portainerDeploy).findStack(0xc000110780, 0x18, 0xc0000252a0, 0xd, 0x0, 0x0, 0x0)
	/code/deployer.go:274 +0x58
github.com/duckbrain/beluga.(*portainerDeploy).Deploy.func1(0x18, 0xc000580142, 0xd, 0xc0005ca0a0, 0x18)
	/code/deployer.go:295 +0x8e
github.com/duckbrain/beluga.(*portainerDeploy).tryEndpoints(0xc000110780, 0xc000687ca8, 0x24, 0xc0002ee680)
	/code/deployer.go:264 +0x22d
github.com/duckbrain/beluga.(*portainerDeploy).Deploy(0xc000110780, 0x9f9a00, 0xc000024620, 0x9f4500, 0xc000114140, 0xc000110780, 0x4)
	/code/deployer.go:294 +0x1fc
github.com/duckbrain/beluga.(*Runner).Deploy(0xc000114140, 0x9f9a00, 0xc000024620, 0x0, 0x0)
	/code/runner.go:66 +0x8a
github.com/duckbrain/beluga/cmd.glob..func2(0xcca300, 0xd3bc40, 0x0, 0x0, 0x0, 0x0)
	/code/cmd/deploy.go:14 +0x45
github.com/spf13/cobra.(*Command).execute(0xcca300, 0xd3bc40, 0x0, 0x0, 0xcca300, 0xd3bc40)
	/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0xccad00, 0x4440fa, 0xcd3a80, 0xc000000180)
	/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
	/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/duckbrain/beluga/cmd.Execute()
	/code/cmd/root.go:42 +0x31
main.main()
	/code/cmd/beluga/main.go:6 +0x20
@truesilver92
Copy link
Author

Workaround for the issue is to directly assign access to endpoints to your deploy user account

duckbrain added a commit that referenced this issue Aug 9, 2022
…rtainer

#11 Fix nil map panic when unmarshalling environment variables from p…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant