Skip to content

Commit

Permalink
Fixed nil pointer runtime panic error (argoproj-labs#1015)
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Cai <[email protected]>
  • Loading branch information
ciiay authored Oct 6, 2023
1 parent 5d6261d commit fdbc053
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion controllers/argocd/applicationset/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (asr *ApplicationSetReconciler) reconcileDeployment() error {
existingDeployment, err := workloads.GetDeployment(desiredDeployment.Name, desiredDeployment.Namespace, asr.Client)
if err != nil {
if !errors.IsNotFound(err) {
asr.Logger.Error(err, "reconcileDeployment: failed to retrieve deployment", "name", existingDeployment.Name, "namespace", existingDeployment.Namespace)
asr.Logger.Error(err, "reconcileDeployment: failed to retrieve deployment", "name", desiredDeployment.Name, "namespace", desiredDeployment.Namespace)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/argocd/applicationset/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (asr *ApplicationSetReconciler) reconcileRole() error {
existingRole, err := permissions.GetRole(desiredRole.Name, desiredRole.Namespace, asr.Client)
if err != nil {
if !errors.IsNotFound(err) {
asr.Logger.Error(err, "reconcileRole: failed to retrieve role", "name", existingRole.Name, "namespace", existingRole.Namespace)
asr.Logger.Error(err, "reconcileRole: failed to retrieve role", "name", desiredRole.Name, "namespace", desiredRole.Namespace)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/argocd/applicationset/rolebinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (asr *ApplicationSetReconciler) reconcileRoleBinding() error {
existingRoleBinding, err := permissions.GetRoleBinding(desiredRoleBinding.Name, desiredRoleBinding.Namespace, asr.Client)
if err != nil {
if !errors.IsNotFound(err) {
asr.Logger.Error(err, "reconcileRoleBinding: failed to retrieve roleBinding", "name", existingRoleBinding.Name, "namespace", existingRoleBinding.Namespace)
asr.Logger.Error(err, "reconcileRoleBinding: failed to retrieve roleBinding", "name", desiredRoleBinding.Name, "namespace", desiredRoleBinding.Namespace)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/applicationset/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ func (asr *ApplicationSetReconciler) reconcileService() error {
return err
}

existingService, err := networking.GetService(desiredService.Name, desiredService.Namespace, asr.Client)
_, err = networking.GetService(desiredService.Name, desiredService.Namespace, asr.Client)
if err != nil {
if !errors.IsNotFound(err) {
asr.Logger.Error(err, "reconcileService: failed to retrieve service", "name", existingService.Name, "namespace", existingService.Namespace)
asr.Logger.Error(err, "reconcileService: failed to retrieve service", "name", desiredService.Name, "namespace", desiredService.Namespace)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/applicationset/serviceaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func (asr *ApplicationSetReconciler) reconcileServiceAccount() error {
return err
}

existingServiceAccount, err := permissions.GetServiceAccount(desiredServiceAccount.Name, desiredServiceAccount.Namespace, asr.Client)
_, err = permissions.GetServiceAccount(desiredServiceAccount.Name, desiredServiceAccount.Namespace, asr.Client)
if err != nil {
if !errors.IsNotFound(err) {
asr.Logger.Error(err, "reconcileServiceAccount: failed to retrieve serviceAccount", "name", existingServiceAccount.Name, "namespace", existingServiceAccount.Namespace)
asr.Logger.Error(err, "reconcileServiceAccount: failed to retrieve serviceAccount", "name", desiredServiceAccount.Name, "namespace", desiredServiceAccount.Namespace)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/notifications/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ func (nr *NotificationsReconciler) reconcileConfigMap() error {
return err
}

existingConfigMap, err := workloads.GetConfigMap(desiredConfigMap.Name, desiredConfigMap.Namespace, nr.Client)
_, err = workloads.GetConfigMap(desiredConfigMap.Name, desiredConfigMap.Namespace, nr.Client)
if err != nil {
if !errors.IsNotFound(err) {
nr.Logger.Error(err, "reconcileConfigMap: failed to retrieve configMap", "name", existingConfigMap.Name, "namespace", existingConfigMap.Namespace)
nr.Logger.Error(err, "reconcileConfigMap: failed to retrieve configMap", "name", desiredConfigMap.Name, "namespace", desiredConfigMap.Namespace)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/argocd/notifications/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (nr *NotificationsReconciler) reconcileDeployment() error {
existingDeployment, err := workloads.GetDeployment(desiredDeployment.Name, desiredDeployment.Namespace, nr.Client)
if err != nil {
if !errors.IsNotFound(err) {
nr.Logger.Error(err, "reconcileDeployment: failed to retrieve deployment", "name", existingDeployment.Name, "namespace", existingDeployment.Namespace)
nr.Logger.Error(err, "reconcileDeployment: failed to retrieve deployment", "name", desiredDeployment.Name, "namespace", desiredDeployment.Namespace)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/argocd/notifications/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (nr *NotificationsReconciler) reconcileRole() error {
existingRole, err := permissions.GetRole(desiredRole.Name, desiredRole.Namespace, nr.Client)
if err != nil {
if !errors.IsNotFound(err) {
nr.Logger.Error(err, "reconcileRole: failed to retrieve role", "name", existingRole.Name, "namespace", existingRole.Namespace)
nr.Logger.Error(err, "reconcileRole: failed to retrieve role", "name", desiredRole.Name, "namespace", desiredRole.Namespace)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/argocd/notifications/rolebinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (nr *NotificationsReconciler) reconcileRoleBinding() error {
existingRoleBinding, err := permissions.GetRoleBinding(desiredRoleBinding.Name, desiredRoleBinding.Namespace, nr.Client)
if err != nil {
if !errors.IsNotFound(err) {
nr.Logger.Error(err, "reconcileRoleBinding: failed to retrieve roleBinding", "name", existingRoleBinding.Name, "namespace", existingRoleBinding.Namespace)
nr.Logger.Error(err, "reconcileRoleBinding: failed to retrieve roleBinding", "name", desiredRoleBinding.Name, "namespace", desiredRoleBinding.Namespace)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/notifications/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ func (nr *NotificationsReconciler) reconcileSecret() error {
return err
}

existingSecret, err := workloads.GetSecret(desiredSecret.Name, desiredSecret.Namespace, nr.Client)
_, err = workloads.GetSecret(desiredSecret.Name, desiredSecret.Namespace, nr.Client)
if err != nil {
if !errors.IsNotFound(err) {
nr.Logger.Error(err, "reconcileSecret: failed to retrieve secret", "name", existingSecret.Name, "namespace", existingSecret.Namespace)
nr.Logger.Error(err, "reconcileSecret: failed to retrieve secret", "name", desiredSecret.Name, "namespace", desiredSecret.Namespace)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/notifications/serviceaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func (nr *NotificationsReconciler) reconcileServiceAccount() error {
return err
}

existingServiceAccount, err := permissions.GetServiceAccount(desiredServiceAccount.Name, desiredServiceAccount.Namespace, nr.Client)
_, err = permissions.GetServiceAccount(desiredServiceAccount.Name, desiredServiceAccount.Namespace, nr.Client)
if err != nil {
if !errors.IsNotFound(err) {
nr.Logger.Error(err, "reconcileServiceAccount: failed to retrieve serviceAccount", "name", existingServiceAccount.Name, "namespace", existingServiceAccount.Namespace)
nr.Logger.Error(err, "reconcileServiceAccount: failed to retrieve serviceAccount", "name", desiredServiceAccount.Name, "namespace", desiredServiceAccount.Namespace)
return err
}

Expand Down

0 comments on commit fdbc053

Please sign in to comment.