Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Add check selection api to the server #357

Merged

Conversation

arbulu89
Copy link
Contributor

This PRs implements one of the 1st components to remove consul usage from checks service.
It stores the selected checks in the new Postgres database, and offers the API endpoints to do so externally. This 2nd things will be needed from the runner, as it needs to get the currently selected check ids. The created service code will be used in the cluster web handler as well, to remove the current consul code.

The SelectedChecks information will go in a new table with the next struct:

  • ID, the selected resource ID. By now, this will be the cluster id, but it will scale if we add other concepts checks
  • SelectedChecks, a comma separated list of checks as a string. This copies the current exact type. We can store it as an array if needed, I just migrated the current type for easiness sake

I have more or less the subsequent code ready (adapt the runner and server sides), but I preferred to keep the PR small to improve the review process

Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

A tiny comment, but I think we are ready to merge after this gets addressed or clarified

web/services/checks.go Outdated Show resolved Hide resolved
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

LGTM

@arbulu89
Copy link
Contributor Author

arbulu89 commented Oct 21, 2021

@dottorblaster @fabriziosestito I have updated the SelectedChecks type to a list of strings, which aligns better the purpose of the attribute, the list of selected checks.
Could you have a new look? The change comes in: 753a389

PD: I have been forced to create the new JSONSelectedChecks struct, as swagger doesn't work with pq.StringArray

Copy link
Contributor

@rtorrero rtorrero left a comment

Choose a reason for hiding this comment

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

@arbulu89 LGTM, thanks!

@arbulu89 arbulu89 force-pushed the feature/add-check-selection-api branch from 753a389 to 8b28a10 Compare October 21, 2021 11:53
@arbulu89 arbulu89 force-pushed the feature/add-check-selection-api branch from 8b28a10 to 3e52da6 Compare October 21, 2021 11:58
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

Looks quite good to me, good job @arbulu89!

Copy link
Member

@nelsonkopliku nelsonkopliku left a comment

Choose a reason for hiding this comment

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

Good stuff!
My OCD would prefer a slightly different setup for tests. But that's not a blocking. 🚀

t.Fatal(err)
}

// 200 scenario
Copy link
Member

Choose a reason for hiding this comment

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

I would probably refactor to use testsuites and maybe split Scenarios into smaller test functions, but this just works as fine! 💪

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, initially I thought the same. But as it already had pretty complete tests (test 200, 404, 500), I just followed the same approach.
Nothing against using suites or smaller functions :D

Copy link
Member

@fabriziosestito fabriziosestito left a comment

Choose a reason for hiding this comment

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

LGTM, we might start thinking of dividing api in files or subpackages as it is growing a lot.

@arbulu89
Copy link
Contributor Author

LGTM, we might start thinking of dividing api in files or subpackages as it is growing a lot.

Agree! I would create an api folder within web so we have all the code in there.
I will do it in one of my next PRs, as I'm still adding some few more api code

@arbulu89 arbulu89 merged commit 749fa03 into trento-project:main Oct 21, 2021
@arbulu89 arbulu89 added the enhancement Improvement of existing features label Oct 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Improvement of existing features
Development

Successfully merging this pull request may close these issues.

5 participants