{
  "repo": "pingcap/tidb-operator",
  "binary": "operator",
  "binary_path": "cmd/operator/main.go",
  "surface_kind": "controller_service",
  "type": "controller_service",
  "services": [
    {
      "name": "OperatorLifecycle",
      "package": "cmd/operator",
      "methods": [
        {
          "name": "ParseFlagsAndLogger",
          "name_key": "Runtime OperatorLifecycle.ParseFlagsAndLogger",
          "input": "metrics-bind-address, health-probe-bind-address, leader-elect, max-concurrent-reconciles, and zap logging flags",
          "output": "parsed startup flags and configured controller-runtime logger",
          "type": "local"
        },
        {
          "name": "InitFeatureGatesAndPanicMetric",
          "name_key": "Runtime OperatorLifecycle.InitFeatureGatesAndPanicMetric",
          "input": "controller-runtime kubeconfig",
          "output": "feature gates initialized and controller panic metric hook installed",
          "type": "local"
        },
        {
          "name": "CreateManager",
          "name_key": "Runtime OperatorLifecycle.CreateManager",
          "input": "rest config, cache selectors, custom client factory, leader-election settings, and metrics/probe addresses",
          "output": "controller-runtime manager with filtered cache, custom client, metrics listener, and probe listener",
          "type": "local"
        },
        {
          "name": "AddFieldIndexers",
          "name_key": "Runtime OperatorLifecycle.AddFieldIndexers",
          "input": "controller-runtime manager field indexer",
          "output": "spec.cluster.name indexers for PDGroup, TiKVGroup, TiDBGroup, and TiFlashGroup",
          "type": "local"
        },
        {
          "name": "CreatePDClientManager",
          "name_key": "Runtime OperatorLifecycle.CreatePDClientManager",
          "input": "controller-runtime client and logger",
          "output": "PD client manager with store and member pollers",
          "type": "local"
        },
        {
          "name": "CreateVolumeModifier",
          "name_key": "Runtime OperatorLifecycle.CreateVolumeModifier",
          "input": "AWS default config chain, controller-runtime client, and logger",
          "output": "AWS raw volume modifier when config loads, otherwise native Kubernetes modifier",
          "type": "local"
        },
        {
          "name": "RegisterControllers",
          "name_key": "Runtime OperatorLifecycle.RegisterControllers",
          "input": "manager, shared client, PD client manager, and volume modifier",
          "output": "nine controllers registered into the controller-runtime manager",
          "type": "local"
        },
        {
          "name": "RegisterHealthChecks",
          "name_key": "Runtime OperatorLifecycle.RegisterHealthChecks",
          "input": "manager",
          "output": "healthz and readyz checks added to the probe listener",
          "type": "local"
        },
        {
          "name": "StartRuntimes",
          "name_key": "Runtime OperatorLifecycle.StartRuntimes",
          "input": "background context and signal-aware manager runtime",
          "output": "PD client manager pollers started and controller-runtime manager enters reconcile loop",
          "type": "local"
        }
      ]
    },
    {
      "name": "OperatorHTTP",
      "package": "cmd/operator",
      "type": "http",
      "methods": [
        {
          "name": "GET /metrics",
          "name_key": "HTTP GET /metrics",
          "path": "/metrics",
          "http_method": "GET",
          "input": "none",
          "output": "Prometheus metrics for controller-runtime and custom operator metrics",
          "type": "http"
        },
        {
          "name": "GET /healthz",
          "name_key": "HTTP GET /healthz",
          "path": "/healthz",
          "http_method": "GET",
          "input": "none",
          "output": "health probe result",
          "type": "http"
        },
        {
          "name": "GET /readyz",
          "name_key": "HTTP GET /readyz",
          "path": "/readyz",
          "http_method": "GET",
          "input": "none",
          "output": "readiness probe result",
          "type": "http"
        }
      ]
    },
    {
      "name": "ClusterController",
      "package": "pkg/controllers/cluster",
      "type": "kubernetes_controller",
      "methods": [
        {
          "name": "Setup",
          "name_key": "Runtime ClusterController.Setup",
          "input": "manager and shared controller-runtime client",
          "output": "Cluster reconcile loop registered with watches on Cluster plus all child group CRs",
          "type": "background_controller"
        },
        {
          "name": "Reconcile",
          "name_key": "Runtime ClusterController.Reconcile",
          "input": "Cluster namespaced name from watch events",
          "output": "Cluster status and child group topology reconciled",
          "type": "background_controller"
        }
      ]
    },
    {
      "name": "PDGroupController",
      "package": "pkg/controllers/pdgroup",
      "type": "kubernetes_controller",
      "methods": [
        {
          "name": "Setup",
          "name_key": "Runtime PDGroupController.Setup",
          "input": "manager, shared client, and PD client manager",
          "output": "PDGroup reconcile loop registered with cluster generation-change watch and PD child ownership",
          "type": "background_controller"
        },
        {
          "name": "Reconcile",
          "name_key": "Runtime PDGroupController.Reconcile",
          "input": "PDGroup namespaced name from watch events",
          "output": "PDGroup peers, services, bootstrapped bit, and status reconciled",
          "type": "background_controller"
        }
      ]
    },
    {
      "name": "PDController",
      "package": "pkg/controllers/pd",
      "type": "kubernetes_controller",
      "methods": [
        {
          "name": "Setup",
          "name_key": "Runtime PDController.Setup",
          "input": "manager, shared client, PD client manager, and volume modifier",
          "output": "PD reconcile loop registered with pod/configmap/pvc ownership, cluster watch, and PD member event source",
          "type": "background_controller"
        },
        {
          "name": "Reconcile",
          "name_key": "Runtime PDController.Reconcile",
          "input": "PD namespaced name from watch events",
          "output": "PD pod, PVC, configmap, status, and PD-member lifecycle reconciled",
          "type": "background_controller"
        }
      ]
    },
    {
      "name": "TiDBGroupController",
      "package": "pkg/controllers/tidbgroup",
      "type": "kubernetes_controller",
      "methods": [
        {
          "name": "Setup",
          "name_key": "Runtime TiDBGroupController.Setup",
          "input": "manager and shared client",
          "output": "TiDBGroup reconcile loop registered with cluster generation-change watch and TiDB child ownership",
          "type": "background_controller"
        },
        {
          "name": "Reconcile",
          "name_key": "Runtime TiDBGroupController.Reconcile",
          "input": "TiDBGroup namespaced name from watch events",
          "output": "TiDBGroup services, TiDB children, and status reconciled",
          "type": "background_controller"
        }
      ]
    },
    {
      "name": "TiDBController",
      "package": "pkg/controllers/tidb",
      "type": "kubernetes_controller",
      "methods": [
        {
          "name": "Setup",
          "name_key": "Runtime TiDBController.Setup",
          "input": "manager, shared client, and volume modifier",
          "output": "TiDB reconcile loop registered with pod/configmap/pvc ownership and cluster watch",
          "type": "background_controller"
        },
        {
          "name": "Reconcile",
          "name_key": "Runtime TiDBController.Reconcile",
          "input": "TiDB namespaced name from watch events",
          "output": "TiDB pod, PVC, configmap, labels, health, and status reconciled",
          "type": "background_controller"
        }
      ]
    },
    {
      "name": "TiKVGroupController",
      "package": "pkg/controllers/tikvgroup",
      "type": "kubernetes_controller",
      "methods": [
        {
          "name": "Setup",
          "name_key": "Runtime TiKVGroupController.Setup",
          "input": "manager and shared client",
          "output": "TiKVGroup reconcile loop registered with cluster generation-change watch and TiKV child ownership",
          "type": "background_controller"
        },
        {
          "name": "Reconcile",
          "name_key": "Runtime TiKVGroupController.Reconcile",
          "input": "TiKVGroup namespaced name from watch events",
          "output": "TiKVGroup headless service, TiKV children, and status reconciled",
          "type": "background_controller"
        }
      ]
    },
    {
      "name": "TiKVController",
      "package": "pkg/controllers/tikv",
      "type": "kubernetes_controller",
      "methods": [
        {
          "name": "Setup",
          "name_key": "Runtime TiKVController.Setup",
          "input": "manager, shared client, PD client manager, and volume modifier",
          "output": "TiKV reconcile loop registered with pod/configmap/pvc ownership, cluster watch, and PD store event source",
          "type": "background_controller"
        },
        {
          "name": "Reconcile",
          "name_key": "Runtime TiKVController.Reconcile",
          "input": "TiKV namespaced name from watch events",
          "output": "TiKV pod, PVC, configmap, store labels, leader eviction scheduler, and status reconciled",
          "type": "background_controller"
        }
      ]
    },
    {
      "name": "TiFlashGroupController",
      "package": "pkg/controllers/tiflashgroup",
      "type": "kubernetes_controller",
      "methods": [
        {
          "name": "Setup",
          "name_key": "Runtime TiFlashGroupController.Setup",
          "input": "manager and shared client",
          "output": "TiFlashGroup reconcile loop registered with cluster generation-change watch and TiFlash child ownership",
          "type": "background_controller"
        },
        {
          "name": "Reconcile",
          "name_key": "Runtime TiFlashGroupController.Reconcile",
          "input": "TiFlashGroup namespaced name from watch events",
          "output": "TiFlashGroup headless service, TiFlash children, and status reconciled",
          "type": "background_controller"
        }
      ]
    },
    {
      "name": "TiFlashController",
      "package": "pkg/controllers/tiflash",
      "type": "kubernetes_controller",
      "methods": [
        {
          "name": "Setup",
          "name_key": "Runtime TiFlashController.Setup",
          "input": "manager, shared client, PD client manager, and volume modifier",
          "output": "TiFlash reconcile loop registered with pod/configmap/pvc ownership, cluster watch, and PD store event source",
          "type": "background_controller"
        },
        {
          "name": "Reconcile",
          "name_key": "Runtime TiFlashController.Reconcile",
          "input": "TiFlash namespaced name from watch events",
          "output": "TiFlash pod, PVC, configmap, store labels, and status reconciled",
          "type": "background_controller"
        }
      ]
    }
  ],
  "extensions": {
    "notes": [
      "The binary has three runtime surfaces: controller-runtime controllers, the metrics listener on --metrics-bind-address, and the probe listener on --health-probe-bind-address.",
      "PD member and store watch events are not sourced from the Kubernetes API directly; they come from the PD client manager's background pollers after PDGroup registration succeeds.",
      "CreateVolumeModifier only decides between AWS raw-modifier and native PVC mutation at startup. Actual cloud-volume calls happen later inside PD, TiDB, TiKV, and TiFlash reconcile paths when PVC drift is detected."
    ]
  }
}
