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

[234] Add the ability to configure the Readiness, Liveness and Startup probes #235

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

yersan
Copy link
Collaborator

@yersan yersan commented Oct 18, 2022

Fixes #234

api/v1alpha1/wildflyserver_types.go Show resolved Hide resolved
api/v1alpha1/wildflyserver_types.go Show resolved Hide resolved
api/v1alpha1/wildflyserver_types.go Show resolved Hide resolved
api/v1alpha1/wildflyserver_types.go Show resolved Hide resolved
api/v1alpha1/wildflyserver_types.go Show resolved Hide resolved
api/v1alpha1/wildflyserver_types.go Outdated Show resolved Hide resolved
@yersan yersan force-pushed the issue-234 branch 2 times, most recently from d33ead4 to d8e67c0 Compare October 19, 2022 15:31
@yersan yersan force-pushed the issue-234 branch 6 times, most recently from 047d072 to 7a74f50 Compare October 28, 2022 12:09
Copy link
Contributor

@jbliznak jbliznak left a comment

Choose a reason for hiding this comment

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

Thanks Yeray for fixing my concern, I have no more objections.

pkg/resources/statefulsets/statefulset.go Outdated Show resolved Hide resolved
pkg/resources/statefulsets/statefulset.go Outdated Show resolved Hide resolved
pkg/resources/statefulsets/statefulset.go Outdated Show resolved Hide resolved
doc/apis.adoc Outdated Show resolved Hide resolved
@yersan yersan force-pushed the issue-234 branch 3 times, most recently from 0af4af9 to 4e8d31a Compare June 23, 2023 16:25
api/v1alpha1/wildflyserver_types.go Outdated Show resolved Hide resolved
@yersan yersan changed the title Issue-234 Adds configuration of probes [234] Add the ability to configure the Readiness, Liveness and Startup probes Nov 2, 2023
@@ -580,3 +581,393 @@ func TestWildFlyServerWithSecurityContext(t *testing.T) {
assert.Equal(readOnlyRootFilesystem, statefulSet.Spec.Template.Spec.Containers[0].SecurityContext.ReadOnlyRootFilesystem)
assert.Equal(runAsNonRoot, statefulSet.Spec.Template.Spec.Containers[0].SecurityContext.RunAsNonRoot)
}

