Skip to content

Better DX for healthcheck #1625

Closed as not planned
Closed as not planned

Description

@helderco

I think the test field in healthcheck should be abstracted into a new cmd field and the time intervals could also be humanized.

Currently the test field is a single list where the first element has special meaning:

#HealthCheck: {
	test?: [...string]
	interval?:    int
	timeout?:     int
	startperiod?: int
	retries?:     int
}

The options are:

  • []: inherit healthcheck
  • ["NONE"] : disable healthcheck
  • ["CMD", args...] : exec arguments directly
  • ["CMD-SHELL", command] : run command with system's default shell

Here's what some dockerfile instructions produce:

CMD-SHELL

HEALTHCHECK --interval=5m --timeout=3s CMD curl -f http://localhost/ || exit 1
healthcheck: {
    test: [
        "CMD-SHELL",
        "curl -f http://localhost/ || exit 1",
    ]
    interval: 300000000000
    timeout: 3000000000
}

CMD

HEALTHCHECK --interval=5m --timeout=3s CMD ["curl", "-f", "http://localhost/"]
healthcheck: {
    test: [
        "CMD",
        "curl",
        "-f",
        "http://localhost/",
    ]
    interval: 300000000000
    timeout: 3000000000
}

NONE

HEALTHCHECK NONE
healthcheck: {
    test: ["NONE"]
}

Proposal

Change to:

#HealthCheck: {
	{
		disable: true
	} | {
		cmd: string | [...string]
		interval?: int | #Duration
		timeout?: int | #Duration
		start_period?: int | #Duration
		retries?: int
	}
}

#Duration: string // regex here

Then, the previous calls would become:

config: {
    healthcheck: {
        cmd: "curl -f http://localhost/ || exit 1"
        interval: "3s"
        timeout: "3s"
    }
}

config: {
    healthcheck: {
        cmd: ["curl", "-f", "http://localhost/"]
        interval: "3s"
        timeout: "3s"
    }
}

config: {
    healthcheck: disable: true
}

Activity

  1. self-assigned this
    on Feb 17, 2022
  2. helderco commented on Feb 22, 2022

    @helderco
    ContributorAuthor

    On second thought, docker compose uses the test from the spec: https://docs.docker.com/compose/compose-file/compose-file-v3/#healthcheck

    Do we prefer familiarity with compose or dockerfile? I think maybe take the best ideas from both and keep it as simple as possible for users.

  3. removed their assignment
    on Aug 9, 2022
  4. shykes commented on Dec 21, 2022

    @shykes
    Contributor

    I'm closing this since the 0.2 CUE API is frozen, in favor of the GraphQL API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions