Skip to content

refactor: general cleanup, isolating resource concerns behind services and reduce controllers to minimal reconciliation flow - #1

Merged
tuunit merged 9 commits into
mainfrom
refactor/code-cleanup-and-proper-abstraction
Aug 13, 2026
Merged

refactor: general cleanup, isolating resource concerns behind services and reduce controllers to minimal reconciliation flow#1
tuunit merged 9 commits into
mainfrom
refactor/code-cleanup-and-proper-abstraction

Conversation

@tuunit

@tuunit tuunit commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

tuunit added 3 commits July 16, 2026 09:54
…etter abstractions

Signed-off-by: Jan Larwig <jan@larwig.com>
…r/ package

Signed-off-by: Jan Larwig <jan@larwig.com>
…straction and boundaries between resources and reducing the controllers package to the minimum flow

Signed-off-by: Jan Larwig <jan@larwig.com>
@tuunit
tuunit force-pushed the refactor/code-cleanup-and-proper-abstraction branch from 7173627 to 9023874 Compare July 16, 2026 08:04
tuunit and others added 5 commits July 16, 2026 10:34
Signed-off-by: Jan Larwig <jan@larwig.com>
Signed-off-by: Jan Larwig <jan@larwig.com>
… quick-start docs

- .devcontainer/devcontainer.json: add named volumes for bash history
  (/commandhistory) and docker-in-docker state (/var/lib/docker) so both
  survive container rebuilds; set HISTFILE accordingly
- .devcontainer/post-install.sh: install clusterctl and the stackit CLI
  (with bash completions), flush bash history after every command via
  PROMPT_COMMAND, verify both tools at the end of setup
- .gitignore: ignore local dev/debug artifacts (.DS_Store, cluster.yaml,
  kind-config.yaml, devcontainer-lock.json)
- docs/src/quick-start.md: document the .stackit/ service-account key
  convention, add the STACKIT_SSH_KEY_NAME env var (used by the bastion
  cluster template), add an optional kind-config.yaml section for
  enterprise TLS-intercepting proxies (e.g. Zscaler), and write the
  generated cluster manifest to a file before applying it

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors controller reconciliation into root-level controller, scope, cloud-service, and utility packages while expanding webhook validation and tests.

Changes:

  • Separates cloud resource concerns into reusable services.
  • Adds webhook validation/defaulting and regression coverage.
  • Updates build, development, CI, and documentation paths for the new layout.

Reviewed changes

