openfaas / faas-cli

Official CLI for OpenFaaS
https://www.openfaas.com/
Other
794 stars 226 forks source link

Error updating secrets #599

Closed padiazg closed 4 years ago

padiazg commented 5 years ago

We tried to update one secret that is used by 14 functions, but we get error 502.

# faas-cli secret update bonus-helper-secret-1 --from-file=config_produccion.json

Expected Behaviour

A successful update to the secret

Current Behaviour

We get server returned unexpected status code: 502.

This is the log from func_faas-swarm:

func_faas-swarm.1.0v8o3foxei7o@docker03    | updateSecretErr
func_faas-swarm.1.0v8o3foxei7o@docker03    |  Error response from daemon: rpc error: code = InvalidArgument desc = only updates to Labels are allowed
func_faas-swarm.1.0v8o3foxei7o@docker03    | 2019/01/29 17:52:12 http: panic serving 10.0.0.172:44428: runtime error: invalid memory address or nil pointer dereference
func_faas-swarm.1.0v8o3foxei7o@docker03    | goroutine 13003 [running]:
func_faas-swarm.1.0v8o3foxei7o@docker03    | net/http.(*conn).serve.func1(0xc420084c80)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /usr/local/go/src/net/http/server.go:1726 +0xd0
func_faas-swarm.1.0v8o3foxei7o@docker03    | panic(0x7faea0, 0xacc0c0)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /usr/local/go/src/runtime/panic.go:502 +0x229
func_faas-swarm.1.0v8o3foxei7o@docker03    | github.com/openfaas/faas-swarm/handlers.updateSecret(0xc42031e280, 0xc4202bf000, 0x438, 0xe00, 0x0, 0x0, 0x0, 0x10, 0x7d6360, 0xc420324550)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /go/src/github.com/openfaas/faas-swarm/handlers/secrets.go:221 +0x437
func_faas-swarm.1.0v8o3foxei7o@docker03    | github.com/openfaas/faas-swarm/handlers.MakeSecretsHandler.func1(0x8d1820, 0xc4204aa000, 0xc420196100)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /go/src/github.com/openfaas/faas-swarm/handlers/secrets.go:54 +0x349
func_faas-swarm.1.0v8o3foxei7o@docker03    | net/http.HandlerFunc.ServeHTTP(0xc42035e170, 0x8d1820, 0xc4204aa000, 0xc420196100)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /usr/local/go/src/net/http/server.go:1947 +0x44
func_faas-swarm.1.0v8o3foxei7o@docker03    | github.com/openfaas/faas-swarm/vendor/github.com/openfaas/faas-provider/auth.DecorateWithBasicAuth.func1(0x8d1820, 0xc4204aa000, 0xc420196100)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /go/src/github.com/openfaas/faas-swarm/vendor/github.com/openfaas/faas-provider/auth/basic_auth.go:24 +0x20c
func_faas-swarm.1.0v8o3foxei7o@docker03    | net/http.HandlerFunc.ServeHTTP(0xc420336480, 0x8d1820, 0xc4204aa000, 0xc420196100)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /usr/local/go/src/net/http/server.go:1947 +0x44
func_faas-swarm.1.0v8o3foxei7o@docker03    | github.com/openfaas/faas-swarm/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc420309c70, 0x8d1820, 0xc4204aa000, 0xc420196100)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /go/src/github.com/openfaas/faas-swarm/vendor/github.com/gorilla/mux/mux.go:162 +0xed
func_faas-swarm.1.0v8o3foxei7o@docker03    | net/http.serverHandler.ServeHTTP(0xc420352340, 0x8d1820, 0xc4204aa000, 0xc420470300)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /usr/local/go/src/net/http/server.go:2697 +0xbc
func_faas-swarm.1.0v8o3foxei7o@docker03    | net/http.(*conn).serve(0xc420084c80, 0x8d1d60, 0xc4200a72c0)
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /usr/local/go/src/net/http/server.go:1830 +0x651
func_faas-swarm.1.0v8o3foxei7o@docker03    | created by net/http.(*Server).Serve
func_faas-swarm.1.0v8o3foxei7o@docker03    |    /usr/local/go/src/net/http/server.go:2798 +0x27b

Context

Your Environment

Gateway uri: http://127.0.0.1:8080 version: 0.10.2 sha: bfa869ec8c0c04c26c5b0ed434bc367e712dcaef commit: Revert docker tag bump to 0.10.0

Provider name: faas-swarm orchestration: swarm version: 0.6.1 sha: 3cac0ccc2e8bb7f567739a33f7d414cdb58440aa

* Docker version ( Full output from: `docker version` ):

Client: Version: 18.03.1-ce API version: 1.37 Go version: go1.9.5 Git commit: 9ee9f40 Built: Thu Apr 26 07:20:16 2018 OS/Arch: linux/amd64 Experimental: false Orchestrator: swarm

Server: Engine: Version: 18.03.1-ce API version: 1.37 (minimum version 1.12) Go version: go1.9.5 Git commit: 9ee9f40 Built: Thu Apr 26 07:23:58 2018 OS/Arch: linux/amd64 Experimental: false


* Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)?
`Docker Swarm`

* Operating System and version (e.g. Linux, Windows, MacOS):
`Linux docker03 3.10.0-514.21.1.el7.x86_64 #1 SMP Sat Apr 22 02:41:35 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux`
bartsmykla commented 5 years ago

@padiazg docker swarm doesn't support updating secrets unfortunately

alexellis commented 5 years ago

This is the problem @bartsmykla, rather than the lack of update:

func_faas-swarm.1.0v8o3foxei7o@docker03 | 2019/01/29 17:52:12 http: panic serving 10.0.0.172:44428: runtime error: invalid memory address or nil pointer dereference

This needs fixing in the faas-swarm code.

Please could one of you raise an issue for this and label it with Derek?

rgee0 commented 5 years ago

I think maybe we need to reassess here. The nil pointer error is coming out of the call to c.SecretUpdate - rem it out and you get a 200. However, my understanding of this method is that it only allows update to Labels. Attempts to update the Data field will result in the Label message also seen in @padiazg's output. So, we could track down the nil pointer error to make the message go away but I'm not sure this will subsequently enable the desired action.

https://github.com/docker/engine/blob/680095405094e61218bdfaa8d53c1f70e00f5113/integration/secret/secret_test.go#L212-L216

alexellis commented 4 years ago

Swarm secrets cannot be updated.