Skip to content

Commit

Permalink
fix: Ignore the status check for the registryctl cr in harbor control…
Browse files Browse the repository at this point in the history
…ler (#918)

Signed-off-by: He Weiwei <hweiwei@vmware.com>
  • Loading branch information
heww authored Jun 22, 2022
1 parent 8c76ebe commit 9164d7f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion controllers/goharbor/harbor/registryctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
8 changes: 0 additions & 8 deletions controllers/goharbor/registry/registryctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
7 changes: 0 additions & 7 deletions controllers/goharbor/registry/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
24 changes: 24 additions & 0 deletions pkg/controller/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9164d7f

Please sign in to comment.