faas-netes icon indicating copy to clipboard operation
faas-netes copied to clipboard

expose gateway probes

Open kevin-lindsay-1 opened this issue 1 year ago • 1 comments

Exposes the readiness and liveness probe timing & success/failure settings to be able to be set by the user.

Description

Pod use readiness for load balancing and preventing pod overloading. Liveness determines if a pod has gotten "stuck", and restarts it if it stops responding.

Motivation and Context

  • [X] I have raised an issue to propose this change (required)

How Has This Been Tested?

Local deployment of chart.

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [X] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [X] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [X] I've read the CONTRIBUTION guide
  • [X] I have signed-off my commits with git commit -s
  • [ ] I have added tests to cover my changes.
  • [ ] All new and existing tests passed.

kevin-lindsay-1 avatar Sep 02 '22 16:09 kevin-lindsay-1

Thank you for your contribution. unfortunately, one or more of your commits are missing the required "Signed-off-by:" statement. Signing off is part of the Developer Certificate of Origin (DCO) which is used by this project.

Read the DCO and project contributing guide carefully, and amend your commits using the git CLI. Note that this does not require any cryptography, keys or special steps to be taken.

:bulb: Shall we fix this?

This will only take a few moments.

First, clone your fork and checkout this branch using the git CLI.

Next, set up your real name and email address:

git config --global user.name "Your Full Name" git config --global user.email "[email protected]"

Finally, run one of these commands to add the "Signed-off-by" line to your commits.

If you only have one commit so far then run: git commit --amend --signoff and then git push --force. If you have multiple commits, watch this video.

Check that the message has been added properly by running "git log".

derek[bot] avatar Sep 02 '22 16:09 derek[bot]

@welteki please can you make a suggestion for @kevin-lindsay-1 or point him to one of your prior examples with defaulting / if / or statements?

alexellis avatar Oct 04 '22 07:10 alexellis

Hi Kevin, like Alex mentioned you can use if statements, you can also use the default function like we do in several other places in the chart.

https://github.com/openfaas/faas-netes/blob/85d425bfae93d00a4a053d874418b8ff32aeaf80/chart/openfaas/templates/ingress.yaml#L3 https://github.com/openfaas/faas-netes/blob/85d425bfae93d00a4a053d874418b8ff32aeaf80/chart/openfaas/templates/gateway-dep.yaml#L2

https://helm.sh/docs/chart_template_guide/functions_and_pipelines/#using-the-default-function

welteki avatar Oct 04 '22 09:10 welteki

That linting error I see seems like the linter is supplying a type that I wouldn't expect to see in a real chart?

kevin-lindsay-1 avatar Oct 04 '22 14:10 kevin-lindsay-1

Error:  templates/: template: openfaas/templates/gateway-dep.yaml:67:45: executing "openfaas/templates/gateway-dep.yaml" at <dig "gateway" "livenessProbe" "initialDelaySeconds" nil>: error calling dig: interface conversion: interface {} is chartutil.Values, not map[string]interface {}

Perhaps we need a solution that avoids dig?

If gateway.livenessProbe => then try to read the whole path, otherwise set the default.

alexellis avatar Oct 04 '22 14:10 alexellis

Updated to not dig $.Values directly, since its type is not a map[string]interface{}. $.Values is special, because it has a helm-provided definition.

kevin-lindsay-1 avatar Oct 04 '22 15:10 kevin-lindsay-1

Looks like there was a build failure due to sprig v3 functions not being in scope in the build's linter. Looks like the job was retried, so maybe this was caught already.

kevin-lindsay-1 avatar Oct 04 '22 15:10 kevin-lindsay-1

I'm seeing:

Error: templates/: parse error at (openfaas/templates/gateway-dep.yaml:67): function "dig" not defined

alexellis avatar Oct 04 '22 15:10 alexellis

That appears to be due to sprig functions not being in scope in whatever linter is being used, which effectively means that it isn't linting according to helm's contract. Helm has dig.

kevin-lindsay-1 avatar Oct 04 '22 15:10 kevin-lindsay-1

Values.gateway has always been there, so we only need to check to Values.gateway.livenessProbe IMHO, that should be possible without the dig macro? If Values.gateway.livenessProbe is defined and empty, then that's a user error, not an upgrade issue.

alexellis avatar Oct 04 '22 16:10 alexellis

So if a user replaces livenessProbe with {}, do you want to not include them, or do you want it to use your preferred default values?

kevin-lindsay-1 avatar Oct 04 '22 16:10 kevin-lindsay-1

If you don't want to use dig, ok. It looks like the lint issue is an issue with your build not supporting sprig, but ok. I'll do whatever, because this isn't my repo. If you want me to write an if statement and have a separate livenessProbe with defaults, I'll do it. I don't think it's clean, but I'm not going to die on a hill for this PR, which I was doing as a favor.

At the end of the day, I'm looking for functionality to be exposed. If you aren't comfortable using dig, that's your prerogative.

kevin-lindsay-1 avatar Oct 04 '22 18:10 kevin-lindsay-1

So if a user replaces livenessProbe with {}, do you want to not include them, or do you want it to use your preferred default values?

We'll leave this as an unsupported use-case.

If a user wants K8s defaults, they can copy them into livenessProbe

Can you amend the commit to do the simplest thing possible?

alexellis avatar Oct 07 '22 14:10 alexellis

Thank you for your contribution. unfortunately, one or more of your commits are missing the required "Signed-off-by:" statement. Signing off is part of the Developer Certificate of Origin (DCO) which is used by this project.

Read the DCO and project contributing guide carefully, and amend your commits using the git CLI. Note that this does not require any cryptography, keys or special steps to be taken.

:bulb: Shall we fix this?

This will only take a few moments.

First, clone your fork and checkout this branch using the git CLI.

Next, set up your real name and email address:

git config --global user.name "Your Full Name" git config --global user.email "[email protected]"

Finally, run one of these commands to add the "Signed-off-by" line to your commits.

If you only have one commit so far then run: git commit --amend --signoff and then git push --force. If you have multiple commits, watch this video.

Check that the message has been added properly by running "git log".

derek[bot] avatar Oct 07 '22 14:10 derek[bot]

@alexellis this was updated almost a week ago now. can we look at this again? I'd like to get this merged, as gateways crash without it.

kevin-lindsay-1 avatar Oct 13 '22 14:10 kevin-lindsay-1

@kevin-lindsay-1 the chart has been republished with this change. Thanks for working on it.

alexellis avatar Oct 19 '22 18:10 alexellis