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

refactor: genericize target manager #122

Merged
merged 4 commits into from
Mar 14, 2024
Merged

Conversation

lvlcn-t
Copy link
Collaborator

@lvlcn-t lvlcn-t commented Mar 7, 2024

Motivation

This is the second PR to address #66.

Initially the target manager was built to implement the feature of #30 asap. The manager logic was implemented in a way around the gitlab API interactions. To be able to support other remote state backends for global registration we need to genericize the target manager.

Changes

Pretty much everything is moving and renaming in this PR.

The only thing I've really changed is that the config now has a type which specifies the type of the remote interactor used kind of like we already do for the loader.

The new target manager config looks like this:

targetManager:
  type: gitlab # <- This is the new type config option.
  checkInterval: 1m
  registrationInterval: 1m
  updateInterval: 2m
  unhealthyThreshold: 3m
  gitlab:
    baseUrl: https://gitlab.com
    projectId: 123456

I'll change the docs and chart for this later with the last PR regarding #66 that will close the issue.

  • refactor: generalize Gitlab interface to remote interactor interface
  • refactor: mv gitlab config to interactor config
  • chore: adjust imports
  • feat: add interactor type
  • feat: adjust target manager validation for interactor type
  • chore: adjust naming
  • chore: bump helm-docs v1.13.1

For additional information look at the commits.

Tests done

  • Unit tests succeeded
  • E2E tests succeeded - we have no e2e tests for the target manager

Manual e2e tests

Logs

$ go run main.go run --config .tmp/config/start-config.yaml 
Using config file: .tmp/config/start-config.yaml
time=09:35:17 level=INFO source=/home/installadm/dev/github/sparrow/cmd/run.go:81 msg="Running sparrow"
time=09:35:17 level=INFO source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/manager.go:82 msg="Starting target manager reconciliation"
time=09:35:17 level=INFO source=/home/installadm/dev/github/sparrow/pkg/api/api.go:76 msg="Serving Api" addr=:8080
time=09:35:17 level=INFO source=/home/installadm/dev/github/sparrow/pkg/config/file.go:69 msg="File Loader disabled"
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/remote/gitlab/gitlab.go:142 msg="Fetching file list from gitlab"
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/remote/gitlab/gitlab.go:192 msg="Successfully fetched file list" files=3
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/remote/gitlab/gitlab.go:134 msg="Successfully fetched file" file=dev-tom.local.sparrow.com.json
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/remote/gitlab/gitlab.go:134 msg="Successfully fetched file" file=tom.dev.sparrow.com.json
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/remote/gitlab/gitlab.go:134 msg="Successfully fetched file" file=tom.local.sparrow.de.json
time=09:36:17 level=INFO source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/remote/gitlab/gitlab.go:88 msg="Successfully fetched all target files" files=3
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/manager.go:244 msg="Skipping unhealthy target" target="{Url:https://dev-tom.local.sparrow.com LastSeen:2024-02-27 21:30:38.576875669 +0000 UTC}"
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/manager.go:244 msg="Skipping unhealthy target" target="{Url:https://tom.dev.sparrow.com LastSeen:2024-02-29 19:19:44.803342416 +0000 UTC}"
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/manager.go:234 msg="Found self as global target" lastSeenMin=9.450534298533332
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/manager.go:244 msg="Skipping unhealthy target" target="{Url:https://tom.local.sparrow.de LastSeen:2024-03-07 08:26:50.399523487 +0000 UTC}"
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/manager.go:251 msg="Updated global targets" targets=0
time=09:36:17 level=DEBUG source=/home/installadm/dev/github/sparrow/pkg/sparrow/targets/manager.go:164 msg="Already registered as global target"

Remote Repository

image

TODO

  • I've assigned this PR to myself
  • I've labeled this PR correctly

* refactor: generalize Gitlab interface to remote interactor interface
* refactor: mv gitlab config to interactor config
* chore: adjust imports
* feat: add interactor type
* feat: adjust target manager validation for interactor type
* chore: adjust naming
* chore: bump helm-docs v1.13.1
@lvlcn-t lvlcn-t self-assigned this Mar 7, 2024
@lvlcn-t lvlcn-t added refactoring Refactoring of existing code area/target-manager Issues/PRs related to the TargetManager labels Mar 7, 2024
Copy link
Member

@y-eight y-eight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor remarks

pkg/sparrow/targets/interactor/config.go Show resolved Hide resolved
pkg/sparrow/targets/targetmanager.go Outdated Show resolved Hide resolved
@lvlcn-t lvlcn-t merged commit d786d77 into main Mar 14, 2024
11 checks passed
@lvlcn-t lvlcn-t deleted the refactor/genericize-tarman branch March 14, 2024 15:38
@lvlcn-t lvlcn-t mentioned this pull request Mar 16, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/target-manager Issues/PRs related to the TargetManager refactoring Refactoring of existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants