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

Restructure controllers pkg #593

Conversation

qu1queee
Copy link
Contributor

@qu1queee qu1queee commented Feb 16, 2021

Changes

This came up while working on #558 . This does NOT fix #558, this is a general code structure enhancement around controllers definition and reconcile logic.

The goal of this PR is to make the code definition more clear, for future contributors and future enhancements.

This PR provides:

  • Move all controller/reconcile logic from /pkg/controller to /pkg/reconciler. This provides more clarity on where the reconcile logic is.
  • A separation of concerns per controller, by splitting the controller definition (e.g watchers setup, etc) from the Reconcile core logic.
  • Provides support for an internal package call resources, to allocate all logic related to resources that required to be manage during reconciliations. This is only added at the moment for the buildrun one, at /pkg/reconciler/buildrun/resources.
  • Keep the /pkg/controller package to host the manager definition based in all controllers definitions.
  • I included one more commit to fix "sanity checks" and "missing file headers".

The above is based on how Tekton/Knative organize their project structures regarding reconcile and controllers logic.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

Move controller/reconcile logic into reconciler pkg

Note: We still have room for improvement on the code organization, mainly on the BuildRun reconciler logic. But adding an initial PR to avoid adding a larger one.

@openshift-ci-robot openshift-ci-robot added the release-note Label for when a PR has specified a release note label Feb 16, 2021
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 16, 2021
@qu1queee qu1queee force-pushed the qu1queee/refactor_controllers_struct branch from aa658a3 to 7fc15f0 Compare February 16, 2021 20:06
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 16, 2021
@qu1queee qu1queee changed the title Refactor controllers pkg Restructure controllers pkg Feb 16, 2021
This introduce reconciler pkg, this package provides more clarity
between controller and reconciler logic. It also allows each resource
to have an internal resources package to deal with all related resources
involved during that resource reconciliation.
@qu1queee qu1queee force-pushed the qu1queee/refactor_controllers_struct branch from 7fc15f0 to 6cad175 Compare February 17, 2021 09:38
@qu1queee qu1queee requested review from HeavyWombat and SaschaSchwarze0 and removed request for zhangtbj February 17, 2021 09:45
Copy link
Contributor

@HeavyWombat HeavyWombat left a comment

Choose a reason for hiding this comment

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

Did a first pass. I added comments where I have questions.

.github/pull_request_template.md Outdated Show resolved Hide resolved
SECURITY.md Show resolved Hide resolved
docs/proposals/runtime-image.md Outdated Show resolved Hide resolved
pkg/reconciler/build/build.go Show resolved Hide resolved
pkg/reconciler/buildrun/buildrun_suite_test.go Outdated Show resolved Hide resolved
Fix all sanity check linters
Add all missing license headers
Do not include markdown files under .github dir
@qu1queee qu1queee force-pushed the qu1queee/refactor_controllers_struct branch from 6cad175 to c7c4fde Compare February 17, 2021 11:40
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

I like it. :-)

/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SaschaSchwarze0

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 17, 2021
@HeavyWombat
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 18, 2021
@openshift-merge-robot openshift-merge-robot merged commit c707e39 into shipwright-io:master Feb 18, 2021
@qu1queee qu1queee deleted the qu1queee/refactor_controllers_struct branch February 18, 2021 16:35
@gabemontero gabemontero added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note Label for when a PR has specified a release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve BuildRun Failure State Transitions
6 participants