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

Spring Boot actuator endpoints failed to generate automatically if "deployment.yml" resource fragment is used #1295

Closed
simonwg opened this issue Feb 21, 2022 · 2 comments · Fixed by #1320
Assignees
Labels
bug Something isn't working
Milestone

Comments

@simonwg
Copy link

simonwg commented Feb 21, 2022

Description

Info

  • Eclipse JKube version : 1.6.0
  • Maven version (mvn -v) : 3.8.4

  • Kubernetes / Red Hat OpenShift setup and version : OpenShift 3.11

  • If it's a bug, how to reproduce : Using the zero-config quickstarts. Add the following in src/main/jkube/deployment.yml

spec:
  template:
    spec:
      containers:
        - env:
            - name: ABC
              value: dummy

The log will show that "oc: jkube-healthcheck-spring-boot" is not triggered and the output openshift.yml doesn't have readinessProbe and livenessProbe config generated. Same configuration works for JKube 1.5.1

  • If it's a feature request, what is your use case :

  • Sample Reproducer Project : [GitHub Clone URL]

@rohanKanojia
Copy link
Member

@simonwg : Thanks for reporting, I can reproduce this issue.

Till this gets fixed you can try using this property as a workaround:

  • Add liveness/readiness probes to all containers
mvn oc:resource -Djkube.enricher.jkube-healthcheck-spring-boot.enrichAllContainers=true

@manusa manusa added the bug Something isn't working label Feb 21, 2022
@rohanKanojia rohanKanojia self-assigned this Feb 28, 2022
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Feb 28, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Add a distinct size calculation logic to avoid probes not being added in
case of openshift.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@rohanKanojia
Copy link
Member

rohanKanojia commented Mar 1, 2022

Hmm, I'm seeing strange behavior from TypedVisitor class since previous Kubernetes Client upgrade

https://github.com/eclipse/jkube/blob/d1152b17067a14cf4a4490056e4a38071519d895/jkube-kit/enricher/specific/src/main/java/org/eclipse/jkube/kit/enricher/specific/AbstractHealthCheckEnricher.java#L115-L121

Here when KubernetesListBuilder contains a DeploymentConfig, Service and Route and DeploymentConfig contains only one container in PodTemplateSpec; Somehow the visit(ContainerBuilder method is invoked twice. Ideally, it should be done once only. This causes no containerBuilder to be returned for probe enrichment.

What's more strange is that I'm struggling to reproduce this via a unit test with same DeploymentConfig contents. For example, this unit test is passing:

    @Test
    public void enrichSingleContainerInOpenShift() {
        KubernetesListBuilder list = new KubernetesListBuilder().addToItems(new DeploymentConfigBuilder()
                .withNewMetadata()
                .addToLabels("app.openshift.io/vcs-ref", "master")
                .addToLabels("jkube.io/git-url", "git@github.com:rohanKanojia/eclipse-jkube-demo-project.git")
                .addToLabels("app.openshift.io/vcs-uri", "git@github.com:rohanKanojia/eclipse-jkube-demo-project.git")
                .addToLabels("jkube.io/git-commit", "40b69fc860db02bcbd02dc31e27791b48ccdd4dd")
                .addToLabels("jkube.io/git-branch", "master")
                .addToLabels("jkube.io/scm-url", "https://github.com/spring-projects/spring-boot/random-generator")
                .addToLabels("jkube.io/scm-tag", "HEAD")
                .withName("test-project")
                .endMetadata()
                .withNewSpec()
                .withReplicas(1)
                .addToSelector("app", "test-project")
                .addToSelector("provider", "jkube")
                .addToSelector("group", "meetup")
                .withNewStrategy()
                .withNewRollingParams().withTimeoutSeconds(3600L).endRollingParams()
                .withType("Rolling")
                .endStrategy()
                .withNewTemplate()
                .withNewSpec()
                .addNewContainer()
                .withName("app")
                .withImage("app:latest")
                .withImagePullPolicy("IfNotPresent")
                .addNewEnv()
                .withName("KUBERNETES_NAMESPACE")
                .withNewValueFrom().withNewFieldRef().withFieldPath(".metadata.namespace").endFieldRef().endValueFrom()
                .endEnv()
                .withNewSecurityContext().withPrivileged(false).endSecurityContext()
                .addNewPort().withContainerPort(8080).withName("http").withProtocol("TCP").endPort()
                .addNewPort().withContainerPort(9779).withName("prometheus").withProtocol("TCP").endPort()
                .addNewPort().withContainerPort(8778).withName("jolokia").withProtocol("TCP").endPort()
                .endContainer()
                .endSpec()
                .endTemplate()
                .addNewTrigger()
                .withType("ConfigChange")
                .endTrigger()
                .endSpec());

        createEnricher(new Properties(), Collections.emptyMap()).create(PlatformMode.openshift, list);

        final AtomicInteger containerFound = new AtomicInteger(0);
        list.accept(new TypedVisitor<ContainerBuilder>() {
            @Override
            public void visit(ContainerBuilder container) {
                assertNotNull(container.build().getLivenessProbe());
                assertNotNull(container.build().getReadinessProbe());
                containerFound.incrementAndGet();
            }
        });

        assertEquals(1, containerFound.get());
    }

I do have a fix for this issue but I'm not sure if it's the right fix or not. I'll continue working on this to reproduce it via unit test.

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 1, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 2, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 2, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 2, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 2, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 2, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 2, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 2, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 3, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 3, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 3, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Mar 7, 2022
…l` fragment is used (eclipse-jkube#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit that referenced this issue Mar 9, 2022
…l` fragment is used (#1295)

Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder>
is visiting ContainerBuilder twice instead of visiting it once. This is
generating list with duplicate ContainerBuilder elements.

Move DeploymentConfigEnricher lower than Health Check enrichers in order
to do conversion after health checks have been added to Deployment.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa added this to the 1.8.0 milestone Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants