()
| 41 | const _operatorPortStr = "8888" |
| 42 | |
| 43 | func main() { |
| 44 | if err := config.Init(); err != nil { |
| 45 | exit.ErrorNoTelemetry(errors.Wrap(err, "init")) |
| 46 | } |
| 47 | |
| 48 | telemetry.Event("operator.init") |
| 49 | |
| 50 | cron.Run(operator.DeleteEvictedPods, operator.ErrorHandler("delete evicted pods"), time.Hour) |
| 51 | cron.Run(operator.ClusterTelemetry, operator.ErrorHandler("instance telemetry"), 1*time.Hour) |
| 52 | cron.Run(operator.CostBreakdown, operator.ErrorHandler("cost breakdown metrics"), 5*time.Minute) |
| 53 | |
| 54 | _, err := operator.UpdateMemoryCapacityConfigMap() |
| 55 | if err != nil { |
| 56 | exit.Error(errors.Wrap(err, "init")) |
| 57 | } |
| 58 | |
| 59 | cron.Run(taskapi.ManageJobResources, operator.ErrorHandler("manage task jobs"), taskapi.ManageJobResourcesCronPeriod) |
| 60 | |
| 61 | deployments, err := config.K8s.ListDeploymentsWithLabelKeys("apiName") |
| 62 | if err != nil { |
| 63 | exit.Error(errors.Wrap(err, "init")) |
| 64 | } |
| 65 | |
| 66 | for i := range deployments { |
| 67 | deployment := deployments[i] |
| 68 | apiKind := deployment.Labels["apiKind"] |
| 69 | switch apiKind { |
| 70 | case userconfig.AsyncAPIKind.String(): |
| 71 | if err := asyncapi.UpdateAPIMetricsCron(&deployment); err != nil { |
| 72 | operatorLogger.Fatal(errors.Wrap(err, "init")) |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | router := mux.NewRouter() |
| 78 | |
| 79 | routerWithoutAuth := router.NewRoute().Subrouter() |
| 80 | routerWithoutAuth.Use(endpoints.PanicMiddleware) |
| 81 | routerWithoutAuth.HandleFunc("/verifycortex", endpoints.VerifyCortex).Methods("GET") |
| 82 | |
| 83 | routerWithoutAuth.HandleFunc("/batch/{apiName}", endpoints.SubmitBatchJob).Methods("POST") |
| 84 | routerWithoutAuth.HandleFunc("/batch/{apiName}", endpoints.GetBatchJob).Methods("GET") |
| 85 | routerWithoutAuth.HandleFunc("/batch/{apiName}", endpoints.StopBatchJob).Methods("DELETE") |
| 86 | routerWithoutAuth.HandleFunc("/tasks/{apiName}", endpoints.SubmitTaskJob).Methods("POST") |
| 87 | routerWithoutAuth.HandleFunc("/tasks/{apiName}", endpoints.GetTaskJob).Methods("GET") |
| 88 | routerWithoutAuth.HandleFunc("/tasks/{apiName}", endpoints.StopTaskJob).Methods("DELETE") |
| 89 | |
| 90 | // prometheus metrics |
| 91 | routerWithoutAuth.Handle("/metrics", promhttp.Handler()).Methods("GET") |
| 92 | |
| 93 | routerWithAuth := router.NewRoute().Subrouter() |
| 94 | |
| 95 | routerWithAuth.Use(endpoints.PanicMiddleware) |
| 96 | routerWithAuth.Use(endpoints.APIVersionCheckMiddleware) |
| 97 | routerWithAuth.Use(endpoints.AWSAuthMiddleware) |
| 98 | routerWithAuth.Use(endpoints.ClientIDMiddleware) |
| 99 | |
| 100 | routerWithAuth.HandleFunc("/info", endpoints.Info).Methods("GET") |
nothing calls this directly
no test coverage detected