{"record":{"id":"a9757c8111efd393","repo":"quarkusio/quarkus","slug":"when-generating-a-cronjob-resource-you-need-to-sp","errorCode":null,"errorMessage":"When generating a CronJob resource, you need to specify a schedule CRON expression.","messagePattern":"When generating a CronJob resource, you need to specify a schedule CRON expression\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddCronJobResourceDecorator.java","lineNumber":43,"sourceCode":"        // match labels for selector\n        // for some reason, tests want null selector if not explicitly set\n        if (jobTemplateSpec.hasSelector()) {\n            initSelectorMatchLabels(jobTemplateSpec.editSelector())\n                    .endSelector();\n        }\n\n        // configure job pod and container from template\n        configurePodSpec(jobTemplateSpec.editOrNewTemplate().editOrNewSpec())\n                .endSpec().endTemplate();\n\n        spec.withSuspend(config.suspend());\n        spec.withConcurrencyPolicy(config.concurrencyPolicy().name());\n\n        config.schedule().ifPresent(spec::withSchedule);\n        // check that we end up with a schedule, either from existing resource or configuration\n        final var schedule = spec.getSchedule();\n        if (schedule == null || schedule.isBlank()) {\n            throw new IllegalArgumentException(\n                    \"When generating a CronJob resource, you need to specify a schedule CRON expression.\");\n        }\n        config.successfulJobsHistoryLimit().ifPresent(spec::withSuccessfulJobsHistoryLimit);\n        config.failedJobsHistoryLimit().ifPresent(spec::withFailedJobsHistoryLimit);\n        config.startingDeadlineSeconds().ifPresent(spec::withStartingDeadlineSeconds);\n        config.timeZone().ifPresent(spec::withTimeZone);\n\n        // init job template from config\n        initFromConfig(jobTemplateSpec, config);\n\n        jobTemplateSpec.endSpec().endJobTemplate();\n        spec.endSpec();\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":58,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddCronJobResourceDecorator.java#L25-L58","documentation":"When Quarkus generates a Kubernetes CronJob resource (quarkus.kubernetes.deployment-kind=CronJob), AddCronJobResourceDecorator must end up with a schedule in the CronJob spec. It applies quarkus.kubernetes.cron-job.<name>.schedule if present, then checks the resulting spec; if there is still no non-blank schedule — neither from an existing generated resource nor from config — it throws this IllegalArgumentException, because a CronJob without a schedule is invalid in Kubernetes.","triggerScenarios":"Building with deployment-kind CronJob (or a CronJob build item) without setting quarkus.kubernetes.cron-job.<name>.schedule (or the legacy .cron-job config), and without any pre-existing schedule in the generated spec.","commonSituations":"Switching an existing app from Deployment to CronJob and forgetting the schedule property; typos in the schedule property name; config applied to a different cron-job key than the generated one; schedule set to empty string.","solutions":["Set a CRON expression in application.properties: quarkus.kubernetes.cron-job.<name>.schedule=\"0 */5 * * *\"","Verify the schedule is under the same <name> key as your generated CronJob resource","Check you didn't leave the schedule property empty or misspelled","If the schedule should come from an existing resource, ensure that decorator/source actually runs before this check"],"exampleFix":"// before\nquarkus.kubernetes.deployment-kind=CronJob\n// after\nquarkus.kubernetes.deployment-kind=CronJob\nquarkus.kubernetes.cron-job.default.schedule=\"0 */5 * * *\"","handlingStrategy":"validation","validationCode":"// application.properties check before build\n// assert properties.containsKey(\"quarkus.kubernetes.cron-job.\" + name + \".schedule\") when deployment-kind=CronJob\nif (\"CronJob\".equals(deploymentKind) && schedule == null || schedule.isBlank()) { fail(\"CronJob requires a schedule\"); }","typeGuard":null,"tryCatchPattern":"try { quarkusBuild(); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"CronJob\")) { /* set schedule config */ } }","preventionTips":["Always set quarkus.kubernetes.cron-job.<name>.schedule when using CronJob kind","Use a valid CRON expression (5 or 6 fields)","Keep the schedule key name aligned with the resource name","CI check: build manifests and assert schedule present"],"tags":["kubernetes","cronjob","config"],"backgroundTag":"missing-cron-schedule","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}