Copilot reviewed 43 out of 62 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
webhook/v1alpha1/webhook_validation_test.go Adds webhook tests
webhook/v1alpha1/webhook_suite_test.go Fixes envtest paths
webhook/v1alpha1/validation_helpers.go Updates cloud import
webhook/v1alpha1/stackitmachinetemplate_webhook.go Adds machine-template webhook
webhook/v1alpha1/stackitmachine_webhook.go Adds machine webhook
webhook/v1alpha1/stackitclustertemplate_webhook.go Adds cluster-template webhook
webhook/v1alpha1/stackitcluster_webhook.go Adds cluster webhook
util/tags.go Adds resource-tag helpers
util/tags_test.go Tests tag helpers
util/reconcile.go Adds reconciliation helpers
util/credentials.go Updates cloud import
util/credentials_test.go Adds credential tests
util/conditions.go Consolidates condition handling
util/bootstrap.go Adds bootstrap extraction
util/bootstrap_test.go Tests bootstrap extraction
tilt-provider.yaml Updates watched paths
test/e2e/e2e_test.go Updates package imports
scope/machine_scope.go Adds machine state helpers
scope/cluster_scope.go Adds cluster state helpers
README.md Uses local logo path
pkg/util/conditions.go Removes old utility
Makefile Updates manager entrypoint
internal/controller/stackitmachine_controller.go Removes old machine controller
internal/controller/stackitcluster_controller.go Removes old cluster controller
internal/controller/contract_helpers.go Removes old helpers
go.mod Upgrades to Go 1.26
docs/src/quick-start.md Expands setup guidance
docs/src/development/architecture.md Documents new layout
Dockerfile Updates Go and entrypoint
controller/suite_test.go Fixes envtest paths
controller/stackitmachine_watches.go Extracts machine watches
controller/stackitmachine_infrastructure.go Extracts machine infrastructure flow
controller/stackitmachine_controller.go Minimizes machine reconciler
controller/stackitmachine_controller_test.go Adds regression coverage
controller/stackitcluster_infrastructure.go Extracts cluster infrastructure flow
controller/stackitcluster_controller.go Minimizes cluster reconciler
controller/stackitcluster_controller_test.go Updates cluster tests
controller/stackitcluster_bastion.go Extracts bastion flow
controller/controller_test_helpers_test.go Adds reconciliation helper
controller/constants.go Centralizes constants
cmd/manager/main.go Wires new packages and events
cmd/cleanup-stackit/main.go Updates package imports
cloud/types.go Defines cloud-domain types
cloud/services/loadbalancer/loadbalancer.go Adds load-balancer service
cloud/services/bastion/bastion.go Adds bastion service
cloud/sdk_client.go Refines SDK reconciliation
cloud/sdk_client_test.go Adds SDK regressions
cloud/sdk_client_integration_test.go Adds integration tests
cloud/providerid.go Adds provider-ID handling
cloud/providerid_test.go Tests provider IDs
cloud/fake/client.go Updates fake client import
cloud/errors.go Defines cloud errors
cloud/errors_test.go Tests error classification
cloud/client.go Defines cloud client API
cloud/cleanup.go Adds tag-based cleanup
cloud/cleanup_test.go Tests cleanup behavior
AGENTS.md Updates repository layout
.gitignore Ignores local artifacts
.github/workflows/test.yml Limits push tests to main
.github/workflows/lint.yml Limits push lint to main
.devcontainer/post-install.sh Adds development CLIs
.devcontainer/devcontainer.json Updates image and persistence
Suppressed comments (1)

cloud/sdk_client.go:708

  • Duplicate CIDRs are accepted by the API validation, but existingRules is not updated after a create, so repeated entries cause duplicate CreateSecurityGroupRule requests and can fail bastion reconciliation. Use the desired map to skip entries already processed.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

For(&infrav1.StackitCluster{}).
Watches(&clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(r.stackitClusterRequestsForCluster)).
Watches(&corev1.ConfigMap{}, handler.EnqueueRequestsFromMapFunc(r.stackitClusterRequestsForCloudInitRef)).
Watches(&corev1.Secret{}, handler.EnqueueRequestsFromMapFunc(r.stackitClusterRequestsForCloudInitRef)).
Comment on lines +46 to +48
return stackitMachineRequestsForMachines(machines.Items, func(machine clusterv1.Machine) bool {
return machine.Spec.ClusterName == stackitCluster.Name
})
Comment on lines +74 to +76
server, created, err := r.ensureServer(ctx, cloudClient, s, bootstrapData)
if err != nil {
return util.CloudFailureResult(
Comment on lines +144 to +148
needsLoadBalancerCleanup := isControlPlaneMachine(s.Machine) &&
s.StackitCluster.Spec.APIServerLoadBalancer.Enabled &&
s.StackitCluster.Status.APIServerLoadBalancerID != ""
if sm.Status.InstanceID == "" && !needsLoadBalancerCleanup {
controllerutil.RemoveFinalizer(sm, infrav1.MachineFinalizer)
Comment on lines +188 to +190
func (r *StackitClusterReconciler) reconcileDelete(ctx context.Context, s *scope.ClusterScope) error {
sc := s.StackitCluster
if sc.Status.APIServerLoadBalancerID != "" || hasBastionStatus(sc.Status.Bastion) || sc.Spec.APIServerLoadBalancer.Enabled {
Signed-off-by: Jan Larwig <jan@larwig.com>
@tuunit

tuunit commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

Pull request overview

Refactors controller reconciliation into root-level controller, scope, cloud-service, and utility packages while expanding webhook validation and tests.

Will be addressed in future / separate PRs as those issues are independent of the refactoring

@tuunit
tuunit merged commit 16a3d8a into main Aug 13, 2026
4 checks passed
@tuunit
tuunit deleted the refactor/code-cleanup-and-proper-abstraction branch August 13, 2026 10:49
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