-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
d33ead4
to
d8e67c0
Compare
047d072
to
7a74f50
Compare
There was a problem hiding this 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.
7a74f50
to
b7ed6e4
Compare
0af4af9
to
4e8d31a
Compare
@@ -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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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....
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@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) | ||
} | ||
|
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
wildfly-operator/pkg/resources/statefulsets/statefulset.go
Lines 110 to 114 in a4764d0
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.
There was a problem hiding this comment.
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
@yersan I see the |
@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. |
Fixes #234