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

Readiness health checks story 2 in db #3361

Merged

Conversation

ameowlia
Copy link
Member

@ameowlia ameowlia commented Jul 26, 2023

This PR is part of a larger effort detailed here in this Cloud Controller PR and here in this CFF RFC.

In this story, the 3 new app manifest properties (created in this PR), are set in the db.

New App Manifest Properties

applications:
- name: test-app
  processes:
  - type: web
    health-check-http-endpoint: /health
    health-check-invocation-timeout: 2
    health-check-type: http
    timeout: 80
    readiness-health-check-http-endpoint: /ready       # 👈 new property
    readiness-health-check-invocation-timeout: 2       # 👈 new property
    readiness-health-check-type: http                  # 👈 new property

Acceptance Steps

  1. When I provide valid properties they are saved on the db. Below are examples of valid configs.
 # nothing! will default to process in the db
  readiness-health-check-http-endpoint: /ready
  readiness-health-check-invocation-timeout: 2
  readiness-health-check-type: http
  readiness-health-check-type: http
  readiness-health-check-type: port
  readiness-health-check-type: process
  1. When I provide invalid properties, I get an error, and they are not saved in the db. Below are examples of invalid configs:
  readiness-health-check-http-endpoint: ready
  readiness-health-check-invocation-timeout: -10
  readiness-health-check-type: http
  readiness-health-check-http-endpoint: /ready
  readiness-health-check-type: port
  readiness-health-check-type: meow

Previous PRs

@ameowlia ameowlia force-pushed the readiness-health-checks-story-2-in-db branch 3 times, most recently from e28fe36 to 44ea08a Compare July 26, 2023 16:30
@ameowlia ameowlia marked this pull request as ready for review July 26, 2023 16:32
Now when a user supplies the readiness health check properties via the
app manifest, the values are stored on the process, and saved in the
database.

Signed-off-by: Renee Chu <[email protected]>
@ameowlia ameowlia force-pushed the readiness-health-checks-story-2-in-db branch from 44ea08a to 85b22b9 Compare July 26, 2023 16:44
class HealthCheckPolicy
def initialize(process, health_check_timeout, health_check_invocation_timeout)
def initialize(process, health_check_timeout, health_check_invocation_timeout, health_check_type, health_check_http_endpoint)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We refactored the health check policy, to contain all of the checks for health checks, and removed some checks that were in the process model. We think this consolidates these checks more.

Also we refactored so that we could make a ReadinessHealthCheckPolicy that inherits from this class.

mariash and others added 2 commits July 26, 2023 18:00
def self.constants_to_array
[
HTTP,
NONE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we have NONE at all, do you? Trying to set a health check to none via the API results in the following error:

± sb |readiness-health-checks-story-2-in-db → origin {3} ?:1 ✗| → cf curl -X PATCH v3/processes/c6493e8f-84b0-4e84-be1f-7156b7704039 -d '{"health_check": {"type": "none","data":  {  }}}'
{
   "errors": [
      {
         "detail": "Health check type must be \"port\", \"process\", or \"http\"",
         "title": "CF-UnprocessableEntity",
         "code": 10008
      }
   ]
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it used to be an option, but no longer is. It looks like for awhile there was backwards compatible logic where it would map none -> process. I suspect it is dead code now and could be ripped out. If you want we can do it in another story.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to clean up, but NONE's presence doesn't seem too onerous right now. I'll leave it to you to decide if you want to do it, and if not I'll create a story/github issue to track it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a story in our epic to do it.

Copy link
Member

@sethboyles sethboyles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! The only major thing I would ask you to consider changing is the ReadinessHealthCheckPolicy < HealthCheckPolicy inheritance pattern. I think having a BaseHealthCheckPolicy that both policies inherit from would avoid any surprises that might come from changing HealthCheckPolicy and seeing the effects in ReadinessHealthCheckPolicy

split out readiness health check types into its own method
@ameowlia ameowlia force-pushed the readiness-health-checks-story-2-in-db branch from 29f6068 to 2cfe394 Compare July 27, 2023 21:23
@ameowlia
Copy link
Member Author

@sethboyles The latest commit adds BaseHealthCheckPolicy class for both the ReadinessHealthCheckPolicy and HealthCheckPolicy classes to inherit from. Both the ReadinessHealthCheckPolicy and HealthCheckPolicy are very slimmed down now. I wasn't sure about the best way to test all these components.

Options for testing health check policy classes

  1. Test all the main logic once in base_health_check_policy_spec. Then only test the differences on each of the inheriting classes.
  2. Don't test BaseHealthCheckPolicy at all since nothing uses it explicitly. Put all tests in on ReadinessHealthCheckPolicy and HealthCheckPolicy.
  3. Test everywhere! Put tests on BaseHealthCheckPolicy, ReadinessHealthCheckPolicy, and HealthCheckPolicy. 👈 This is the current state of the world.

I chose option 3. I am happy to change the testing pattern if you would prefer a different option.

@sethboyles
Copy link
Member

LGTM!

@ameowlia ameowlia merged commit acb51bf into readiness-health-checks Jul 28, 2023
@ameowlia ameowlia deleted the readiness-health-checks-story-2-in-db branch July 28, 2023 21:49
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 this pull request may close these issues.

4 participants