Skip to content

doc: Update existing resources with owner refs #2013

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

Merged

Conversation

asmacdo
Copy link
Member

@asmacdo asmacdo commented Oct 3, 2019

Operator deployed resources created while dependent watches are disabled
cannot have owner information retroactively injected by the proxy. This
patch documents the process of adding that information to existing
resources manually.

@asmacdo asmacdo added language/ansible Issue is related to an Ansible operator project kind/documentation Categorizes issue or PR as related to documentation. labels Oct 3, 2019
@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 3, 2019
@asmacdo
Copy link
Member Author

asmacdo commented Oct 4, 2019

/retest

1 similar comment
@asmacdo
Copy link
Member Author

asmacdo commented Oct 4, 2019

/retest

Copy link
Member

@fabianvf fabianvf left a comment

Choose a reason for hiding this comment

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

Overall content looks good, I think this is tied more to the owner reference injection settings (as described here than dependentWatches, so it probably should go in its own doc with a link in the advanced_options page.

Couple other small questions/comments, but nice work!

@camilamacedo86
Copy link
Contributor

Hi @fabianvf,

Could we not do it be done automatically by using the controllerutil.SetControllerReference for all created objects?

@fabianvf
Copy link
Member

fabianvf commented Oct 8, 2019

@camilamacedo86 The issue is that we don't know whether a resource we're receiving in the proxy is one that we created previously, we'll only see updates coming in (and we don't want the operator to own every resource it touches, just the ones that it creates).

@jmrodri
Copy link
Member

jmrodri commented Oct 9, 2019

Once all the changes @fabianvf suggested are made I'll take another look at it.

@asmacdo asmacdo force-pushed the 1977-doc-belated-owner-reference branch from 5e156a2 to 4ec3749 Compare October 10, 2019 17:16
Copy link
Member

@fabianvf fabianvf left a comment

Choose a reason for hiding this comment

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

Looks great, couple super minor nits/clarifications,

Operator deployed resources created while dependent watches are disabled
cannot have owner information retroactively injected by the proxy. This
patch documents the process of adding that information to existing
resources manually.

Fixes operator-framework#1977
@asmacdo asmacdo force-pushed the 1977-doc-belated-owner-reference branch from 4ec3749 to 45ac3f8 Compare October 10, 2019 19:15
Copy link
Member

@fabianvf fabianvf 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 Oct 10, 2019
@asmacdo
Copy link
Member Author

asmacdo commented Oct 11, 2019

/retest

- apiVersion: cache.example.com/v1alpha1
kind: Memcached
name: example-memcached
uid: ad834522-d9a5-4841-beac-991ff3798c00
Copy link
Contributor

@camilamacedo86 camilamacedo86 Oct 13, 2019

Choose a reason for hiding this comment

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

Hi @fabianvf,

Is required to add the UID? If I would like to do it for a pod for example and the pod be re-created automatically by the API platform which is the default behaviour would not it assume a new UID? So, should not we be able to do that without informing a UID?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the UID field is required to construct an ownerReference. This is to correctly garbage collect if the owner is deleted and then re-created

Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT about we add a note with this info @asmacdo?

Copy link
Member Author

Choose a reason for hiding this comment

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

To me, the delete/recreate edge case seems like an implementation detail which we should leave out to keep the guide simple. I'm happy to add it if it would be helpful though.

resource is a cluster level resource.

`annotation` structure:
* operator-sdk/primary-resource: {metadata.namepace}/{metadata.name}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we would need here specify what is a primary-resource or add a link for where it is defined.

Copy link
Member Author

Choose a reason for hiding this comment

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

What other info do you think is needed, other than how to construct it? I don't see it anywhere in our docs, but it seems like construction is all the user will need to know.


### Owner References and Annotations

Dependent resources *within the same namespace as the owning CR* are
Copy link
Contributor

Choose a reason for hiding this comment

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

The same here.

apiVersion: v1
kind: Namespace
```
#### playbook.yml
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
#### playbook.yml
```suggestion
**<add scallfold path>/playbook.yml**

Copy link
Member

Choose a reason for hiding this comment

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

There is no path or scaffolding for this playbook.yml, it's just an example that the user could copy into a file and use as a starting point for doing this migration.

Copy link
Member Author

Choose a reason for hiding this comment

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

The way I wrote this is a little misleading. I'll reword some things to make this clear.

uid: "{{ extra_owner_data.resources[0].metadata.uid }}"
```

#### `each_resource.yml`
Copy link
Contributor

@camilamacedo86 camilamacedo86 Oct 13, 2019

Choose a reason for hiding this comment

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

Which means each_resource.yml? It is not a file in the scaffold project?

Suggested change
#### `each_resource.yml`
**for each resource**
Following an example for each resource that ....

Copy link
Member

Choose a reason for hiding this comment

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

No, it's a separate file that the user would need to create, these files just serve as a starting point for automating the migration.

If you have many resources to update, it may be easier to use the
following (unsupported) playbook.

#### vars.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think that we should use #### for name of files. The reason for that is that the ### means a subsection, so would make sense we have a subsection in an index with vars.yaml ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I skipped the ## level, so on the next commit, I'll:
s/###/##/ and s/####/###/

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 14, 2019
name: example-memcached
uid: ad834522-d9a5-4841-beac-991ff3798c00
```

Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT?

Suggested change
**NOTE**: The UID field is required to construct an ownerReference. Then, this is to correctly garbage collect if the owner is deleted and then re-created. So, the owner reference is not lost if the resource needs to be re-created by the API.

Is my understand correctly @fabianvf ?

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.

@asmacdo great work 🥇

I added just few NOTES suggestions based on the clarifications of comments.
Besides these small fews nits all is 100%.

/lgtm
/approved

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 14, 2019
Copy link
Member

@fabianvf fabianvf left a comment

Choose a reason for hiding this comment

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

/lgtm

@asmacdo
Copy link
Member Author

asmacdo commented Oct 15, 2019

/retest

@asmacdo asmacdo merged commit 4751b95 into operator-framework:master Oct 15, 2019
@openshift-ci-robot
Copy link

@asmacdo: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/e2e-aws-ansible 0fe97ea link /test e2e-aws-ansible

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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
kind/documentation Categorizes issue or PR as related to documentation. language/ansible Issue is related to an Ansible operator project lgtm Indicates that a PR is ready to be merged. 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.

5 participants