- Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix bug in cluster scoped ansible operators #4850
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
asmacdo merged 1 commit into operator-framework:master from asmacdo:4647-multinamespace-bugfix May 3, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# entries is a list of entries to include in | ||
# release notes and/or the migration guide | ||
entries: | ||
- description: > | ||
For Anible-based operators, fixed a bug that caused to be unable watch | ||
cluster scoped dependent resources and dependent resources in other | ||
namespaces. | ||
# kind is one of: | ||
# - addition | ||
# - change | ||
# - deprecation | ||
# - removal | ||
# - bugfix | ||
kind: "bugfix" | ||
# Is this a breaking change? | ||
breaking: false | ||
# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS | ||
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST! | ||
# | ||
# The generator auto-detects the PR number from the commit | ||
# message in which this file was originally added. | ||
# | ||
# What is the pull request number (without the "#")? | ||
# pull_request_override: 0 | ||
# Migration can be defined to automatically add a section to | ||
# the migration guide. This is required for breaking changes. | ||
migration: | ||
header: Ensure that existing dependent resources have owner annotations | ||
body: > | ||
Ansible-based operators use owner references (for resources in the same | ||
namespace) and owner annotations(for cluster scoped resources and | ||
resources in other namespaces). If dependent resources were created | ||
without the references/annotations, they cannot be cleaned up by the | ||
operator, and update/deletes will not trigger a reconcile. Follow these | ||
instructions to add owner references/annotations to existing objects. | ||
https://sdk.operatorframework.io/docs/building-operators/ansible/reference/retroactively-owned-resources/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions 51 hack/generate/samples/internal/ansible/testdata/tasks/clusterannotationtest_test.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
- name: Create the test.example.com/v1alpha1.ClusterAnnotationTest | ||
k8s: | ||
state: present | ||
namespace: '{{ namespace }}' | ||
definition: "{{ lookup('template', '/'.join([samples_dir, cr_file])) | from_yaml }}" | ||
wait: yes | ||
wait_timeout: 300 | ||
wait_condition: | ||
type: Running | ||
reason: Successful | ||
status: "True" | ||
vars: | ||
cr_file: 'test_v1alpha1_clusterannotationtest.yaml' | ||
| ||
- name: retrieve configmap | ||
k8s_info: | ||
api_version: v1 | ||
kind: ConfigMap | ||
namespace: "externalnamespace" | ||
name: "clusterannotationtest-sample" | ||
register: configmap | ||
until: (configmap.resources | length) == 1 | ||
| ||
- assert: | ||
that: | ||
- configmap.resources[0].metadata.annotations["operator-sdk/primary-resource"] == primary | ||
- configmap.resources[0].metadata.annotations["operator-sdk/primary-resource-type"] == primary_type | ||
vars: | ||
primary: "osdk-test/clusterannotationtest-sample" | ||
primary_type: "ClusterAnnotationTest.test.example.com" | ||
| ||
- name: change the namespace labels | ||
k8s: | ||
name: "externalnamespace" | ||
api_version: v1 | ||
kind: "Namespace" | ||
wait: yes | ||
definition: | ||
metadata: | ||
labels: | ||
foo: baz | ||
| ||
- name: Make sure the label is changed back | ||
k8s_info: | ||
api_version: v1 | ||
kind: Namespace | ||
name: "externalnamespace" | ||
register: external_namespace | ||
until: external_namespace.resources[0].metadata.labels["foo"] == "bar" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧇 🌮 🍟