Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ignore the status check for the registryctl cr in harbor controller #918

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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