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

Default and Enforced Compositions #1585

Merged
merged 10 commits into from
Jun 18, 2020
Merged

Default and Enforced Compositions #1585

merged 10 commits into from
Jun 18, 2020

Conversation

muvaf
Copy link
Member

@muvaf muvaf commented Jun 3, 2020

Description of your changes

This PR allows infra-operators to choose a default composition to be selected in case no selector is given as well as an enforced composition to be selected no matter what.

Fixes #1471
Fixes #1470

How has this code been tested?

Manually tested.

Checklist

I have:

  • Run make reviewable to ensure this PR is ready for review.
  • Ensured this PR contains a neat, self documenting set of commits.
  • Updated any relevant documentation and examples.
  • Reported all new error conditions into the log or as an event, as
    appropriate.

For more about what we believe makes a pull request complete, see our
definition of done.

@muvaf muvaf requested review from kasey, negz and hasheddan June 3, 2020 15:52
@muvaf muvaf changed the title Default Composition Ref on InfrastructureDefinition Default and Enforced Compositions Jun 4, 2020
@muvaf muvaf marked this pull request as ready for review June 4, 2020 14:30
@muvaf
Copy link
Member Author

muvaf commented Jun 4, 2020

I've added enforced composition as well since it's pretty similar to default one. All manually tested, ready for review.

muvaf added 8 commits June 5, 2020 16:34
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
…erence or label selector is given in composite resource

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
…tion for all of its composite instances

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
- Enforced and default composition selectors do not do compatibility check.
- Enforced composition ref in infradef is made immutable.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
…default or enforced composition

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
@muvaf muvaf force-pushed the def-comp branch 2 times, most recently from d494cf4 to c42fe11 Compare June 5, 2020 14:12
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
@muvaf
Copy link
Member Author

muvaf commented Jun 5, 2020

Tested manually with the latest changes.

Copy link
Member

@negz negz left a comment

Choose a reason for hiding this comment

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

Sorry I slept on this review @muvaf. Overall it LGTM, though I left a few fairly minor comments that I'd like you to consider before I merge.

return nil
}
cp.SetCompositionReference(def.Spec.DefaultCompositionRef)
s.recorder.Event(cp, event.Normal(reasonCompositionSelection, "Default composition has been selected"))
Copy link
Member

Choose a reason for hiding this comment

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

Is this information really worth plumbing a recorder down here for? Would we still be able to record "A composition has been selected" without specifically communicating that it was a default or enforced composition if we did this further up in the stack?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think what composition is selected is already clear from its field on spec but I find it valuable to see how it's selected to avoid situations where it's relatively hard to figure out what's happening. This could happen in this situation because the person who is creating a requirement or composite resource is kind of far from seeing what default/enforced composition is easily, it's like you have to check the CRD to see it which we never really do. It's also good to educate people who are exploring how stuff works at the place where they do that exploration directly. So, I found it helpful to say how it made it here, if it's exceptional like default/enforced, and what is selected is already shown in spec when you do kubectl describe

// as its target type reference is immutable.
if cp.GetCompositionReference().String() == s.def.Spec.EnforcedCompositionRef.String() {
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this branch? It seems like if we removed it we'd have a no-op SetCompositionReference below, so the only difference is we might emit an event despite the enforced composition already being set.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I believe the event should be fired only when it's actually fired to keep the chronological order of events digestable. I'd like to avoid a situation where there are events on the object but one of every two event is enforced composition is selected whereas it's actually selected only if there is a drift.

…tion reference

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
@muvaf
Copy link
Member Author

muvaf commented Jun 13, 2020

@negz Thanks for the review! It's ready for another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow specifying a default composition in definition Enforced composition ref on the definition
3 participants