Skip to content

Commit

Permalink
Fix remote harbor healthcheck functionality
Browse files Browse the repository at this point in the history
The review contain two changes:
The first is adding implementation for HealthCheck in src/pkg/reg/adapter/harbor/v2/adapter.go
The second general issue, in which a change made in src/controller/registry/controller.go by removing the continue inside the loop,
the continue prevent from updating regMgr.Update with the status change
  • Loading branch information
Gal Netanel committed Feb 26, 2025
1 parent 9e84d03 commit ee3d029
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/controller/registry/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ func (c *controller) StartRegularHealthCheck(ctx context.Context, closing, done
isHealthy, err := c.IsHealthy(ctx, registry)
if err != nil {
log.Errorf("failed to check health of registry %d: %v", registry.ID, err)
continue
}
status := model.Healthy
if !isHealthy {
Expand Down
9 changes: 9 additions & 0 deletions src/pkg/reg/adapter/harbor/v2/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/goharbor/harbor/src/pkg/reg/adapter/harbor/base"
"github.com/goharbor/harbor/src/pkg/reg/filter"
"github.com/goharbor/harbor/src/pkg/reg/model"
"github.com/goharbor/harbor/src/lib/log"
)

var _ adp.Adapter = &adapter{}
Expand Down Expand Up @@ -144,3 +145,11 @@ func (a *adapter) CanBeMount(digest string) (bool, string, error) {
}
return true, repository, nil
}

func (a adapter) HealthCheck() (string, error) {
if err := a.Ping(); err != nil {
log.Errorf("failed to ping registry %s: %v", a.Registry.URL, err)
return model.Unhealthy, nil
}
return model.Healthy, nil
}

0 comments on commit ee3d029

Please sign in to comment.