unit: invalid configurations accepted when using `processes/spare/0`

When using spare processes field set to 0, the router doesn’t actually restart the app but just validate the config. This makes router accept invalid configurations and hang the application in unexpected ways.

Eg.:

$ curl --unix-socket $UNITSOCK 127.0/config/applications/hello
{
	"type": "python",
	"path": "/vagrant/src/unit-configs/ok/python/hello",
	"module": "wsgi",
	"processes": {
		"spare": 0
	}
}
$ curl --unix-socket $UNITSOCK -XPUT 127.0/config/applications/hello/working_directory --data-binary '"/non-existant-dir"'
{
	"success": "Reconfiguration done."
}
$ curl localhost:6666
.
hangs here...
^C
$

I got this problem in tests (that set spare to zero by default), tests were passing when actually they should not… @andrey-zelenkov

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Yes, I talked about test part only.

Current behaviour is not something specially designed. It’s just a straightforward implementation: we have N processes to start. If we fail to start them then we return error. If N is zero, then no processes start, nothing fails.

@tiago4orion I believe Andrey’s comment was related only for our tests. He found it handy to write them this way. We may change the behaviour and always check the app process on applying configuration to make it more consistent.