func TestWildFlyServerWithHttpProbes(t *testing.T) {

Choose a reason for hiding this comment

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

@yersan I don't understand what triggers the usage of HTTP probes here; IIUC default (no bootableJar or http setting) should be exec probes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @tommaso-borgato , the env variables SERVER_LIVENESS_SCRIPT and SERVER_READINESS_SCRIPT are not configured for this test.

Copy link

@tommaso-borgato tommaso-borgato Nov 29, 2023

Choose a reason for hiding this comment

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

@yersan shouldn't we expect exec probes like e.g.

        exec:
          command:
            - /bin/bash
            - '-c'
            - >-
              if [ -f '/opt/eap/bin/livenessProbe.sh' ]; then
              /opt/eap/bin/livenessProbe.sh; else curl --fail
              http://127.0.0.1:9990/health/live; fi

in this case? I mean, I don't see neither bootableJar=true nor http=true configured here....

Copy link
Collaborator Author

@yersan yersan Nov 29, 2023

Choose a reason for hiding this comment

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

Hi @tommaso-borgato , the intention of this test is to verify the creation of probes that use pure HTTP request, not the Exec commands. I used the presence of the aforementioned environment variables to force the switch that triggers it.

Would it get clearer if we use bootableJar=true? That would be more close to the reality fro the product side, although we do not define them upstream.

The verification of the Exec probes is done in the TestWildFlyServerWithProbesScript

Copy link

@tommaso-borgato tommaso-borgato Nov 29, 2023

Choose a reason for hiding this comment

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

@yersan what I don't understand is why in TestWildFlyServerWithHttpProbes, a CRD like:

func TestWildFlyServerWithHttpProbes(t *testing.T) {
	ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
	assert := testifyAssert.New(t)

	// First verify the default values are created when there is not
	// any Probe configuration
	wildflyServer := &wildflyv1alpha1.WildFlyServer{
		ObjectMeta: metav1.ObjectMeta{
			Name:      name,
			Namespace: namespace,
		},
		Spec: wildflyv1alpha1.WildFlyServerSpec{
			ApplicationImage: applicationImage,
			Replicas:         replicas,
		},
	}

which hasn't either bootableJar or http set, when processed by the operator produces HTTP Probes instead of exec probes;

I expected something like:

wildflyServer := &wildflyv1alpha1.WildFlyServer{
		ObjectMeta: metav1.ObjectMeta{
			Name:      name,
			Namespace: namespace,
		},
		Spec: wildflyv1alpha1.WildFlyServerSpec{
			ApplicationImage: applicationImage,
			Replicas:         replicas,
			BootableJar:      true,
		},
	}

to produce HTTP probes,

or something like:

readinessProbe := &wildflyv1alpha1.ProbeSpec{
		InitialDelaySeconds: 20,
		TimeoutSeconds:      245,
		PeriodSeconds:       25,
		SuccessThreshold:    21,
		FailureThreshold:    29,
		Http: true,
	}
wildflyServer.Spec.LivenessProbe = livenessProbe

to produce HTTP probes: I mean a CRD with BootableJar: true or Http: true

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

which hasn't either bootableJar or http set, when processed by the operator produces HTTP Probes instead of exec probes;

Because the env variables SERVER_LIVENESS_SCRIPT and SERVER_READINESS_SCRIPT are not configured for this test. If they are not configured (for example the upstream operator does not configure them), then we configure the probes using HTTP get requests.

Choose a reason for hiding this comment

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

@yersan Thank you for the explanation, now I see it

@yersan
Copy link
Collaborator Author

yersan commented Dec 5, 2023

@tommaso-borgato This is now ready for your review accordingly whit what we have been discussing by removing the HTTP field and exposing the Exec and HTTPGet

assert.True(reflect.DeepEqual(livenessExec.Command, stsLivenessProbe.Exec.Command))
assert.Nil(stsLivenessProbe.HTTPGet)
}

Copy link

@tommaso-borgato tommaso-borgato Jan 15, 2024

Choose a reason for hiding this comment

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

@yersan what about adding yet another test to check that, when StartupProbe alone is added, the other probes still default to the correct values? that would prove that the StartupProbe code path doesn't interfere with the logic already in place...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hello @tommaso-borgato I don't see it necessary since there is no interaction between those conditions in the source code. Each probe uses its own method, and the existence of one vs another does not affect to any logic.

We always invoke each of the methods See

LivenessProbe: createLivenessProbe(w),
// Readiness Probe is optional
ReadinessProbe: createReadinessProbe(w),
// StartupProbe Probe is optional
StartupProbe: createStartupProbe(w),

Anyway, since tests are quick and the change is easy, we can add it, but it is unnecessary from my point of view.

Choose a reason for hiding this comment

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

ok, no need to if they are totally independent code paths

@tommaso-borgato
Copy link

@yersan I see the bundle/manifests/wildfly.org_wildflyservers.yaml file is not updated

@yersan
Copy link
Collaborator Author

yersan commented Jan 19, 2024

@yersan I see the bundle/manifests/wildfly.org_wildflyservers.yaml file is not updated

@tommaso-borgato We don't need to update it. It is confusing, so I guess the best would be to remove it from Git. This is the CRD generated when you are creating a bundle for the Operator. It has nothing to do with this PR.

@yersan yersan merged commit 5f0c4c5 into wildfly:main Feb 14, 2024
1 check passed
@yersan yersan deleted the issue-234 branch February 14, 2024 10:30
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.

Add possibility to customize readiness and liveness probe settings
4 participants