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

Don't support running multiple KCLRun simultaneously #9

Open
jianzs opened this issue Nov 10, 2023 · 0 comments
Open

Don't support running multiple KCLRun simultaneously #9

jianzs opened this issue Nov 10, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@jianzs
Copy link

jianzs commented Nov 10, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

I've written two KCLRun objects in a single YAML file. When I run kubectl kcl run, I encounter an error.

$ kubectl kcl run -f ./bug.yml 
panic: runtime error: index out of range [2] with length 1

goroutine 1 [running]:
kcl-lang.io/krm-kcl/pkg/kio.Filter.Filter({0x140008e3880}, {0x14000121d70, 0x3, 0x3})
        kcl-lang.io/[email protected]/pkg/kio/filter.go:31 +0x180
sigs.k8s.io/kustomize/kyaml/kio.Pipeline.ExecuteWithCallback({{0x14000b9fc58, 0x1, 0x1}, {0x14000b9fc48, 0x1, 0x1}, {0x14000b9fc38, 0x1, 0x1}, 0x0}, ...)
        sigs.k8s.io/kustomize/[email protected]/kio/kio.go:137 +0x24c
sigs.k8s.io/kustomize/kyaml/kio.Pipeline.Execute({{0x1400093fc58, 0x1, 0x1}, {0x1400093fc48, 0x1, 0x1}, {0x1400093fc38, 0x1, 0x1}, 0x0})
        sigs.k8s.io/kustomize/[email protected]/kio/kio.go:104 +0x6c
kcl-lang.io/kubectl-kcl/pkg/options.(*RunOptions).Run(0x0?)
        kcl-lang.io/kubectl-kcl/pkg/options/run.go:35 +0x184
kcl-lang.io/kubectl-kcl/cmd.NewRunCmd.func1(0x14000abc600, {0x1017aacc5, 0x2, 0x2})
        kcl-lang.io/kubectl-kcl/cmd/run.go:19 +0x20
github.com/spf13/cobra.(*Command).execute(0x14000abc600, {0x14000ab9160, 0x2, 0x2})
        github.com/spf13/[email protected]/command.go:940 +0x5c8
github.com/spf13/cobra.(*Command).ExecuteC(0x14000abc000)
        github.com/spf13/[email protected]/command.go:1068 +0x35c
github.com/spf13/cobra.(*Command).Execute(0x101d5f520?)
        github.com/spf13/[email protected]/command.go:992 +0x1c
main.main()
        kcl-lang.io/kubectl-kcl/main.go:10 +0x20

However, if I run each object separately, it works fine. But the result includes two annotations for each object that KCL added itself:

annotations:
    config.kubernetes.io/index: '0'
    internal.config.kubernetes.io/index: '0'

This is the yaml including two KCLRun object.

apiVersion: v1
kind: Service
metadata:
  name: default-domain-service
  namespace: knative-serving
spec:
  clusterIP: None
  selector:
    app: default-domain
  ports:
    - name: http
      port: 80
      targetPort: 8080
  type: ClusterIP
---
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
  name: change-service-type
spec:
  params:
    annotations:
      managed-by: kubectl-kcl
  source: |
    [item | {
      if item.kind == "Service":
          spec.type = "LoadBalance"
    } for item in option("items")]
---
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
  name: add-labels
spec:
  params:
    annotations:
      managed-by: kubectl-kcl
  source: |
    [item | {
      if item.kind == "Service":
          metadata.labels = {
              app = item.metadata.name
          }
    } for item in option("items")]
---

2. What did you expect to see? (Required)

Get the correct result.

3. What did you see instead (Required)

Encountered an error.

4. What is your KCL components version? (Required)

  • kubectl-kcl 0.4.0
  • kcl 0.5.3
@jianzs jianzs added the bug Something isn't working label Nov 10, 2023
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
Development

No branches or pull requests

1 participant