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

Stack Trace Parsing Stack Healthcheck #1974

Closed
jmacelroy opened this issue Nov 15, 2021 · 0 comments · Fixed by #1975
Closed

Stack Trace Parsing Stack Healthcheck #1974

jmacelroy opened this issue Nov 15, 2021 · 0 comments · Fixed by #1975
Assignees

Comments

@jmacelroy
Copy link
Contributor

Some curl based healthchecks for stacks are not parsed correctly resulting in a stack trace.

A user reported a stack trace when deploying from a docker-compose.yml file.
The trace indicated that we were out of bounds on a slice reference when parsing the curl health check for the service.

I was able to repro it with the following unittest

func TestTranslateHealthcheckCurlToHttp(t *testing.T) {
	check := HealthCheck{
		Test:        []string{"curl http://0.0.0.0:4572"},
		Interval:    5 * time.Second,
		Timeout:     10 * time.Minute,
		Retries:     10,
		StartPeriod: 20 * time.Second,
	}

	translateHealtcheckCurlToHTTP(&check)
	fmt.Printf("CHECK %+v\n", check)
}

This test results in a stack of

--- FAIL: TestTranslateHealthcheckCurlToHttp (0.00s)
panic: runtime error: slice bounds out of range [20:11] [recovered]
        panic: runtime error: slice bounds out of range [20:11]

goroutine 36 [running]:
testing.tRunner.func1.2({0x19148a0, 0xc000164a80})
        /usr/local/go/src/testing/testing.go:1209 +0x24e
testing.tRunner.func1()
        /usr/local/go/src/testing/testing.go:1212 +0x218
panic({0x19148a0, 0xc000164a80})
        /usr/local/go/src/runtime/panic.go:1038 +0x215
github.com/okteto/okteto/pkg/model.translateHealtcheckCurlToHTTP(0xc000080ed0)
        /Users/jdm/okt/okteto/pkg/model/stack_serializer.go:520 +0x365
github.com/okteto/okteto/pkg/model.TestTranslateHealthcheckCurlToHttp(0x0)
        /Users/jdm/okt/okteto/pkg/model/stack_serializer_test.go:39 +0xc5
testing.tRunner(0xc0001e3a00, 0x19e7c98)
        /usr/local/go/src/testing/testing.go:1259 +0x102
created by testing.(*T).Run
        /usr/local/go/src/testing/testing.go:1306 +0x35a
FAIL    github.com/okteto/okteto/pkg/model      0.253s
FAIL

The user was on okteto CLI 1.14.5

Their check did not repro for me and was like this but it seems to be similar to the test based on the stack

    healthcheck:
      test: [ "CMD-SHELL", "curl http://0.0.0.0:4578" ]
      interval: 5s
      timeout: 10m
      retries: 10
      start_period: 20s

The translateHealtcheckCurlToHTTP function does a lot of manual parsing. We should investigate using url.Parse and other methods for doing some of the parsing while addressing the issue.

jmacelroy pushed a commit that referenced this issue Nov 16, 2021
There was at least one issue parsing for the url to transform the stack health check
to the data needed for a health check in kubernetes. The issue discovered was
an out of bounds on a slice issue when there was no path present.

This commit fixes #1974

Signed-off-by: Jacob MacElroy <jacob@okteto.com>
pchico83 pushed a commit that referenced this issue Nov 16, 2021
* Simplify curl-based healthcheck parsing for stacks.

There was at least one issue parsing for the url to transform the stack health check
to the data needed for a health check in kubernetes. The issue discovered was
an out of bounds on a slice issue when there was no path present.

This commit fixes #1974

Signed-off-by: Jacob MacElroy <jacob@okteto.com>

* Removing leftover print statements.
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

Successfully merging a pull request may close this issue.

2 participants