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

Add multiple different resources with the same name in the pipeline for register_descendants #191

Closed
sleipnir opened this issue Feb 24, 2023 · 0 comments · Fixed by #192
Closed

Comments

@sleipnir
Copy link

sleipnir commented Feb 24, 2023

Environment

  • Bonny version: 1.1.0
  • Elixir & Erlang/OTP versions (elixir --version): 1.14 OTP 25
  • Operating system: Linux

Current behavior

My Operator doesn't seem to be applying all the descendants. My handler code is as follows:

@impl Pluggable
   def call(%Bonny.Axn{action: action} = axn, nil) when action in [:add, :modify] do
     %Bonny.Axn{resource: resource} = axn
     host_config_map = build_host_configmap(resource)
     host_resource = build_host_deploy(resource)
     host_hpa = build_host_hpa(resource)
     host_service = build_host_service(resource)

     axn
     |> Bonny.Axn.register_descendant(host_config_map)
     |> Bonny.Axn.register_descendant(host_resource)
     |> Bonny.Axn.register_descendant(host_service)
     |> Bonny.Axn.register_descendant(host_hpa)
     |> IO.inspect()
     #|> Bonny.Axn.success_event()
   end

But only configmap and hpa are generated as a result.

The IO.inspect print this:

  action: :add,
  conn: %K8s.Conn{
    cluster_name: "k3d-eigr-spawn",
    user_name: "admin@k3d-eigr-spawn",
    url: "https://0.0.0.0:37957",
    insecure_skip_tls_verify: true,
    ca_cert: <<48, 130, 1, 119, 48, 130, 1, 29, 160, 3, 2, 1, 2, 2, 1, 0, 48,
      10, 6, 8, 42, 134, 72, 206, 61, 4, 3, 2, 48, 35, 49, 33, 48, 31, 6, 3, 85,
      4, 3, 12, 24, 107, 51, ...>>,
    auth: K8s.Conn.Auth.Certificate<...>,
    middleware: %K8s.Middleware.Stack{
      request: [K8s.Middleware.Request.Initialize,
       K8s.Middleware.Request.EncodeBody],
      response: []
    },
    discovery_driver: K8s.Discovery.Driver.HTTP,
    discovery_opts: [],
    http_provider: K8s.Client.MintHTTPProvider,
    cacertfile: "/home/sleipnir/workspaces/eigr/spawn/_build/dev/lib/castore/priv/cacerts.pem"
  },
  resource: %{
    "apiVersion" => "spawn-eigr.io/v1",
    "kind" => "ActorHost",
    "metadata" => %{
      "annotations" => %{
        "kubectl.kubernetes.io/last-applied-configuration" => "{\"apiVersion\":\"spawn-eigr.io/v1\",\"kind\":\"ActorHost\",\"metadata\":{\"annotations\":{\"spawn-eigr.io/actor-system\":\"spawn-system\",\"spawn-eigr.io/sidecar-http-port\":\"9001\"},\"name\":\"spawn-springboot-example\",\"namespace\":\"default\"},\"spec\":{\"host\":{\"image\":\"eigr/spawn-springboot-examples:0.5.3\",\"ports\":[{\"containerPort\":8090,\"name\":\"http\"},{\"containerPort\":8091,\"name\":\"https\"}]}}}\n",
        "spawn-eigr.io/actor-system" => "spawn-system",
        "spawn-eigr.io/sidecar-http-port" => "9001"
      },
      "creationTimestamp" => "2023-02-23T23:37:04Z",
      "generation" => 1,
      "managedFields" => [
        %{
          "apiVersion" => "spawn-eigr.io/v1",
          "fieldsType" => "FieldsV1",
          "fieldsV1" => %{
            "f:metadata" => %{
              "f:annotations" => %{
                "." => %{},
                "f:kubectl.kubernetes.io/last-applied-configuration" => %{},
                "f:spawn-eigr.io/actor-system" => %{},
                "f:spawn-eigr.io/sidecar-http-port" => %{}
              }
            },
            "f:spec" => %{
              "." => %{},
              "f:host" => %{"." => %{}, "f:image" => %{}, "f:ports" => %{}}
            }
          },
          "manager" => "kubectl-client-side-apply",
          "operation" => "Update",
          "time" => "2023-02-23T23:37:04Z"
        }
      ],
      "name" => "spawn-springboot-example",
      "namespace" => "default",
      "resourceVersion" => "1238",
      "uid" => "20c93918-1c61-486b-a470-ef9f7d5b0f1f"
    },
    "spec" => %{
      "host" => %{
        "image" => "eigr/spawn-springboot-examples:0.5.3",
        "ports" => [
          %{"containerPort" => 8090, "name" => "http"},
          %{"containerPort" => 8091, "name" => "https"}
        ]
      }
    }
  },
  controller: {SpawnOperator.Controller.ActorHostController, []},
  status: nil,
  assigns: %{},
  private: %{
    before_apply_descendants: [#Function<2.82424931/2 in Bonny.Pluggable.Logger.call/2>],
    before_apply_status: [#Function<1.82424931/2 in Bonny.Pluggable.Logger.call/2>],
    before_emit_event: [#Function<3.82424931/2 in Bonny.Pluggable.Logger.call/2>]
  },
  descendants: %{
    {"default", "spawn-springboot-example"} => %{
      "apiVersion" => "autoscaling/v2",
      "kind" => "HorizontalPodAutoscaler",
      "metadata" => %{
        "labels" => %{
          "actor-system" => "spawn-system",
          "app" => "spawn-springboot-example"
        },
        "name" => "spawn-springboot-example",
        "namespace" => "default",
        "ownerReferences" => [
          %{
            "apiVersion" => "spawn-eigr.io/v1",
            "blockOwnerDeletion" => false,
            "controller" => true,
            "kind" => "ActorHost",
            "name" => "spawn-springboot-example",
            "uid" => "20c93918-1c61-486b-a470-ef9f7d5b0f1f"
          }
        ]
      },
      "spec" => %{
        "maxReplicas" => 8,
        "metrics" => [
          %{
            "resource" => %{
              "name" => "cpu",
              "target" => %{"averageUtilization" => 80, "type" => "Utilization"}
            },
            "type" => "Resource"
          },
          %{
            "resource" => %{
              "name" => "memory",
              "target" => %{
                "averageUtilization" => 70,
                "type" => "AverageValue"
              }
            },
            "type" => "Resource"
          }
        ],
        "minReplicas" => 1,
        "scaleTargetRef" => %{
          "apiVersion" => "apps/v1",
          "kind" => "Deployment",
          "name" => "spawn-springboot-example"
        }
      }
    },
    {"default", "spawn-springboot-example-sidecar-cm"} => %{
      "apiVersion" => "v1",
      "data" => %{
        "PROXY_APP_NAME" => "spawn-springboot-example",
        "PROXY_CLUSTER_POLLING" => "3000",
        "PROXY_CLUSTER_STRATEGY" => "kubernetes-dns",
        "PROXY_DEPLOYMENT_MODE" => "sidecar",
        "PROXY_HEADLESS_SERVICE" => "system-spawn-system",
        "PROXY_HEARTBEAT_INTERVAL" => "240000",
        "PROXY_HOST_INTERFACE" => "http",
        "PROXY_HTTP_PORT" => "9001",
        "PROXY_ROOT_TEMPLATE_PATH" => "/home/app",
        "PROXY_UDS_ADDRESS" => "/var/run/spawn.sock",
        "PROXY_UDS_ENABLED" => "false",
        "SPAWN_CONSOLE_METRICS" => "true",
        "SPAWN_DISABLE_METRICS" => "false",
        "SPAWN_PUBSUB_NATS_AUTH" => "false",
        "SPAWN_PUBSUB_NATS_AUTH_JWT" => "",
        "SPAWN_PUBSUB_NATS_AUTH_PASS" => "admin",
        "SPAWN_PUBSUB_NATS_AUTH_TYPE" => "simple",
        "SPAWN_PUBSUB_NATS_AUTH_USER" => "admin",
        "SPAWN_PUBSUB_NATS_TLS" => "false",
        "USER_FUNCTION_HOST" => "0.0.0.0",
        "USER_FUNCTION_PORT" => "8090"
      },
      "kind" => "ConfigMap",
      "metadata" => %{
        "name" => "spawn-springboot-example-sidecar-cm",
        "namespace" => "default",
        "ownerReferences" => [
          %{
            "apiVersion" => "spawn-eigr.io/v1",
            "blockOwnerDeletion" => false,
            "controller" => true,
            "kind" => "ActorHost",
            "name" => "spawn-springboot-example",
            "uid" => "20c93918-1c61-486b-a470-ef9f7d5b0f1f"
          }
        ]
      }
    }
  },
  events: [],
  halted: false,
  operator: SpawnOperator.Operator,
  states: 0
}

Expected behavior

I hope the features are created as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant