{
  "repo": "tidbcloud/autoscaler",
  "binary": "cluster-autoscaler",
  "binary_path": "cluster-autoscaler/main.go",
  "dependencies": {
    "ClusterAutoscalerLifecycle.LoadFlags": {
      "infrastructure": {},
      "services": []
    },
    "ClusterAutoscalerLifecycle.InitLogging": {
      "infrastructure": {},
      "services": []
    },
    "ClusterAutoscalerLifecycle.ValidateLoggingConfig": {
      "infrastructure": {},
      "services": []
    },
    "ClusterAutoscalerLifecycle.InitHealthCheck": {
      "infrastructure": {},
      "services": []
    },
    "ClusterAutoscalerLifecycle.InitDebuggingSnapshotter": {
      "infrastructure": {},
      "services": []
    },
    "ClusterAutoscalerLifecycle.StartupMetricsServer": {
      "infrastructure": {
        "http_server": {
          "conditions": [
            "Always after healthCheck and debuggingSnapshotter initialization"
          ],
          "operations": [
            {
              "operation": "LISTEN_AND_SERVE",
              "trigger": "Start the dedicated HTTP server that exposes metrics and optional debug handlers",
              "conditions": [
                "Always in the metrics goroutine"
              ],
              "implementation": "http.ListenAndServe(*address, pathRecorderMux)"
            }
          ]
        }
      },
      "services": []
    },
    "ClusterAutoscalerLifecycle.BuildAutoscaler": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": [
            "--enable-provisioning-requests == true"
          ],
          "operations": [
            {
              "operation": "LIST_WATCH",
              "trigger": "Warm ProvisioningRequest informer state used by the provisioning-request client",
              "conditions": [
                "Only when provisioning requests are enabled"
              ],
              "implementation": "provreqclient.NewProvisioningRequestClient(restConfig) -> newPRsLister(...) -> factory.Start(stopChannel) -> factory.WaitForCacheSync(stopChannel)"
            },
            {
              "operation": "LIST_WATCH",
              "trigger": "Warm PodTemplate informer state used to resolve ProvisioningRequest pod templates",
              "conditions": [
                "Only when provisioning requests are enabled"
              ],
              "implementation": "provreqclient.NewProvisioningRequestClient(restConfig) -> newPodTemplatesLister(...) -> factory.Start(stopChannel) -> factory.WaitForCacheSync(stopChannel)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cloud-provider",
          "target_interface": "cloudprovider.CloudProvider",
          "operation_type": "in_process",
          "conditions": [
            "Always while building the autoscaler default options"
          ],
          "operations": [
            {
              "operation": "BUILD_PROVIDER",
              "trigger": "Construct the cloud-provider implementation selected by the startup flags",
              "conditions": [
                "Always during initializeDefaultOptions"
              ],
              "implementation": "cloudBuilder.NewCloudProvider(opts.AutoscalingOptions, informerFactory)"
            }
          ]
        }
      ]
    },
    "ClusterAutoscalerLifecycle.StartPodObserver": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": [
            "Always after BuildAutoscaler succeeds"
          ],
          "operations": [
            {
              "operation": "LIST_WATCH",
              "trigger": "Observe newly unschedulable pods to trigger immediate autoscaler loops",
              "conditions": [
                "Always while the process is running"
              ],
              "implementation": "loop.StartPodObserver(context, kube_util.CreateKubeClient(...)) -> cache.NewListWatchFromClient(..., podsResource, apiv1.NamespaceAll, unschedulablePodSelector)"
            }
          ]
        }
      },
      "services": []
    },
    "ClusterAutoscalerLifecycle.RegisterSignalHandlers": {
      "infrastructure": {},
      "services": []
    },
    "ClusterAutoscalerLifecycle.StartHealthMonitoring": {
      "infrastructure": {},
      "services": []
    },
    "ClusterAutoscalerLifecycle.StartBackgroundComponents": {
      "infrastructure": {
        "scheduler": {
          "conditions": [
            "BuildAutoscaler succeeded"
          ],
          "operations": [
            {
              "operation": "START_BACKGROUND_COMPONENT",
              "trigger": "Start autoscaler background components before entering the main loop",
              "conditions": [
                "Always after the autoscaler instance is built"
              ],
              "implementation": "autoscaler.Start() -> a.clusterStateRegistry.Start()"
            }
          ]
        }
      },
      "services": []
    },
    "ClusterAutoscalerLifecycle.RunAutoscalerLoop": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": [
            "This process is running as leader or leader election is disabled"
          ],
          "operations": [
            {
              "operation": "LIST",
              "trigger": "Validate and snapshot current cluster state for each autoscaler iteration",
              "conditions": [
                "Always on every loop iteration"
              ],
              "implementation": "StaticAutoscaler.obtainNodeLists() -> AllNodeLister().List(), ReadyNodeLister().List(); ListerRegistry.DaemonSetLister().List(...); PodDisruptionBudgetLister().List()"
            },
            {
              "operation": "UPDATE/PATCH/DELETE",
              "trigger": "Actuate scale-down and cleanup node taints during autoscaling",
              "conditions": [
                "Only on cleanup or scale-down paths"
              ],
              "implementation": "taints.CleanAllToBeDeleted(...), taints.CleanAllDeletionCandidates(...), scaleDownActuator and node deletion paths inside StaticAutoscaler.RunOnce(...)"
            },
            {
              "operation": "WRITE",
              "trigger": "Persist autoscaler status into the status ConfigMap",
              "conditions": [
                "--write-status-configmap == true"
              ],
              "implementation": "utils.WriteStatusConfigMap(autoscalingContext.ClientSet, autoscalingContext.ConfigNamespace, ...)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cloud-provider-refresh",
          "target_interface": "cloudprovider.CloudProvider.Refresh",
          "operation_type": "in_process",
          "conditions": [
            "Always on every autoscaler iteration"
          ],
          "operations": [
            {
              "operation": "REFRESH",
              "trigger": "Refresh cloud-provider state before scale-up or scale-down decisions",
              "conditions": [
                "Always on every loop iteration"
              ],
              "implementation": "a.AutoscalingContext.CloudProvider.Refresh()"
            }
          ]
        },
        {
          "name": "cloud-provider-nodegroups",
          "target_interface": "cloudprovider.CloudProvider.NodeGroups",
          "operation_type": "in_process",
          "conditions": [
            "Cloud provider refresh succeeded"
          ],
          "operations": [
            {
              "operation": "LIST_NODE_GROUPS",
              "trigger": "Read node group min, max, and existing-state data for scale calculations",
              "conditions": [
                "Always after CloudProvider.Refresh() succeeds"
              ],
              "implementation": "a.AutoscalingContext.CloudProvider.NodeGroups()"
            }
          ]
        },
        {
          "name": "cloud-provider-scale-up",
          "target_interface": "cloudprovider.NodeGroup.IncreaseSize",
          "operation_type": "in_process",
          "conditions": [
            "A scale-up plan was selected"
          ],
          "operations": [
            {
              "operation": "INCREASE_SIZE",
              "trigger": "Scale up the selected node group",
              "conditions": [
                "Only on successful scale-up paths"
              ],
              "implementation": "nodeGroup.IncreaseSize(delta)"
            }
          ]
        },
        {
          "name": "cloud-provider-scale-down",
          "target_interface": "cloudprovider.NodeGroup.DecreaseTargetSize/DeleteNodes",
          "operation_type": "in_process",
          "conditions": [
            "Scale-down planner selected removable nodes"
          ],
          "operations": [
            {
              "operation": "DECREASE_TARGET_SIZE",
              "trigger": "Reduce node-group target size before deleting scaled-down nodes",
              "conditions": [
                "Only on scale-down actuation paths"
              ],
              "implementation": "nodeGroup.DecreaseTargetSize(delta)"
            },
            {
              "operation": "DELETE_NODES",
              "trigger": "Delete scaled-down nodes from the node group",
              "conditions": [
                "Only when node deletion is approved"
              ],
              "implementation": "nodeGroup.DeleteNodes(nodes)"
            }
          ]
        }
      ]
    },
    "ClusterAutoscalerLifecycle.ValidateKubernetesConnection": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": [
            "leaderElection.LeaderElect == true"
          ],
          "operations": [
            {
              "operation": "LIST",
              "trigger": "Verify that the Kubernetes client can reach the API server before leader election starts",
              "conditions": [
                "Only when leader election is enabled"
              ],
              "implementation": "kubeClient.CoreV1().Nodes().List(ctx.TODO(), metav1.ListOptions{})"
            }
          ]
        }
      },
      "services": []
    },
    "ClusterAutoscalerLifecycle.StartLeaderElection": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": [
            "leaderElection.LeaderElect == true"
          ],
          "operations": [
            {
              "operation": "CREATE/GET/UPDATE",
              "trigger": "Create and maintain the leader-election lease lock",
              "conditions": [
                "Only when leader election is enabled"
              ],
              "implementation": "resourcelock.New(..., kubeClient.CoreV1(), kubeClient.CoordinationV1(), ...); leaderelection.RunOrDie(...)"
            },
            {
              "operation": "POST",
              "trigger": "Publish leader-election events to the Kubernetes events API",
              "conditions": [
                "Only when leader election is enabled"
              ],
              "implementation": "kube_util.CreateEventRecorder(kubeClient, *recordDuplicatedEvents)"
            }
          ]
        }
      },
      "services": []
    },
    "ClusterAutoscalerLifecycle.ExitCleanUp": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": [
            "Process received a shutdown signal or is otherwise exiting"
          ],
          "operations": [
            {
              "operation": "DELETE",
              "trigger": "Delete the status ConfigMap on process shutdown",
              "conditions": [
                "--write-status-configmap == true"
              ],
              "implementation": "utils.DeleteStatusConfigMap(a.AutoscalingContext.ClientSet, a.AutoscalingContext.ConfigNamespace, a.AutoscalingContext.StatusConfigMapName)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cloud-provider-cleanup",
          "target_interface": "cloudprovider.CloudProvider.Cleanup",
          "operation_type": "in_process",
          "conditions": [
            "WriteStatusConfigMap path was not short-circuited"
          ],
          "operations": [
            {
              "operation": "CLEANUP",
              "trigger": "Release cloud-provider resources on autoscaler exit",
              "conditions": [
                "Only when WriteStatusConfigMap is enabled and ExitCleanUp reaches the cleanup tail"
              ],
              "implementation": "a.CloudProvider.Cleanup()"
            }
          ]
        }
      ]
    },
    "DebugHTTP.Metrics": {
      "infrastructure": {},
      "services": []
    },
    "DebugHTTP.HealthCheck": {
      "infrastructure": {},
      "services": []
    },
    "DebugHTTP.DebuggingSnapshot": {
      "infrastructure": {},
      "services": []
    },
    "DebugHTTP.PProf": {
      "infrastructure": {},
      "services": []
    }
  }
}
