From fea9b6fd92c791455d02c8c5d1ba618df6520d1b Mon Sep 17 00:00:00 2001 From: He Weiwei Date: Wed, 22 Jun 2022 09:31:30 +0000 Subject: [PATCH] fix: Ignore the status check for the registryctl cr in harbor controller Signed-off-by: He Weiwei --- controllers/goharbor/harbor/registryctl.go | 2 +- controllers/goharbor/registry/registryctl.go | 8 ------- controllers/goharbor/registry/resources.go | 7 ------ pkg/controller/resource.go | 24 ++++++++++++++++++++ 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/controllers/goharbor/harbor/registryctl.go b/controllers/goharbor/harbor/registryctl.go index 9c4add7e2..9dda281eb 100644 --- a/controllers/goharbor/harbor/registryctl.go +++ b/controllers/goharbor/harbor/registryctl.go @@ -25,7 +25,7 @@ func (r *Reconciler) AddRegistryController(ctx context.Context, harbor *goharbor return nil, nil, errors.Wrap(err, "cannot get registryCtl") } - registryCtlRes, err := r.AddBasicResource(ctx, registryCtl, certificate) + registryCtlRes, err := r.AddNonCheckableResource(ctx, registryCtl, certificate) if err != nil { return nil, nil, errors.Wrap(err, "cannot add registryCtl") } diff --git a/controllers/goharbor/registry/registryctl.go b/controllers/goharbor/registry/registryctl.go index 34abc2ced..992a0f3f9 100644 --- a/controllers/goharbor/registry/registryctl.go +++ b/controllers/goharbor/registry/registryctl.go @@ -88,11 +88,3 @@ func owneredByRegistryCtl(obj client.Object, registryCtl *goharborv1.RegistryCon return false } - -// UpdateRegistryCtlStatus updates registrycontroller status by registry. -func (r *Reconciler) UpdateRegistryCtlStatus(ctx context.Context, registry *goharborv1.Registry, registryCtl *goharborv1.RegistryController) error { - // sync registrycontroller status with registry - registryCtl.Status = registry.Status - - return r.Client.Status().Update(ctx, registryCtl) -} diff --git a/controllers/goharbor/registry/resources.go b/controllers/goharbor/registry/resources.go index 534e43c4e..d4ec431d1 100644 --- a/controllers/goharbor/registry/resources.go +++ b/controllers/goharbor/registry/resources.go @@ -33,13 +33,6 @@ func (r *Reconciler) AddResources(ctx context.Context, resource resources.Resour return errors.Wrap(err, "cannot get registryctl") } - defer func() { - e := r.UpdateRegistryCtlStatus(ctx, registry, registryCtl) - if e != nil { - r.Log.Error(err, "cannot update registry controller status") - } - }() - err = r.CleanUpRegistryCtlResources(ctx, registryCtl) if err != nil { return errors.Wrap(err, "cleanup registryctl resources error") diff --git a/pkg/controller/resource.go b/pkg/controller/resource.go index ed716d3c8..7dec7cdb7 100644 --- a/pkg/controller/resource.go +++ b/pkg/controller/resource.go @@ -299,6 +299,30 @@ func (c *Controller) AddBasicResource(ctx context.Context, resource resources.Re return res, g.AddResource(ctx, res, dependencies, c.ProcessFunc(ctx, resource, dependencies...)) } +func (c *Controller) AddNonCheckableResource(ctx context.Context, resource resources.Resource, dependencies ...graph.Resource) (*Resource, error) { + if resource == nil { + return nil, nil + } + + mutate, err := c.GlobalMutateFn(ctx) + if err != nil { + return nil, err + } + + res := &Resource{ + mutable: mutate, + checkable: statuscheck.True, + resource: resource, + } + + g := sgraph.Get(ctx) + if g == nil { + return nil, errors.Errorf("no graph in current context") + } + + return res, g.AddResource(ctx, res, dependencies, c.ProcessFunc(ctx, resource, dependencies...)) +} + func (c *Controller) AddExternalResource(ctx context.Context, resource resources.Resource, dependencies ...graph.Resource) (graph.Resource, error) { if resource == nil { return nil, nil