seal-io / walrus

Walrus is an open-source application management platform based on IaC tools including OpenTofu, Terraform and others. It helps platform engineers build golden paths for developers and empowers developers with self-service capabilities.
https://seal.io
Apache License 2.0
428 stars 42 forks source link

imported resources may stuck in deploying #1810

Closed gitlawr closed 8 months ago

gitlawr commented 8 months ago

Steps to reproduce Apply the following yaml:

resources:
- name: nginx-1
  template:
    name: kubernetes-containerservice
    version: v0.1.3
  attributes:
    containers:
    - image: nginx
      ports:
      - internal: 80
        external: 80
- name: nginx-2
  template:
    name: kubernetes-containerservice
    version: v0.1.3
  attributes:
    containers:
    - image: nginx
      ports:
      - internal: 80
        external: 80
      envs:
      - name: nginx-address
        value: ${res.nginx-1.address}

Result nginx-2 stuck in Deploying

Expected behavior Deployment succeeds.

Environment

Additional context Logs:

2024-01-03T06:01:34.521Z    E   task    panic in job: github.com/seal-io/walrus/utils/cron.timeoutTask.Process-fm, recover data: failed to load subject: failed to get context: not gin context
github.com/seal-io/walrus/utils/cron.init.0.func1
    github.com/seal-io/walrus/utils@v0.0.0-00010101000000-000000000000/cron/cron.go:39
github.com/go-co-op/gocron.(*executor).run.func1.1
    github.com/go-co-op/gocron@v1.29.0/executor.go:216
runtime.gopanic
    runtime/panic.go:884
github.com/seal-io/walrus/pkg/auths/session.MustGetSubject
    github.com/seal-io/walrus/pkg/auths/session/subject.go:214
github.com/seal-io/walrus/pkg/deployer/terraform.Deployer.createRevision
    github.com/seal-io/walrus/pkg/deployer/terraform/deployer.go:505
github.com/seal-io/walrus/pkg/deployer/terraform.Deployer.Apply
    github.com/seal-io/walrus/pkg/deployer/terraform/deployer.go:113
github.com/seal-io/walrus/pkg/resource.Apply
    github.com/seal-io/walrus/pkg/resource/resource.go:99
github.com/seal-io/walrus/pkg/scheduler/resource.(*RelationshipCheckTask).deployResource
    github.com/seal-io/walrus/pkg/scheduler/resource/relationship_check_task.go:267
github.com/seal-io/walrus/pkg/scheduler/resource.(*RelationshipCheckTask).applyResources
    github.com/seal-io/walrus/pkg/scheduler/resource/relationship_check_task.go:127
github.com/seal-io/walrus/pkg/scheduler/resource.(*RelationshipCheckTask).Process
    github.com/seal-io/walrus/pkg/scheduler/resource/relationship_check_task.go:77
github.com/seal-io/walrus/utils/cron.timeoutTask.Process
    github.com/seal-io/walrus/utils@v0.0.0-00010101000000-000000000000/cron/cron.go:156
reflect.Value.call
    reflect/value.go:584
reflect.Value.Call
    reflect/value.go:368
github.com/go-co-op/gocron.callJobFuncWithParams
    github.com/go-co-op/gocron@v1.29.0/gocron.go:116
github.com/go-co-op/gocron.runJob
    github.com/go-co-op/gocron@v1.29.0/executor.go:76
github.com/go-co-op/gocron.(*executor).runJob
    github.com/go-co-op/gocron@v1.29.0/executor.go:173
github.com/go-co-op/gocron.(*executor).run.func1
    github.com/go-co-op/gocron@v1.29.0/executor.go:239
Finenyaco commented 8 months ago

Environment

Test Result:

walrus file:

resources:
- name: nginx-1
  template:
    name: kubernetes-containerservice
    version: v0.2.3
  attributes:
    containers:
    - image: nginx
      ports:
      - internal: 80
        external: 80
- name: nginx-2
  template:
    name: kubernetes-containerservice
    version: v0.2.3
  attributes:
    containers:
    - image: nginx
      ports:
      - internal: 80
        external: 80
      envs:
      - name: nginx-address
        value: ${res.nginx-1.address}