8000 [Controller] Enable Readiness and Liveness probes configurations by weilerN · Pull Request #3629 · nuclio/nuclio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Controller] Enable Readiness and Liveness probes configurations #3629

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

Conversation

weilerN
Copy link
Collaborator
@weilerN weilerN commented May 5, 2025

Motivation

Described in the JIRA

Root Cause

Nuclio functions previously used default values for readiness and liveness probes, with no user-facing way to customize them. This limited flexibility in production environments, where probe tuning is often necessary to accommodate different workloads.

Description

This PR introduces support for configuring readiness and liveness probes by propagating the probe configurations to the container-level configuration.

Affected Areas

  • Refactor unit tests - Added the defaults functionInstance.Spec.LivenessProbe and functionInstance.Spec.ReadinessProbe to other unit tests.
    This addition was necessary because some tests invoke lazyClient.CreateOrUpdate which is affected by this PR.
    These changes maintain the tests' consistency.

Testing

  • CreateOrUpdate changes were Covered by unit tests
  • The full probes propagation flow is covered with an Integration test

Changes Made

  • Modified the ReadinessProbe and LivenessProbe fields to be taken from the function specification instead of using static values.

@weilerN weilerN force-pushed the NUC-409-implement-configurable-probes-in-controller branch from 66e16e9 to a2885be Compare May 5, 2025 13:58
8000
@weilerN weilerN force-pushed the NUC-409-implement-configurable-probes-in-controller branch from 0fed582 to d309668 Compare May 5, 2025 14:20
@weilerN weilerN requested a review from rokatyy May 5, 2025 14:21
@weilerN weilerN marked this pull request as ready for review May 5, 2025 14:41
Copy link
Contributor
@TomerShor TomerShor left a comment

Choose a reason for hiding this comment

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

Nice work!
Added some comments regarding the tests.

8000
@@ -751,6 +752,30 @@ func (suite *lazyTestSuite) TestEnrichDeploymentFromPlatformConfiguration() {
suite.Require().True(deployment.Spec.Paused)
}

func (suite *lazyTestSuite) TestEnrichProbesInPopulateDeploymentContainer() {
// Prepare
functionInstance := suite.getFunctionInstance("")
Copy link
Contributor

Choose a reason for hiding this comment

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

While I understand it is not needed in this test, it's not a good practice to create functions with empty names.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed - here

func (suite *lazyTestSuite) TestEnrichProbesInPopulateDeploymentContainer() {
// Prepare
functionInstance := suite.getFunctionInstance("")
testCtx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for that, you can use suite.ctx

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed - here


// Prepare
functionName := "func-hello-world"
testNum := int32(14)
Copy link
Contributor

Choose a reason for hiding this comment

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

Give variables meaningful names.
In this case it should be timeoutSeconds, or even livenessProbeTimeoutSeconds

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed - here

createFunctionOptions.FunctionConfig.Spec.LivenessProbe = &v1.Probe{TimeoutSeconds: testNum}

// Act
result, deployErr := suite.Platform.CreateFunction(suite.Ctx, createFunctionOptions)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use suite.DeployFunction instead, as it wraps the function creation in extra enrichments, error handling (such as timeouts), and gracefully deletes the function before existing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed - here
Note- all the changes below this line are basically moving the container's tests inside the suite.DeployFunction scope.

@weilerN weilerN requested a review from TomerShor May 6, 2025 08:18
Copy link
Contributor
@rokatyy rokatyy left a comment

Choose a reason for hiding this comment

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

Very good.
Just a couple of minor things regarding tests.

@weilerN weilerN requested a review from rokatyy May 6, 2025 10:37
Copy link
Contributor
@rokatyy rokatyy left a comment

Choose a reason for hiding this comment

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

LGTM :)

Copy link
Contributor
@TomerShor TomerShor left a comment

Choose a reason for hiding this comment

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

Great stuff!

@rokatyy rokatyy merged commit 1a063a6 into nuclio:development May 6, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0