-
Notifications
You must be signed in to change notification settings - Fork 23
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
Operator shutting down after one minute #202
Comments
Hi @heruan , no it is not, if you could share your code we can take a look. Aren't you definening some health probes? My guess would be k8s is shutting it down. |
No probes. I tested running from the IDE, still shuts down. Debugging looks like it's Spring shutting down and closing the operator, but why would Spring shut down once the operator is started? Minimum reproducible code: plugins {
id("java")
id("org.springframework.boot") version "3.4.2"
id("io.spring.dependency-management") version "1.1.7"
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-logging")
implementation("io.javaoperatorsdk:operator-framework-spring-boot-starter:6.0.0-beta2")
} package test;
import io.fabric8.kubernetes.api.model.KubernetesResource;
import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.Version;
@Group("com.vaadin")
@Version("v1")
public class App extends CustomResource<AppSpec, AppStatus> implements
Namespaced {
public static class AppSpec implements KubernetesResource {
}
public static class AppStatus implements KubernetesResource {
}
} package test;
import io.javaoperatorsdk.operator.api.config.informer.Informer;
import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl;
import org.springframework.stereotype.Component;
@Informer
@Component
public class AppController implements Reconciler<App> {
@Override
public UpdateControl<App> reconcile(App app, Context<App> context) {
System.out.println("RECONCILE RUNNING");
return UpdateControl.noUpdate();
}
} package test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class OperatorApplication {
public static void main(String... args) {
SpringApplication.run(OperatorApplication.class, args);
}
} Shutdown happens both running with |
@heruan how are you generating the CRD? or you apply that manually? can you please that too pls |
The CRD is generated by Fabric8: # Generated by Fabric8 CRDGenerator, manual edits might get overwritten!
apiVersion: "apiextensions.k8s.io/v1"
kind: "CustomResourceDefinition"
metadata:
name: "apps.com.vaadin"
spec:
group: "com.vaadin"
names:
kind: "App"
plural: "apps"
singular: "app"
scope: "Namespaced"
versions:
- name: "v1"
schema:
openAPIV3Schema:
properties:
spec:
type: "object"
status:
type: "object"
type: "object"
served: true
storage: true
subresources:
status: {} |
Tested with 5.6.0 and it doesn't happen, so I'd assume the cause is somewhere in v5.6.0...v6.0.0-beta2 |
Shutdown happens only with JOSDK 5.0.0-beta1/RC1, downgrading to 4.9.7 works (still using JOSDK Starter 6.0.0-beta2). Log with JOSDK 5.0.0-beta1 on Spring Boot 3.4.2:
Log with JOSDK downgraded to 4.9.7 (still Spring Boot 3.4.2 and JOSDK Starter 6.0.0-beta2):
For some reason the Not sure if this warning might be relevant:
@csviri have you been able to replicate this? |
not yet, hope will get to it tomorrow |
Run with logs at
|
Was able to reproduce with the sample in the starter, it happens also when I downgrade JOSDK version. So something with Spring Boot. Will dig deeper. |
So when working with the sample this helped:
I tried on you example, and interestingly when added to gradle: My bet is that is that the actual problem is that if not a web application spring just kills it after 1 minute!? Not instantly since we have non-daemon threads running. (But needs to be verified) IMO, we should do either a blocking command line app this way: But rather, have it always a web app, and also having proper liveness probes exposed through servlets as in Quarkus Operator SDK. |
see also: #204 |
Thanks for the investigation! I would say the operator starter should not require the web starter for the application to run. How does the web starter avoid shutdown? I suppose the web server thread keeps listening to requests as the operator keeps listening to events 🤔 |
Good questions, actually this might be that we had non-deamon Threads before (this might changed in fabric8 client), or just Spring handles this somehow explicitly (hope not).
Note that we need that anyways to properly hand health probes. |
I'm trying to build a simple operator, right now it is just like this:
When I start the app, after one minute it shuts down:
I still have no
App
custom resources created, I just noticed it shuts down for some reason. Is this expected?The text was updated successfully, but these errors were encountered: