mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
fix(application-controller): Fix panic error when trying to scale application controller shards (#15725)
* Added error checking to determine if application controller deployment is found or not Signed-off-by: Anand Francis Joseph <anjoseph@redhat.com> * Fixed the informer to list deployments in namespace scope Signed-off-by: Anand Francis Joseph <anjoseph@redhat.com> * Fixed readiness check probe for application controller when running as deployment Signed-off-by: Anand Francis Joseph <anjoseph@redhat.com> --------- Signed-off-by: Anand Francis Joseph <anjoseph@redhat.com>
This commit is contained in:
parent
b44400fa00
commit
0386027fd9
3 changed files with 11 additions and 6 deletions
|
|
@ -219,7 +219,7 @@ func getClusterFilter(kubeClient *kubernetes.Clientset, settingsMgr *settings.Se
|
|||
appControllerDeployment, err := kubeClient.AppsV1().Deployments(settingsMgr.GetNamespace()).Get(context.Background(), applicationControllerName, metav1.GetOptions{})
|
||||
|
||||
// if the application controller deployment was not found, the Get() call returns an empty Deployment object. So, set the variable to nil explicitly
|
||||
if kubeerrors.IsNotFound(err) {
|
||||
if err != nil && kubeerrors.IsNotFound(err) {
|
||||
appControllerDeployment = nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -208,14 +208,18 @@ func NewApplicationController(
|
|||
},
|
||||
})
|
||||
|
||||
factory := informers.NewSharedInformerFactory(ctrl.kubeClientset, defaultDeploymentInformerResyncDuration)
|
||||
factory := informers.NewSharedInformerFactoryWithOptions(ctrl.kubeClientset, defaultDeploymentInformerResyncDuration, informers.WithNamespace(settingsMgr.GetNamespace()))
|
||||
deploymentInformer := factory.Apps().V1().Deployments()
|
||||
|
||||
readinessHealthCheck := func(r *http.Request) error {
|
||||
applicationControllerName := env.StringFromEnv(common.EnvAppControllerName, common.DefaultApplicationControllerName)
|
||||
appControllerDeployment, err := deploymentInformer.Lister().Deployments(settingsMgr.GetNamespace()).Get(applicationControllerName)
|
||||
if !kubeerrors.IsNotFound(err) {
|
||||
return fmt.Errorf("error retrieving Application Controller Deployment: %s", err)
|
||||
if err != nil {
|
||||
if kubeerrors.IsNotFound(err) {
|
||||
appControllerDeployment = nil
|
||||
} else {
|
||||
return fmt.Errorf("error retrieving Application Controller Deployment: %s", err)
|
||||
}
|
||||
}
|
||||
if appControllerDeployment != nil {
|
||||
if appControllerDeployment.Spec.Replicas != nil && int(*appControllerDeployment.Spec.Replicas) <= 0 {
|
||||
|
|
|
|||
|
|
@ -152,8 +152,9 @@ func StripCRLFCharacter(input string) string {
|
|||
func (db *db) GetApplicationControllerReplicas() int {
|
||||
// get the replicas from application controller deployment, if the application controller deployment does not exist, check for environment variable
|
||||
applicationControllerName := env.StringFromEnv(common.EnvAppControllerName, common.DefaultApplicationControllerName)
|
||||
appControllerDeployment, _ := db.kubeclientset.AppsV1().Deployments(db.settingsMgr.GetNamespace()).Get(context.Background(), applicationControllerName, metav1.GetOptions{})
|
||||
if appControllerDeployment != nil {
|
||||
appControllerDeployment, err := db.kubeclientset.AppsV1().Deployments(db.settingsMgr.GetNamespace()).Get(context.Background(), applicationControllerName, metav1.GetOptions{})
|
||||
|
||||
if err == nil && appControllerDeployment.Spec.Replicas != nil {
|
||||
return int(*appControllerDeployment.Spec.Replicas)
|
||||
}
|
||||
return env.ParseNumFromEnv(common.EnvControllerReplicas, 0, 0, math.MaxInt32)
|
||||
|
|
|
|||
Loading…
Reference in a new issue