Skip to content

docs: Particularize Initializers and Provide Sample Code #3412

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SimonTheLeg
Copy link
Contributor

@SimonTheLeg SimonTheLeg commented May 19, 2025

Summary

  • Irons out some rough edges on the existing documentation
  • Provides some details on the hiearchy of Initializers
  • Provides sample code how to write a custom Initializer

Before starting with a detailed review of the content: Two open questions from my side

  1. For now I have put the code into mkdocs tabs to directly live in the documentation. As the example is rather complex, I am thinking it would be better to place this somewhere into our repo and link from to docs to it. Do you agree? If yes, where would be the best place to put the example?

  2. The code works and initializes the workspaces correctly. However it still logs errors like this one. Do you have any ideas what this could be? Since it logs them constantly, I am not feeling quite happy with the code, but I cannot figure out how to fix it. I have tried setting lc.Name = req.Name, but this runs into the same issue

    time=2025-05-27T13:57:07.530+02:00 level=INFO msg=Reconciling clustername=2563gq6olq0jl826 logger=initializer-controller
    time=2025-05-27T13:57:07.530+02:00 level=ERROR msg="Reconciler error" controller=logicalcluster controllerGroup=core.kcp.io controllerKind=LogicalCluster LogicalCluster.name=cluster namespace="" name=cluster reconcileID=1ac925c2-8b83-4115-8f7e-dca1674ec78c err="LogicalCluster.core.kcp.io \"cluster\" not found"
    

What Type of PR Is This?

/kind documentation

Related Issue(s)

Fixes: making kcp docs a better place :)

Release Notes

NONE

@kcp-ci-bot kcp-ci-bot added dco-signoff: yes Indicates the PR's author has signed the DCO. release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 19, 2025
@kcp-ci-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kcp-ci-bot kcp-ci-bot added the do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label May 19, 2025
@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign scheeles for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@kcp-ci-bot kcp-ci-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 19, 2025
@SimonTheLeg SimonTheLeg force-pushed the fix-initializer-documentation branch from 14d5d6b to fe0fc0d Compare May 27, 2025 12:43
@kcp-ci-bot kcp-ci-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 27, 2025
@SimonTheLeg SimonTheLeg force-pushed the fix-initializer-documentation branch from fe0fc0d to 880a48d Compare May 27, 2025 12:47
@SimonTheLeg SimonTheLeg changed the title doc: Particularize Initializers and Provide Sample Code docs: Particularize Initializers and Provide Sample Code May 27, 2025
@embik
Copy link
Member

embik commented May 27, 2025

Regarding (1):

Maybe it makes sense to focus on the code parts that are relevant to building such a controller instead of a fully working example that includes standard stuff like setting up a manager, generating a rest config, etc?

Regarding (2):

I'm not quite sure, but I suspect the following is happening: When you patch the LogicalCluster, you remove the initializer from its status list. That means that the logical cluster becomes "invisible" to you, since you have finished initialization. I guess that PATCH (or the controller-runtime implementation) wants to get back the patched object, but as soon as you patched it, it's gone. So that's why you are now getting a 404. I suppose a 404 error after patching it is expected and should be caught as such.

But @mjudeikis should comment on this too, it's just a hunch at this point.

@embik
Copy link
Member

embik commented May 27, 2025

/ok-to-test

@kcp-ci-bot kcp-ci-bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label May 27, 2025
@kcp-ci-bot
Copy link
Contributor

@SimonTheLeg: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kcp-test-e2e-sharded 880a48d link true /test pull-kcp-test-e2e-sharded

Full PR test history

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has signed the DCO. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants