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

Implement ServerSelector in ServerClaimReconciler #86

Merged
merged 5 commits into from
Jul 23, 2024

Conversation

aobort
Copy link
Contributor

@aobort aobort commented Jul 17, 2024

Proposed Changes

  • added ClaimedServerRef to .status. Since .spec.serverRef is an optional field it's reasonable to store reference to claimed server in the claim's status
  • added handling of .spec.serverSelector field

Fixes #68

Copy link
Member

@afritzler afritzler left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @aobort! Please find my comments below.

The core question I have here:
When I claim a Server via a Ref do I want to also allow a Selector or do we ignore it? My understanding of a Ref is: if the Server is Available - claim it! No matter what it's labels are. On the other side the ServerSelector allows you to select the next best Server which has the correct set of labels. So the Ref should have precedence over the selector. On the other side if there is no Ref, try to use the selector.

api/v1alpha1/serverclaim_types.go Outdated Show resolved Hide resolved
internal/controller/serverclaim_controller.go Outdated Show resolved Hide resolved
internal/controller/serverclaim_controller.go Outdated Show resolved Hide resolved
internal/controller/serverclaim_controller.go Outdated Show resolved Hide resolved
internal/controller/serverclaim_controller.go Outdated Show resolved Hide resolved
internal/controller/serverclaim_controller.go Show resolved Hide resolved
internal/controller/serverclaim_controller.go Outdated Show resolved Hide resolved
api/v1alpha1/serverclaim_types.go Outdated Show resolved Hide resolved
@afritzler afritzler changed the title server selector handling for server claim Implement ServerSelector in ServerClaimReconciler Jul 17, 2024
@aobort
Copy link
Contributor Author

aobort commented Jul 17, 2024

Thanks for the PR @aobort! Please find my comments above.

The core question I have here: When I claim a Server via a Ref do I want to also allow a Selector or do we ignore it? My understanding of a Ref is: if the Server is Available - claim it! No matter what it's labels are. On the other side the ServerSelector allows you to select the next best Server which has the correct set of labels. So the Ref should have precedence over the selector. On the other side if there is no Ref, try to use the selector.

I'd prefer not to make it overcomplicated and stick to two options:

  • use reference if set
  • use selector if reference is not set

without implementing complex decision making like "if server by reference is not claimable, then let's try to find another one by selector". In other words, if one put explicit reference to server, then operator should claim it or stop the process.

@afritzler
Copy link
Member

You are right: we should stick to the following semantic:

  • If .spec.serverRef and .spec.serverSelector is both set, we expect that those labels are present on the Server
  • If only .spec.serverRef is set we just pick the Server if it is in an Available state
  • If only .spec.serverSelector is set, we List all matching Servers and pick the first Available one

@aobort aobort requested a review from afritzler July 17, 2024 11:40
@afritzler
Copy link
Member

Can you also run make docs to regenerate the API reference documentation?

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jul 17, 2024
@aobort aobort marked this pull request as ready for review July 18, 2024 08:07
@aobort
Copy link
Contributor Author

aobort commented Jul 19, 2024

@afritzler Test (not included into PR) for the case when neither .spec.serverRef nor .spec.serverSelector defined fails due to ginkgo runs tests in parallel:

it is impossible to define which server will be claimed in case ref and selector are empty. Thus I've made a try to just get server from the claim after .spec.serverRef is fulfilled - works fine. However on some runs - I've run tests 5-10 times in a row - controller claims server which was supposed to be claimed in another test case and that test case fails.

In total: some test case might fail occasionally. The solution which works is to:

  1. add Ordered option to the test suite. This will grant serial run for all nested containers, so the test cases will run one by one;
  2. destroy servers after each test. This will grant absence of side effects on any objects which are not belong to current test case.

@afritzler
Copy link
Member

To test the case, that .spec.serverRef and .spec.serverSelector are empty, just create a couple of Server resources and ensure, that the .spec.serverRef has been mutated to a non nil value. Also you could then try to get the .spec.serverRef object and ensure that it's state is set to Reserved.

In general each suite test (*_test.go) should ensure the correct clean up of any Server which has been created or derived in any of the It statements.

Copy link
Member

@afritzler afritzler left a comment

Choose a reason for hiding this comment

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

The PR looks good to me now. Just one minor naming issue I have.

internal/controller/serverclaim_controller.go Outdated Show resolved Hide resolved
aobort added 5 commits July 23, 2024 14:26
Signed-off-by: Artem Bortnikov <[email protected]>
Signed-off-by: Artem Bortnikov <[email protected]>
Signed-off-by: Artem Bortnikov <[email protected]>
@aobort aobort force-pushed the issue-68/server-selector branch from 93bd661 to 0b62b18 Compare July 23, 2024 11:27
@aobort aobort requested a review from afritzler July 23, 2024 11:29
@aobort
Copy link
Contributor Author

aobort commented Jul 23, 2024

The PR looks good to me now. Just one minor naming issue I have.

@afritzler fixed. Pls, review

@afritzler afritzler added the enhancement New feature or request label Jul 23, 2024
@afritzler afritzler merged commit 17e1033 into ironcore-dev:main Jul 23, 2024
10 checks passed
@aobort aobort deleted the issue-68/server-selector branch July 23, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change documentation Improvements or additions to documentation enhancement New feature or request size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement ServerSelector in ServerClaimReconciler
2 participants