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

Port controller to new pkg/runtime API #165

Merged
merged 6 commits into from
Aug 31, 2021
Merged

Conversation

squaremo
Copy link
Member

@squaremo squaremo commented Aug 16, 2021

  • Rewrite conditions code to use API in pkg/runtime/conditions (MarkTrue/...False/...Unknown)
  • Use patch helper rather than own patchStatus
  • Exit early without setting status when .spec.suspend
  • Events and metrics helpers
  • Figure out what other things need porting and put them here

Ref: fluxcd/flux2#1601

@squaremo
Copy link
Member Author

I also think this PR should include test refactoring

No, I'm not going to push the boat out further and do that here. I don't think it's a matter of compliance.

@squaremo
Copy link
Member Author

ACLs have moved to fluxcd/pkg:

OK -- I would expect that to be its own change.

Signed-off-by: Michael Bridgen <michael@weave.works>
The helpers for conditions have changed in runtime v0.13.0-rc.2; this
commit is near to a mechanical rewrite of the conditions-hamdling code
in the controllers.

It removes `Set*Readiness` from all api/*/, since it it only a thin
shim, and would now need pkg/runtime to be imported. These were
exported funcs, but unlikely to be used outside of the controller
code, and anyway it's <1.0.

meta.DependencyNotReadyReason was removed from pkg/apis/meta, and gets
a more specific replacement `ImageRepositoryNotReadyReason` here.

One more thing: I went through and checked each MarkFalse (i.e., not
ready) to see if it should be a MarkStalled (i.e., add stalled
condition, and also not ready). I think for now it is OK to stick with
being ready or not ready, and consider what might lead to being
stalled later.

Signed-off-by: Michael Bridgen <michael@weave.works>
This uses the patch helper from pkg/runtime. The deferred func is a
lot simpler than the example given in

    https://pkg.go.dev/github.com/fluxcd/pkg/runtime/patch#Helper

because I do not use extra conditions, or try to infer the status from
the return values.

Signed-off-by: Michael Bridgen <michael@weave.works>
This replaces all the individual patchStatus calls with a single
defer.

Signed-off-by: Michael Bridgen <michael@weave.works>
Signed-off-by: Michael Bridgen <michael@weave.works>
The contract for .spec.suspend is (I'm told) to not take any actions,
including not updating the status.

Signed-off-by: Michael Bridgen <michael@weave.works>
@stefanprodan
Copy link
Member

@squaremo can you please create a branch reconcilers-dev like we have in source-controller? If we merge this PR into main, we'll not be able to release any bug fixes until we finish the refactoring.

@squaremo
Copy link
Member Author

we'll not be able to release any bug fixes until we finish the refactoring.

Will anything else happen on that branch?

@squaremo squaremo changed the base branch from main to reconcilers-dev August 26, 2021 14:44
@stefanprodan
Copy link
Member

stefanprodan commented Aug 26, 2021

Will anything else happen on that branch?

I'm thinking of:

  • Refactoring of tests like in SC reconcilers-dev branch (no more Ginko)
  • Refactoring of ImageRepositories ACLs to use fluxcd/pkg
  • Refactoring events to avoid alerting spam

@squaremo
Copy link
Member Author

I'm thinking of:

  • Refactoring of tests like in SC reconcilers-dev branch (no more Ginko)
  • Refactoring of ImageRepositories ACLs to use fluxcd/pkg
  • Refactoring events to avoid alerting spam

Are those all things that hold up fixing things on main? The last one especially just sounds like a change that could be made equally to main.

@squaremo
Copy link
Member Author

I've retargeted it; anyway it will serve as the target of an rc version of the API, so the analogous changes can be made to image-automation-controller.

Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @squaremo

Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

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

Sorry it took my rather long to properly review this.

Based on the comments about wanting to address certain things in (a) separate PR(s), this seems to aligned with what the new helpers have to offer.

One personal preference I would like to make a note of is that some of the conditions that now result in Ready==False with a descriptive reason may be candidates for a dedicated negative polarity condition. Reason for this is that it may help consumers that e.g. try to build an UI around the API object to make things visible to their end users, as Condition Types are part of the API (and can thus be used to (conditionally) render things), while the reasons are arbitrary.

In any case, off to a great start, and thank you @squaremo 🥇

@squaremo squaremo merged commit 143780f into reconcilers-dev Aug 31, 2021
@squaremo squaremo deleted the port-pkg-runtime branch August 31, 2021 11:52
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.

3 participants