Repository navigation
fix(server): keep nginx-example replicas defined on first run - #38
Merged
Merged
Conversation
KCL 0.12.8 evaluates config.replicas as Undefined when that read sits
in the same dict literal as MetadataBuilder(config) | {...}, so the
default nginx-example fails while loading Deployment.spec.replicas
(kcl-lang/kcl discussion 2126, kcl#2130). Build the workload spec
outside that dict, and read service-mixin config the same way.
KCL 0.13.1+ treats a leading underscore as module-private, which
rejects metadata.__META_* from other konfig modules and stops the
documented kcl run before it can render. Publish those constants.
Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Peefy <Peefy@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the first-run failure reported in https://github.com/orgs/kcl-lang/discussions/2126.
kcl runinexamples/appops/nginx-example/devfailed on KCL 0.12.8 (the CLI a new user had on 2026-08-23) with:at
models/kube/backend/server_backend.k.Root cause
Server.replicasalready defaults tooption("replicas") or 1. The value is not missing.ServerBackendwas readingconfig.replicasinside the same dict literal asMetadataBuilder(config) | {...}. On KCL 0.12.8 that pattern makes the sibling attribute load returnUndefined(kcl-lang/kcl#2130), and the Kubernetes Deployment schema rejectsUndefinedforreplicas. The same pattern inServiceMixincan fail the same way onconfig.workloadType.KCL 0.12.10 fixed the evaluator, and konfig #37 dropped the isolation workaround. That brought the discussion failure back for anyone still on 0.12.8. Current
mainplus the KCL the docs install today (0.13.3) fails earlier for a second reason: 0.13.1+ treats a leading underscore as module-private (kcl-lang/kcl#1576), sometadata.__META_*cannot be read from other konfig modules and the documentedkcl run -D appenv=devnever renders.Change
_specvalue, then reference it from the dict that mergesMetadataBuilder.len(config.services)andconfig.workloadTypeinServiceMixinbefore that merge.META_APP_NAME,META_APP_NAMESPACE,META_ENV_TYPE_NAME, andMETA_CLUSTER_NAME.scripts/test.shnow requiresreplicas: 1in the nginx-example output.Verified with KCL 0.12.8 (
kcl run, the discussion command) and KCL 0.13.3 (kcl mod updatethenkcl run -D appenv=dev, the documented flow). Both emit a Deployment withreplicas: 1, plus the Namespace and Service. All 20 examples inscripts/test.shpass on both versions.