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

Update Advanced Topics Doc #2999

Merged
merged 19 commits into from
May 27, 2020

Conversation

theishshah
Copy link
Member

Description of the change:

Update info in advanced topics doc.

Motivation for the change:

Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

Some formatting stuff, nothing major.

Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

A few suggestions

@@ -60,14 +60,18 @@ import (
routev1 "github.com/openshift/api/route/v1"
)

func main() {
func init() {
...

// Adding the routev1
if err := routev1.AddToScheme(mgr.GetScheme()); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Remove this now that below lines were added.

website/content/en/docs/kubebuilder/advanced-topics.md Outdated Show resolved Hide resolved
Copy link
Member

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

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

/lgtm
@theishshah fix the suggestion made by @estroz then you should be good.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 11, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 11, 2020
Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 12, 2020
@@ -60,14 +61,15 @@ import (
routev1 "github.com/openshift/api/route/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

@theishshah This doc is still referencing the old SDK layout filepath. Can't comment there but a few lines above it says:

Call the `AddToScheme()` function for your 3rd party resource and pass it the Manager's scheme via `mgr.GetScheme()`
in `cmd/manager/main.go`.

Where cmd/manager/main.go is now main.go in kubebuilder's layout.

Can you please proof read the doc again for other such references.

@hasbro17
Copy link
Contributor

@theishshah Can you also remove the TODO's from this doc as you address them in this PR.
e.g the doc still has my note:

// TODO: Update the main.go code in these sections to use the init() func to register the scheme instead of doing it in main().

@theishshah theishshah changed the title Update Advanced Topics Doc [WIP] Update Advanced Topics Doc May 12, 2020

> **// TODO:** Remove this section since we're no longer scaffolding main.go to use the SDK's `GenerateAndServeCRMetrics()` util in `pkg/kube-metrics`.

### Handle Cleanup on Deletion

Copy link
Contributor

Choose a reason for hiding this comment

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

@theishshah There's still a TODO here in the finalizer section for updating the finalizer section of this doc with the new var names and signatures of the kubebuilder controller.

// TODO: Update finalizer reconcile code for kubebuilder's default reconciler imports and variable names

@estroz
Copy link
Member

estroz commented May 19, 2020

@theishshah progress on this? I'd like to get this in before defaulting to the new project layout.

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Just fix code intention across the doc.
Otherwise, it shows ok for me.


The operator's Manager supports the core Kubernetes resource types as found in the client-go [scheme][scheme_package] package and will also register the schemes of all custom resource types defined in your project.

```Go
import (
"github.com/example-inc/memcached-operator/pkg/apis"
cachev1alpha1 "github.com/example-inc/memcached-operator/api/v1alpha1
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation:

Screenshot 2020-05-20 at 00 01 48

@camilamacedo86 camilamacedo86 requested a review from hasbro17 May 19, 2020 23:04
@theishshah theishshah changed the title [WIP] Update Advanced Topics Doc Update Advanced Topics Doc May 20, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 20, 2020
Copy link
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

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

The finalizer code is missing.

website/content/en/docs/kubebuilder/advanced-topics.md Outdated Show resolved Hide resolved
Copy link
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

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

@theishshah Still some more changes.

Plus we still have a TODO in the leader election section.

// TODO: Update this section to remove leader-for-life option? Since it's no longer the default.

Just remove that line. Don't think we need to update the leader election content itself.

Comment on lines 66 to 70

utilruntime.Must(clientgoscheme.AddToScheme(mgr.GetScheme()))

utilruntime.Must(routev1.AddToScheme(mgr.GetScheme()))
// +kubebuilder:scaffold:scheme
Copy link
Contributor

Choose a reason for hiding this comment

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

@theishshah Can you please fix this indentation issue and double check this. It still hasn't been fixed from the past 2 reviews.
image

}

// Add finalizer for this CR
if !contains(memcached.GetFinalizers(), memcachedFinalizer) {
if err := r.addFinalizer(reqLogger, memcached); err != nil {
return reconcile.Result{}, err
return ctrl.Result{}, err
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We still have a return reconcile.Result{}, nil on Line 194 below this.

Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2020
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

HI @theishshah,

It still missing fix the layout of the code snippets added. See: https://github.com/operator-framework/operator-sdk/blob/7013dade5f8227e80aaa7a8b57c9c7817434ac6f/website/content/en/docs/kubebuilder/advanced-topics.md. All should have the same indentation which is used in the other docs as well.

Otherwise all fine.

c/c @estroz

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 27, 2020
Copy link
Contributor

@camilamacedo86 camilamacedo86 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 👍
/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2020
Copy link
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

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

@theishshah There are still parts of the reconciler code that are from the old scaffold.
But once you update those, then LGTM.


...

return ctrl.Result{}, nil
}

func (r *ReconcileMemcached) finalizeMemcached(reqLogger logr.Logger, m *cachev1alpha1.Memcached) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (r *ReconcileMemcached) finalizeMemcached(reqLogger logr.Logger, m *cachev1alpha1.Memcached) error {
func (r * MemcachedReconciler) finalizeMemcached(reqLogger logr.Logger, m *cachev1alpha1.Memcached) error {

// of finalizers include performing backups and deleting
// resources that are not owned by this CR, like a PVC.
reqLogger.Info("Successfully finalized memcached")
return nil
}

func (r *ReconcileMemcached) addFinalizer(reqLogger logr.Logger, m *cachev1alpha1.Memcached) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (r *ReconcileMemcached) addFinalizer(reqLogger logr.Logger, m *cachev1alpha1.Memcached) error {
func (r * MemcachedReconciler) addFinalizer(reqLogger logr.Logger, m *cachev1alpha1.Memcached) error {

controllerutil.AddFinalizer(m, memcachedFinalizer)

// Update CR
err := r.client.Update(context.TODO(), m)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err := r.client.Update(context.TODO(), m)
err := r.Update(context.TODO(), m)

@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 27, 2020
@theishshah theishshah merged commit cb45a3b into operator-framework:master May 27, 2020
@theishshah theishshah deleted the advanceddocs branch May 27, 2020 20:43
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.

6 participants