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: enrich targets now accepts any scheme #149

Merged
merged 3 commits into from
Jun 7, 2024

Conversation

niklastreml
Copy link
Collaborator

Motivation

Closes #148

This improves the logic in enrichTargets to account for any scheme, be that http, https, tcp whatever floats your boat, as long as it's a valid url we're happy.

Changes

Parse the url into a net.Url so we grab the dns name in an easier way for the dns check.

For additional information look at the commits.

Tests done

I've tested it with the latency and dns check enabled using mixed set of targets configured with HTTP and HTTPS. Seemed to work fine

  • Unit tests succeeded
  • E2E tests succeeded

TODO

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

Signed-off-by: Niklas Treml <treml.niklas@gmail.com>
Signed-off-by: Niklas Treml <treml.niklas@gmail.com>
@niklastreml niklastreml added the bug Something isn't working label Jun 6, 2024
@niklastreml niklastreml self-assigned this Jun 6, 2024
@niklastreml niklastreml linked an issue Jun 6, 2024 that may be closed by this pull request
1 task
Copy link
Collaborator

@lvlcn-t lvlcn-t left a comment

Choose a reason for hiding this comment

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

LGTM but could you add some unit tests for the cases this PR is supposed to fix?

Additionally we should investigate why this test sometimes fails:

=== RUN   Test_gitlabTargetManager_Reconcile_Registration_Update
{"time":"2024-06-06T16:34:19.377725874Z","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/targets.(*manager).Reconcile","file":"/home/runner/work/sparrow/sparrow/pkg/sparrow/targets/manager.go","line":82},"msg":"Starting target manager reconciliation"}
{"time":"2024-06-06T16:34:19.388429797Z","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/targets/remote/test.(*MockClient).PostFile","file":"/home/runner/work/sparrow/sparrow/pkg/sparrow/targets/remote/test/remotemock.go","line":53},"msg":"MockPostFile called","err":null}
{"time":"2024-06-06T16:34:19.478009469Z","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/targets/remote/test.(*MockClient).FetchFiles","file":"/home/runner/work/sparrow/sparrow/pkg/sparrow/targets/remote/test/remotemock.go","line":62},"msg":"MockFetchFiles called","targets":1,"err":null}
{"time":"2024-06-06T16:34:19.478098907Z","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/targets/remote/test.(*MockClient).PutFile","file":"/home/runner/work/sparrow/sparrow/pkg/sparrow/targets/remote/test/remotemock.go","line":44},"msg":"MockPutFile called","err":null}
{"time":"2024-06-06T16:34:19.578621783Z","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/targets/remote/test.(*MockClient).FetchFiles","file":"/home/runner/work/sparrow/sparrow/pkg/sparrow/targets/remote/test/remotemock.go","line":62},"msg":"MockFetchFiles called","targets":1,"err":null}
{"time":"2024-06-06T16:34:19.578713224Z","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/targets/remote/test.(*MockClient).PutFile","file":"/home/runner/work/sparrow/sparrow/pkg/sparrow/targets/remote/test/remotemock.go","line":44},"msg":"MockPutFile called","err":null}
{"time":"2024-06-06T16:34:19.678783951Z","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/targets/remote/test.(*MockClient).FetchFiles","file":"/home/runner/work/sparrow/sparrow/pkg/sparrow/targets/remote/test/remotemock.go","line":62},"msg":"MockFetchFiles called","targets":1,"err":null}
{"time":"2024-06-06T16:34:19.678915467Z","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/targets/remote/test.(*MockClient).PutFile","file":"/home/runner/work/sparrow/sparrow/pkg/sparrow/targets/remote/test/remotemock.go","line":44},"msg":"MockPutFile called","err":null}
    manager_test.go:457: Reconcile() should have updated the registration twice
--- FAIL: Test_gitlabTargetManager_Reconcile_Registration_Update (0.30s)

Signed-off-by: Niklas Treml <treml.niklas@gmail.com>
@niklastreml
Copy link
Collaborator Author

as far as the flaky test goes, I don't have time to look into it, but I'll file a bug report

@niklastreml niklastreml requested a review from lvlcn-t June 7, 2024 07:24
Copy link
Collaborator

@lvlcn-t lvlcn-t left a comment

Choose a reason for hiding this comment

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

LGTM

@niklastreml
Copy link
Collaborator Author

Created the issue #150

@niklastreml niklastreml merged commit 4d047e4 into main Jun 7, 2024
13 checks passed
@niklastreml niklastreml deleted the fix/dns-check-ignore-schemes branch June 7, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: DNS Check can never use targets supplied by target manager
2 participants