From 3f5338527b026f687a0e2bc55f88af5ae16f345e Mon Sep 17 00:00:00 2001 From: Jaideep Rao Date: Thu, 1 Feb 2024 04:41:41 -0500 Subject: [PATCH] code-refactoring: add status reconciliation to ArgoCDReconciler (#1211) * fix: don't set phase to available during host reconciliation (#918) * upgrade golangci-lint Signed-off-by: Jaideep Rao * fix phase reconciliation during host reconciliation Signed-off-by: Jaideep Rao * address review comment Signed-off-by: Jaideep Rao * set phase to pending if ingress not found Signed-off-by: Jaideep Rao --------- Signed-off-by: Jaideep Rao * update owners file (#953) * Move to only adding two roles for managed namespaces (#954) * Move to only adding two roles for managed namespaces --------- Signed-off-by: Salem Elrahal Co-authored-by: Salem Elrahal * feat: expose operator metrics (#928) Track and expose custom operator performance metrics --------- Signed-off-by: Jaideep Rao * add build.os config for readthedocs (#967) * setup 0.8.0 (#966) * feat: Add conversion webhook for ArgoCD v1alpha1 to v1beta1 migration (#964) * Add ArgoCD v1beta1 & deprecate v1alpha1 - Add new ArgoCD v1beta1 api - Mark ArgoCD v1alpha1 as deprecated & add back the removed sso fields - Use server side validation for "kubectl apply" as client side results into failure due to exceeding annotation size limit. Signed-off-by: Siddhesh Ghadi Add funcs for ArgoCD alpha to beta conversion Signed-off-by: Siddhesh Ghadi Add conversion webhook - Create webhook & setup webhook server on 9443 - Disable operator namespaced install via OLM so that OLM can handle certs for webhook server - For manual install, user needs to explicitly configure cert manager to inject certs and enable webhook server in operator by setting env ENABLE_CONVERSION_WEBHOOK="true" Signed-off-by: Siddhesh Ghadi Resolve local build issues Signed-off-by: Siddhesh Ghadi Tweak webhook configs Signed-off-by: Siddhesh Ghadi Update operator installation docs Signed-off-by: Siddhesh Ghadi Add e2e tests Signed-off-by: Siddhesh Ghadi Minor updates Signed-off-by: Siddhesh Ghadi Fix go-lint ci failure Signed-off-by: Siddhesh Ghadi Update docs Signed-off-by: Siddhesh Ghadi Remove webhook from 0.7.0 bundle Signed-off-by: Siddhesh Ghadi Add spaces in bundle Signed-off-by: Siddhesh Ghadi * update 0.8.0 bundle Signed-off-by: Siddhesh Ghadi --------- Signed-off-by: Siddhesh Ghadi * chore(deps): bump pygments from 2.7.4 to 2.15.0 in /docs (#950) Bumps [pygments](https://github.com/pygments/pygments) from 2.7.4 to 2.15.0. - [Release notes](https://github.com/pygments/pygments/releases) - [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES) - [Commits](https://github.com/pygments/pygments/compare/2.7.4...2.15.0) --- updated-dependencies: - dependency-name: pygments dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: upgrade RH-SSO from 7.5 to 7.6 (#977) * upgrade RH-SSO from 7.5 to 7.6 Signed-off-by: iam-veeramalla * fix: failing tests Signed-off-by: iam-veeramalla * fix: failing tests Signed-off-by: iam-veeramalla --------- Signed-off-by: iam-veeramalla * refactor: Remove dead code (#979) * Remove dead code Signed-off-by: Siddhesh Ghadi * Fix import Signed-off-by: Siddhesh Ghadi * Fix imports Signed-off-by: Siddhesh Ghadi --------- Signed-off-by: Siddhesh Ghadi * Replace ArgoCD v1alpha1 references with v1beta1 (#975) Signed-off-by: Siddhesh Ghadi * refactor: Remove deprecated .spec.resourceCustomizations (#973) * Remove .spec.resourceCustomizations code Signed-off-by: Siddhesh Ghadi * Update docs Signed-off-by: Siddhesh Ghadi * Update docs Signed-off-by: Siddhesh Ghadi * Address review comments Signed-off-by: Siddhesh Ghadi * Fix typo Signed-off-by: Siddhesh Ghadi --------- Signed-off-by: Siddhesh Ghadi * upgrade ArgoCD version to 2.8.2 and update the CRDs (#984) * upgrade ArgoCD version to 2.8.2 and update the CRDs Signed-off-by: ishitasequeira * Update argocd image Signed-off-by: ishitasequeira --------- Signed-off-by: ishitasequeira * chore: Update ArgoCD v1alpha1 deprecation message (#988) * Update ArgoCD v1alpha1 deprecation message Signed-off-by: Siddhesh Ghadi * Run code gen Signed-off-by: Siddhesh Ghadi --------- Signed-off-by: Siddhesh Ghadi * Add support for tls self signed certs in AppSet Gitlab SCM Provider (#985) * add support for tls self signed certs in AppSet Gitlab SCM Provider Signed-off-by: ishitasequeira * add e2e test Signed-off-by: ishitasequeira * add unit tests Signed-off-by: ishitasequeira * renamed field ScmRootCaPath to SCMRootCaPath Signed-off-by: ishitasequeira * Add documentation and address comments Signed-off-by: ishitasequeira * Address comments Signed-off-by: ishitasequeira --------- Signed-off-by: ishitasequeira * chore(deps): bump github.com/argoproj/argo-cd/v2 from 2.8.2 to 2.8.3 (#992) Bumps [github.com/argoproj/argo-cd/v2](https://github.com/argoproj/argo-cd) from 2.8.2 to 2.8.3. - [Release notes](https://github.com/argoproj/argo-cd/releases) - [Changelog](https://github.com/argoproj/argo-cd/blob/master/CHANGELOG.md) - [Commits](https://github.com/argoproj/argo-cd/compare/v2.8.2...v2.8.3) --- updated-dependencies: - dependency-name: github.com/argoproj/argo-cd/v2 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: pick up argo cd v2.8.3 (#993) Signed-off-by: iam-veeramalla * fix: replace deprecated syntax in kustomization.yaml (#1000) Signed-off-by: minchao * Missing syntax-highlighting, toggle button for screen mode in argocd-operator docs (#1002) * Update requirements.txt added markdown= 3.3.7 and markdown-include=0.6.0 Signed-off-by: Surajyadav * Delete docs/assets/extra.css deleted extra.css Signed-off-by: Surajyadav * Update mkdocs.yml added markdown_extension markdown_include with codehighlight and toggle for screen mode Signed-off-by: Surajyadav * Update mkdocs.yml Signed-off-by: Surajyadav --------- Signed-off-by: Surajyadav * fix: keycloak probes failure and intermittent perforamance issues (#1007) * fix: keycloak probes failure results in pod crash Signed-off-by: iam-veeramalla * fix: use latest keycloak image to handle performance issue Signed-off-by: iam-veeramalla --------- Signed-off-by: iam-veeramalla * bug: fix heathcheck subkey generation for resources with no group (#1013) * account for empty group during resource customization config subkey generation --------- Signed-off-by: Jaideep Rao * chore(deps): bump golang.org/x/net from 0.11.0 to 0.17.0 (#1019) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.11.0 to 0.17.0. - [Commits](https://github.com/golang/net/compare/v0.11.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add labelSelector option to filter the ArgoCD instances for reconciliation (#961) * Added labelselector string to map conversion Signed-off-by: Raghavi Shirur * Changed data-type for labelSelector to parse string Signed-off-by: Raghavi Shirur * Added code to reconcile selected ArgoCD instances based on label selector Signed-off-by: Raghavi Shirur * remove comments Signed-off-by: Raghavi Shirur * Updated argoCD label fetch, renamed env var Signed-off-by: Raghavi Shirur * Updated unit test and yaml Signed-off-by: Raghavi Shirur * Updated unit test Signed-off-by: Raghavi Shirur * Fix yaml env ValueFrom field Signed-off-by: Raghavi Shirur * Added comments and labelSelector check in main.go Signed-off-by: Raghavi Shirur * removed label-selector option from manifest Signed-off-by: Raghavi Shirur * updated label-selector format in manifests Signed-off-by: Raghavi Shirur * added label selector logs Signed-off-by: Raghavi Shirur * go mod tidy Signed-off-by: Raghavi Shirur * added e2e tests for label-selector Signed-off-by: Raghavi Shirur * restructured kuttl files and added operator patch file Signed-off-by: Raghavi Shirur * go mod tidy Signed-off-by: Raghavi Shirur * corrected kuttl tests for cm failure Signed-off-by: Raghavi Shirur * Added documentation for Environment Variable ARGOCD_LABEL_SELECTOR Signed-off-by: Raghavi Shirur * cleanup Signed-off-by: Raghavi Shirur * improved unit tests and some minor changes Signed-off-by: Raghavi Shirur * kuttl rerun Signed-off-by: Raghavi Shirur * removed env var Signed-off-by: Raghavi Shirur * misc modifications Signed-off-by: Raghavi Shirur * argocd-operator csv correction Signed-off-by: Raghavi Shirur * fix bundle error Signed-off-by: Raghavi Shirur * fix bundle error Signed-off-by: Raghavi Shirur * fix manifests build Signed-off-by: Raghavi Shirur Signed-off-by: Ishita Sequeira Signed-off-by: Raghavi Shirur * Added more unit test cases Signed-off-by: Raghavi Shirur * rebase Signed-off-by: Raghavi Shirur * removed excess reconcilers Signed-off-by: Raghavi Shirur * minor fix Signed-off-by: Raghavi Shirur * removed extraneous test case and cleaned manager.yaml Signed-off-by: Raghavi Shirur * cleaned manager.yaml Signed-off-by: Raghavi Shirur * fix make bundle issue Signed-off-by: Raghavi Shirur * fix make bundle issue Signed-off-by: Raghavi Shirur --------- Signed-off-by: Raghavi Shirur Signed-off-by: Ishita Sequeira Co-authored-by: ishitasequeira * fix: address CVE-2023-39325 (#1022) *address CVE-2023-39325 - upgrade to golang v1.20.10 - disable http/2 for webhook and metrics server, use http/1.1 by default but make it a configurable flag - upgarde k8s library packages to v0.28.3 - Add new structs for keycloak API that were previously part of the (now deprecated) keycloak-operator repo - upgrade to controller-runtime to v0.16.3 - refactor all unit tests --------- Signed-off-by: Jaideep Rao * Add gcp cherry-pick bot config (#1023) Signed-off-by: Siddhesh Ghadi * Add .github/dependabot.yml to enable auto dependency version updates (#1025) * feat(dex): add optional env field (#1005) * feat(dex): add optional env field Signed-off-by: Robert Deusser * fix: remove non-default configuration Signed-off-by: Robert Deusser * fix: v1alpha1 is deprecated Signed-off-by: Robert Deusser * fix: convert dex spec between api versions Signed-off-by: Robert Deusser * fix: ensure there is no diff in the bundle Signed-off-by: Robert Deusser --------- Signed-off-by: Robert Deusser * fix: replace deprecated AddToScheme with Install, and deprecated SchemeGroupVersion with GroupVersion. (#1066) Signed-off-by: Cheng Fang * allow enabling ArgoCD workloads independently (#1021) * allow enabling ArgoCD core workloads independently Signed-off-by: ishitasequeira * fix lint Signed-off-by: ishitasequeira * check for dependent component urls if dependent components are disabled Signed-off-by: ishitasequeira * fix build Signed-off-by: ishitasequeira * fix make bundle Signed-off-by: ishitasequeira * fix tests Signed-off-by: ishitasequeira * Update flags for each component Signed-off-by: ishitasequeira * Update configuration using remote flag Signed-off-by: ishitasequeira * fix CI Signed-off-by: ishitasequeira * Address comments Signed-off-by: ishitasequeira * Addressed feedback Signed-off-by: ishitasequeira * update conversion webhook Signed-off-by: ishitasequeira * fix make build Signed-off-by: ishitasequeira --------- Signed-off-by: ishitasequeira * chore(deps): bump argoproj/argocd in /build/util (#1080) Bumps argoproj/argocd from `d40da8f` to `644c386`. --- updated-dependencies: - dependency-name: argoproj/argocd dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: upgrade Argo CD for release v.9.0 (#1082) * feat: upgrade Argo CD for release v.9.0 Signed-off-by: iam-veeramalla * fix: unit test failures Signed-off-by: iam-veeramalla --------- Signed-off-by: iam-veeramalla * fix the logic for applicationset resources reconcilation when spec.applicationset.enabled is false (#1089) * fix the logic for applicationset resources reconciliation when spec.applicationset.enabled is false Signed-off-by: ishitasequeira Signed-off-by: Raghavi Shirur Signed-off-by: ishitasequeira * fix tests Signed-off-by: ishitasequeira Signed-off-by: Raghavi Shirur Signed-off-by: ishitasequeira * delete repo server when repo.enabled is set to false Signed-off-by: ishitasequeira Signed-off-by: Raghavi Shirur Signed-off-by: ishitasequeira * Update status.Phase based on component enabled flag Signed-off-by: ishitasequeira Signed-off-by: Raghavi Shirur Signed-off-by: ishitasequeira * Added kuttl tests Signed-off-by: Raghavi Shirur Signed-off-by: ishitasequeira * Added namespace creation step Signed-off-by: Raghavi Shirur Signed-off-by: ishitasequeira * delete services created for resources Signed-off-by: ishitasequeira * delete server deployment when enabled flag set to false Signed-off-by: ishitasequeira * fix e2e test Signed-off-by: ishitasequeira * fix log message Signed-off-by: ishitasequeira * revert kuttl test timeout Signed-off-by: ishitasequeira * Added test for reverse scenario Signed-off-by: Raghavi Shirur * Dir rename Signed-off-by: Raghavi Shirur * Added e2e test for ha mode Signed-off-by: Raghavi Shirur --------- Signed-off-by: ishitasequeira Signed-off-by: Raghavi Shirur Co-authored-by: Raghavi Shirur * docs: enabling/disabling individual argocd core components (#1098) * Add documentation for enabling/disabling argocd core components Signed-off-by: ishitasequeira * rephrase doc Signed-off-by: ishitasequeira * Address comments Signed-off-by: ishitasequeira --------- Signed-off-by: ishitasequeira * fix: Proper reference to where to find default admin password (#1094) Signed-off-by: ikegentz * adding applicationsets in server rbac policy rule (#1140) Signed-off-by: Mangaal * remove extra argoutils Signed-off-by: Jaideep Rao * fix logic to allow processor operation to be less than default value (#1146) * fix logic to allow operation processors to be less than default value --------- Signed-off-by: Anand Kumar Singh * Use correct repo-server address for notification controller (#1125) Signed-off-by: Siddhesh Ghadi * remove notifs files Signed-off-by: Jaideep Rao * add status reconciliation fns for all components, reconcile statuses at end of cycle Signed-off-by: Jaideep Rao --------- Signed-off-by: Jaideep Rao Signed-off-by: Salem Elrahal Signed-off-by: Siddhesh Ghadi Signed-off-by: dependabot[bot] Signed-off-by: iam-veeramalla Signed-off-by: ishitasequeira Signed-off-by: minchao Signed-off-by: Surajyadav Signed-off-by: Raghavi Shirur Signed-off-by: Ishita Sequeira Signed-off-by: Robert Deusser Signed-off-by: Cheng Fang Signed-off-by: ikegentz Signed-off-by: Mangaal Signed-off-by: Anand Kumar Singh Co-authored-by: Regina Scott <50851526+reginapizza@users.noreply.github.com> Co-authored-by: Salem Elrahal Co-authored-by: Salem Elrahal Co-authored-by: Siddhesh Ghadi <61187612+svghadi@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhishek Veeramalla Co-authored-by: Ishita Sequeira <46771830+ishitasequeira@users.noreply.github.com> Co-authored-by: Minchao Co-authored-by: Suraj yadav Co-authored-by: Raghavi Co-authored-by: ishitasequeira Co-authored-by: Cheng Fang Co-authored-by: Robert Deusser <5935071+rdeusser@users.noreply.github.com> Co-authored-by: Isaac Gentz Co-authored-by: Mangaal <44372157+Mangaal@users.noreply.github.com> Co-authored-by: Anand Kumar Singh --- controllers/argocd/appcontroller/status.go | 32 +++++++++++++ controllers/argocd/applicationset/status.go | 32 +++++++++++++ controllers/argocd/argocd_controller.go | 6 ++- controllers/argocd/notifications/status.go | 32 +++++++++++++ controllers/argocd/redis/status.go | 32 +++++++++++++ controllers/argocd/reposerver/status.go | 32 +++++++++++++ controllers/argocd/server/status.go | 32 +++++++++++++ controllers/argocd/sso/sso.go | 2 +- controllers/argocd/sso/status.go | 32 +++++++++++++ controllers/argocd/status.go | 53 +++++++++++++++++++++ 10 files changed, 283 insertions(+), 2 deletions(-) create mode 100644 controllers/argocd/appcontroller/status.go create mode 100644 controllers/argocd/applicationset/status.go create mode 100644 controllers/argocd/notifications/status.go create mode 100644 controllers/argocd/redis/status.go create mode 100644 controllers/argocd/reposerver/status.go create mode 100644 controllers/argocd/server/status.go create mode 100644 controllers/argocd/sso/status.go diff --git a/controllers/argocd/appcontroller/status.go b/controllers/argocd/appcontroller/status.go new file mode 100644 index 000000000..205f4606b --- /dev/null +++ b/controllers/argocd/appcontroller/status.go @@ -0,0 +1,32 @@ +package appcontroller + +import ( + "context" + + "github.com/pkg/errors" + "k8s.io/client-go/util/retry" +) + +// reconcileStatus will ensure that the app-controller status is updated for the given ArgoCD instance +func (acr *AppControllerReconciler) ReconcileStatus() error { + + // TO DO + + return acr.updateInstanceStatus() +} + +func (acr *AppControllerReconciler) updateInstanceStatus() error { + err := retry.RetryOnConflict(retry.DefaultRetry, func() error { + if err := acr.Client.Status().Update(context.TODO(), acr.Instance); err != nil { + return errors.Wrap(err, "UpdateInstanceStatus: failed to update instance status") + } + return nil + }) + + if err != nil { + // May be conflict if max retries were hit, or may be something unrelated + // like permissions or a network error + return err + } + return nil +} diff --git a/controllers/argocd/applicationset/status.go b/controllers/argocd/applicationset/status.go new file mode 100644 index 000000000..c5b0aef56 --- /dev/null +++ b/controllers/argocd/applicationset/status.go @@ -0,0 +1,32 @@ +package applicationset + +import ( + "context" + + "github.com/pkg/errors" + "k8s.io/client-go/util/retry" +) + +// reconcileStatus will ensure that the appset controller status is updated for the given ArgoCD instance +func (asr *ApplicationSetReconciler) ReconcileStatus() error { + + // TO DO + + return asr.updateInstanceStatus() +} + +func (asr *ApplicationSetReconciler) updateInstanceStatus() error { + err := retry.RetryOnConflict(retry.DefaultRetry, func() error { + if err := asr.Client.Status().Update(context.TODO(), asr.Instance); err != nil { + return errors.Wrap(err, "UpdateInstanceStatus: failed to update instance status") + } + return nil + }) + + if err != nil { + // May be conflict if max retries were hit, or may be something unrelated + // like permissions or a network error + return err + } + return nil +} diff --git a/controllers/argocd/argocd_controller.go b/controllers/argocd/argocd_controller.go index d23db5dbb..343420790 100644 --- a/controllers/argocd/argocd_controller.go +++ b/controllers/argocd/argocd_controller.go @@ -704,6 +704,10 @@ func (r *ArgoCDReconciler) reconcileControllers() error { r.Logger.Error(err, "failed to reconcile SSO controller") } + if err := r.reconcileStatus(); err != nil { + return err + } + return nil } @@ -766,7 +770,7 @@ func (r *ArgoCDReconciler) InitializeControllerReconcilers() { } ssoController := &sso.SSOReconciler{ - Client: &r.Client, + Client: r.Client, Scheme: r.Scheme, Instance: r.Instance, } diff --git a/controllers/argocd/notifications/status.go b/controllers/argocd/notifications/status.go new file mode 100644 index 000000000..a04f3a21f --- /dev/null +++ b/controllers/argocd/notifications/status.go @@ -0,0 +1,32 @@ +package notifications + +import ( + "context" + + "github.com/pkg/errors" + "k8s.io/client-go/util/retry" +) + +// reconcileStatus will ensure that the notifications controller status is updated for the given ArgoCD instance +func (nr *NotificationsReconciler) ReconcileStatus() error { + + // TO DO + + return nr.updateInstanceStatus() +} + +func (nr *NotificationsReconciler) updateInstanceStatus() error { + err := retry.RetryOnConflict(retry.DefaultRetry, func() error { + if err := nr.Client.Status().Update(context.TODO(), nr.Instance); err != nil { + return errors.Wrap(err, "UpdateInstanceStatus: failed to update instance status") + } + return nil + }) + + if err != nil { + // May be conflict if max retries were hit, or may be something unrelated + // like permissions or a network error + return err + } + return nil +} diff --git a/controllers/argocd/redis/status.go b/controllers/argocd/redis/status.go new file mode 100644 index 000000000..c6202a120 --- /dev/null +++ b/controllers/argocd/redis/status.go @@ -0,0 +1,32 @@ +package redis + +import ( + "context" + + "github.com/pkg/errors" + "k8s.io/client-go/util/retry" +) + +// reconcileStatusRedis will ensure that the Redis status is updated for the given ArgoCD instance +func (rr *RedisReconciler) ReconcileStatus() error { + + // TO DO + + return rr.updateInstanceStatus() +} + +func (rr *RedisReconciler) updateInstanceStatus() error { + err := retry.RetryOnConflict(retry.DefaultRetry, func() error { + if err := rr.Client.Status().Update(context.TODO(), rr.Instance); err != nil { + return errors.Wrap(err, "UpdateInstanceStatus: failed to update instance status") + } + return nil + }) + + if err != nil { + // May be conflict if max retries were hit, or may be something unrelated + // like permissions or a network error + return err + } + return nil +} diff --git a/controllers/argocd/reposerver/status.go b/controllers/argocd/reposerver/status.go new file mode 100644 index 000000000..a98b2d13a --- /dev/null +++ b/controllers/argocd/reposerver/status.go @@ -0,0 +1,32 @@ +package reposerver + +import ( + "context" + + "github.com/pkg/errors" + "k8s.io/client-go/util/retry" +) + +// reconcileStatus will ensure that the Repo-server status is updated for the given ArgoCD instance +func (rsr *RepoServerReconciler) ReconcileStatus() error { + + // TO DO + + return rsr.updateInstanceStatus() +} + +func (rsr *RepoServerReconciler) updateInstanceStatus() error { + err := retry.RetryOnConflict(retry.DefaultRetry, func() error { + if err := rsr.Client.Status().Update(context.TODO(), rsr.Instance); err != nil { + return errors.Wrap(err, "UpdateInstanceStatus: failed to update instance status") + } + return nil + }) + + if err != nil { + // May be conflict if max retries were hit, or may be something unrelated + // like permissions or a network error + return err + } + return nil +} diff --git a/controllers/argocd/server/status.go b/controllers/argocd/server/status.go new file mode 100644 index 000000000..42dd2b1d0 --- /dev/null +++ b/controllers/argocd/server/status.go @@ -0,0 +1,32 @@ +package server + +import ( + "context" + + "github.com/pkg/errors" + "k8s.io/client-go/util/retry" +) + +// reconcileStatus will ensure that the server status is updated for the given ArgoCD instance +func (sr *ServerReconciler) ReconcileStatus() error { + + // TO DO + + return sr.updateInstanceStatus() +} + +func (sr *ServerReconciler) updateInstanceStatus() error { + err := retry.RetryOnConflict(retry.DefaultRetry, func() error { + if err := sr.Client.Status().Update(context.TODO(), sr.Instance); err != nil { + return errors.Wrap(err, "UpdateInstanceStatus: failed to update instance status") + } + return nil + }) + + if err != nil { + // May be conflict if max retries were hit, or may be something unrelated + // like permissions or a network error + return err + } + return nil +} diff --git a/controllers/argocd/sso/sso.go b/controllers/argocd/sso/sso.go index f4a20dc24..8e0b30f61 100644 --- a/controllers/argocd/sso/sso.go +++ b/controllers/argocd/sso/sso.go @@ -9,7 +9,7 @@ import ( ) type SSOReconciler struct { - Client *client.Client + Client client.Client Scheme *runtime.Scheme Instance *argoproj.ArgoCD Logger logr.Logger diff --git a/controllers/argocd/sso/status.go b/controllers/argocd/sso/status.go new file mode 100644 index 000000000..b8c2b695c --- /dev/null +++ b/controllers/argocd/sso/status.go @@ -0,0 +1,32 @@ +package sso + +import ( + "context" + + "github.com/pkg/errors" + "k8s.io/client-go/util/retry" +) + +// reconcileStatus will ensure that the sso status is updated for the given ArgoCD instance +func (sr *SSOReconciler) ReconcileStatus() error { + + // TO DO + + return sr.updateInstanceStatus() +} + +func (sr *SSOReconciler) updateInstanceStatus() error { + err := retry.RetryOnConflict(retry.DefaultRetry, func() error { + if err := sr.Client.Status().Update(context.TODO(), sr.Instance); err != nil { + return errors.Wrap(err, "UpdateInstanceStatus: failed to update instance status") + } + return nil + }) + + if err != nil { + // May be conflict if max retries were hit, or may be something unrelated + // like permissions or a network error + return err + } + return nil +} diff --git a/controllers/argocd/status.go b/controllers/argocd/status.go index b412b7b29..f1b035496 100644 --- a/controllers/argocd/status.go +++ b/controllers/argocd/status.go @@ -63,8 +63,61 @@ func (r *ArgoCDReconciler) reconcileStatus(cr *argoproj.ArgoCD) error { >>>>>>> 32c01d0 (chore: rebase against master branch (#1010)) ======= "github.com/argoproj-labs/argocd-operator/pkg/argoutil" + "github.com/argoproj-labs/argocd-operator/pkg/util" ) +// reconcileStatus will ensure that all of the Status properties are updated for the given ArgoCD. +func (r *ArgoCDReconciler) reconcileStatus() error { + var statusErr util.MultiError + + if err := r.AppController.ReconcileStatus(); err != nil { + r.Logger.Error(err, "reconcileStatus") + statusErr.Append(err) + } + + if err := r.ServerController.ReconcileStatus(); err != nil { + r.Logger.Error(err, "reconcileStatus") + statusErr.Append(err) + } + + if err := r.RedisController.ReconcileStatus(); err != nil { + r.Logger.Error(err, "reconcileStatus") + statusErr.Append(err) + } + + if err := r.ReposerverController.ReconcileStatus(); err != nil { + r.Logger.Error(err, "reconcileStatus") + statusErr.Append(err) + } + + if err := r.AppsetController.ReconcileStatus(); err != nil { + r.Logger.Error(err, "reconcileStatus") + statusErr.Append(err) + } + + if err := r.NotificationsController.ReconcileStatus(); err != nil { + r.Logger.Error(err, "reconcileStatus") + statusErr.Append(err) + } + + if err := r.SSOController.ReconcileStatus(); err != nil { + r.Logger.Error(err, "reconcileStatus") + statusErr.Append(err) + } + + // TO DO + + // if err := r.reconcileStatusHost(cr); err != nil { + // return err + // } + + // if err := r.reconcileStatusPhase(cr); err != nil { + // return err + // } + + return statusErr.ErrOrNil() +} + // reconcileStatus will ensure that all of the Status properties are updated for the given ArgoCD. func (r *ReconcileArgoCD) reconcileStatus(cr *argoproj.ArgoCD) error { >>>>>>> 260cca0 (rebase: update main.go, go mod files and docs (7/8) (#1141))