Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Relocate reconcilers from wksctl to CAPEI (cluster-api-provider-existinginfra) #286

Merged
merged 6 commits into from
Aug 21, 2020

Conversation

twelho
Copy link
Contributor

@twelho twelho commented Aug 5, 2020

This PR extracts the Cluster and Machine controllers from wksctl out to a separate repo nicknamed CAPEI (cluster-api-provider-existinginfra). The needed controller-related functionality is then vendored in.

Status:

  • Compiles
  • Tests pass
  • Redundant code removed
  • Code separated on function-level, pieces belonging here moved back
  • Commits rebased to form a linear removal process (avoid removing and re-adding code)
  • capi-existinginfra renamed to cluster-api-provider-existinginfra and moved to WW org
  • wksctl vendors in published CAPEI (go.mod hacks removed)

cc @luxas @bboreham

@twelho twelho self-assigned this Aug 5, 2020
@twelho twelho added chore Related to fix/refinement/improvement of end user or new/existing developer functionality tech-debt Unpleasantness that does (or may in future) affect development labels Aug 5, 2020
@bboreham
Copy link
Contributor

bboreham commented Aug 6, 2020

It strikes me as unlikely we want to move pkg/utilities/path because it relates to the user's home directory, so must be more associated with the CLI command.

Similarly pkg/utilities/manifest because it should only be used when setting up the initial cluster config from files, but it looks like that code is used in many more places than path.

Code like pkg/apis/wksprovider/machine/os/os.go parseCluster() should not be in the pure CAPI provider. It's there for CreateSeedNodeSetupPlan() which is for the bootstrap-from-scratch case. So that function should remain in this repo.
Sounds like os.go needs to be split into two?

Similarly pkg/specs/specs.go has parsing functions. And if they remain in wksctl then package pkg/utilities can also remain.

pkg/qjson is only used in pkg/addons/addon.go, which should be a wksctl function - addons are applied after the cluster comes up. Similarly pkg/registry.

@twelho
Copy link
Contributor Author

twelho commented Aug 10, 2020

Yes most of the code is currently misplaced, I've started by moving pkg/apis/wksprovider/controller/wksctl/machine_controller.go and all of it's recursive file-level dependencies out. I'll add a checkbox for function-level refactoring and moving the right stuff back here.

@twelho twelho force-pushed the vendor-capi-existinginfra branch 3 times, most recently from b8bf241 to 5912743 Compare August 13, 2020 13:12
Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Looking better.

assert.EqualError(t, err, "invalid version \"bad version\": Invalid character(s) found in major number \"bad version\"")
assert.False(t, matches)
}

func TestVersionLessthanWithBothVs(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we lose these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

version.LessThan (and some other version functions as well) are used by the machine controller, and have thus been moved to capi-existinginfra along with these tests. See capi-existinginfra/pkg/utilities/version.

go.mod Outdated
require github.com/twelho/capi-existinginfra v0.0.0

replace (
github.com/twelho/capi-existinginfra => ../capi-existinginfra
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks like it should have been removed

Copy link
Contributor Author

@twelho twelho Aug 17, 2020

Choose a reason for hiding this comment

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

Will be removed soon when I get the repo published and import paths updated.
Update: Now removed.

Signed-off-by: Dennis Marttinen <dennis@weave.works>
@twelho twelho force-pushed the vendor-capi-existinginfra branch 10 times, most recently from 3b43c6b to 0a3b8be Compare August 20, 2020 14:19
@twelho twelho changed the title [WIP] Relocate reconcilers from wksctl to a dedicated repo Relocate reconcilers from wksctl to CAPEI (cluster-api-provider-existinginfra) Aug 20, 2020
@twelho twelho marked this pull request as ready for review August 20, 2020 15:58
@twelho
Copy link
Contributor Author

twelho commented Aug 20, 2020

All tasks are now completed and tests pass 🎉
Ready for (re)review and merge.

Copy link
Contributor

@luxas luxas left a comment

Choose a reason for hiding this comment

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

Amazing work @twelho 💯 🥇 🚀!

Only one small nit 😉

@@ -130,6 +130,8 @@ jobs:
FOOTLOOSE_CHECKSUM: 0e4e49e81940c5876eafa26607154acd788d9979e9f4a4215f17532a3ea5429a
KUBECTL_URL: https://dl.k8s.io/v1.18.5/kubernetes-client-linux-amd64.tar.gz
KUBECTL_CHECKSUM: f6051fa7f715c68d56998d9b4c9be4f08552f3a8427b2c6b9e2e5339dd2929b6
CAPEI_URL: https://github.com/weaveworks/cluster-api-provider-existinginfra/archive/v0.0.2.tar.gz
CAPEI_CHECKSUM: a2d5d2a0f43a2c0872bcc96265d753868a4f0867f555743a5e280cff73f95cdc
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for @bboreham @jrryjcksn @palemtnrider: need to update this whenever CAPEI comes with new releases 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

or, build automation around getting the latest release

go.mod Outdated
@@ -26,6 +22,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.6.1
github.com/thanhpk/randstr v1.0.4
github.com/weaveworks/cluster-api-provider-existinginfra v0.0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

bump this to v0.0.2 now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, updated.

@palemtnrider
Copy link
Contributor

Nice work @twelho !

  • I see this repo still references wksctl-controller and in some places, you had a comment to replace this when capei-controller is available via the build process. Please add an issue so we can track that work.

  • you used existinginfrav1 when importing cluster-api-provider-existing-infra/apis/cluster.weave.works/v1alpha3. And used capi* when importing other packages when there are conflicts with wksctl packages. For my edification -

    • why not capei* instead of capi
    • why the difference when importing v1alpha3

This was a huge amount of work thank you for tackling it!

@twelho
Copy link
Contributor Author

twelho commented Aug 21, 2020

Hi @palemtnrider, thanks for your comments!

Signed-off-by: Dennis Marttinen <dennis@weave.works>
Signed-off-by: Dennis Marttinen <dennis@weave.works>
Signed-off-by: Dennis Marttinen <dennis@weave.works>
Signed-off-by: Dennis Marttinen <dennis@weave.works>
Signed-off-by: Dennis Marttinen <dennis@weave.works>
@twelho
Copy link
Contributor Author

twelho commented Aug 21, 2020

With the latest push the large diff of pkg/apis/wksprovider/machine/os/os.go is now cleaned up as well. During refactoring I moved functions around, but have now restored them to their original positions in the file.

Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Great work, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
chore Related to fix/refinement/improvement of end user or new/existing developer functionality tech-debt Unpleasantness that does (or may in future) affect development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants