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

reconcile api objects instead of state objects [ch12124] #4613

Merged
merged 6 commits into from
Jun 9, 2021

Conversation

maiamcc
Copy link
Contributor

@maiamcc maiamcc commented Jun 7, 2021

Hello @milas,

Please review the following commits I made in branch maiamcc/reconcile-pfs:

ec728c3 (2021-06-07 11:30:24 -0400)
reconcile in response to API changes and update tests

66be159 (2021-06-04 19:34:47 -0400)
preserve old behavior

c133e96 (2021-06-04 19:24:28 -0400)
wip

Code review reminders, by giving a LGTM you attest that:

  • Commits are adequately tested
  • Code is easy to understand and conforms to style guides
  • Incomplete code is marked with TODOs
  • Code is suitably instrumented with logging and metrics

@maiamcc maiamcc requested a review from milas June 7, 2021 15:41
var _ store.TearDowner = &Reconciler{}
var _ reconcile.Reconciler = &Reconciler{}

func NewReconciler(store store.RStore, kClient k8s.Client, ctrlClient ctrlclient.Client) *Reconciler {
Copy link
Contributor

Choose a reason for hiding this comment

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

You won't be able to take ctrlclient.Client as a constructor param, you have to let it be "injected" via SetClient(). (Your Reconcile() method won't be called before that though, so you don't have to worry about it being nil.)

There's a weird chicken-and-egg party going on between the reconcilers + the controller manager (manager creates client but not until it's actually initialized/running which is after the clients get constructed), see #4250 for how we ended up here.

toShutdown = r.addToShutdown(toShutdown, existing)
if active, ok := r.activeForwards[name]; ok {
if equality.Semantic.DeepEqual(active.Spec, pf.Spec) &&
equality.Semantic.DeepEqual(active.ObjectMeta.Annotations, pf.ObjectMeta.Annotations) {
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW I think comparing spec + just the v1alpha1.AnnotationManifest annotation (rather than all) from the old code is a bit less error-prone in the event that some{one,thing} starts manipulating annotations across resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, will do

// a. the PFs are started as expected (r.activeForwards etc.) and
// b. the status is reflected in the API
time.Sleep(time.Second)
f.requireState(pfFooName, func(pf *PortForward) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the time.Sleep() can go away?

Also, this needs a real assertion 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol that was supposed to go away 😅

}
}

func (f *pfrFixture) onChange() {
f.r.OnChange(f.ctx, f.st, store.LegacyChangeSummary())
func (f *pfrFixture) wait() {
Copy link
Contributor

Choose a reason for hiding this comment

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

TBH I think the tests are likely to suffer from timing failures from this. I think it might be better to replace this method with something like requirePfStarted(name string) which uses requireState() to check that !pf.Status.StartedAt.IsZero(); i.e. use it as control flow/synchronization and then do normal assertions after.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm yeah given that i haven't yet implemented status yet, i'm just doing "you can get the port forward back from the API server" which is maybe not THE most robust but better than the existing, wdyt?

@maiamcc maiamcc requested a review from milas June 8, 2021 19:18
@maiamcc
Copy link
Contributor Author

maiamcc commented Jun 8, 2021

@milas this is ready for you when you get a chance

Copy link
Contributor

@milas milas left a comment

Choose a reason for hiding this comment

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

🌮

@maiamcc maiamcc merged commit 1f68da9 into master Jun 9, 2021
@maiamcc maiamcc deleted the maiamcc/reconcile-pfs branch June 9, 2021 20:38
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.

None yet

2 participants