-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ansible-operator finalizer concurrency issue
For ansible-based operators, this change fixes an issue that caused finalizers to fail to run if the watched resource (CR) is deleted during reconciliation. Fixes #4909 Signed-off-by: Austin Macdonald <[email protected]>
- Loading branch information
Showing
11 changed files
with
167 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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,11 @@ | ||
# entries is a list of entries to include in | ||
# release notes and/or the migration guide | ||
entries: | ||
- description: > | ||
For ansible-based operators, this change fixes an issue that caused | ||
finalizers to fail to run if the watched resource (CR) is deleted during | ||
reconciliation. | ||
kind: "bugfix" | ||
# Is this a breaking change? | ||
breaking: false |
This file contains 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 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
34 changes: 34 additions & 0 deletions
34
hack/generate/samples/internal/ansible/testdata/playbooks/finalizerconcurrencyfinalizer.yml
This file contains 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,34 @@ | ||
--- | ||
- hosts: localhost | ||
gather_facts: no | ||
collections: | ||
- kubernetes.core | ||
- operator_sdk.util | ||
|
||
tasks: | ||
- debug: | ||
msg: "Pausing until configmap exists" | ||
|
||
- name: Wait for configmap | ||
k8s_info: | ||
api_version: v1 | ||
kind: ConfigMap | ||
name: finalizer-concurrency-results | ||
namespace: osdk-test | ||
wait: yes | ||
wait_sleep: 10 | ||
wait_timeout: 30 | ||
|
||
- name: Update configmap | ||
k8s: | ||
state: present | ||
force: yes | ||
definition: | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: finalizer-concurrency-results | ||
namespace: osdk-test | ||
data: | ||
finalizer: "success" | ||
wait: yes |
58 changes: 58 additions & 0 deletions
58
hack/generate/samples/internal/ansible/testdata/tasks/finalizerconcurrency_test.yml
This file contains 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,58 @@ | ||
--- | ||
# TODO(asmacdo) this should be the only task. the other is getting magiced in | ||
- name: Create the test.example.com/v1alpha1.FinalizerConcurrencyTest | ||
k8s: | ||
state: present | ||
definition: | ||
apiVersion: test.example.com/v1alpha1 | ||
kind: FinalizerConcurrencyTest | ||
metadata: | ||
name: finalizer-concurrency-test | ||
namespace: '{{ namespace }}' | ||
wait: no | ||
|
||
- name: While reconcile is paused, delete the CR | ||
k8s: | ||
state: absent | ||
definition: | ||
apiVersion: test.example.com/v1alpha1 | ||
kind: FinalizerConcurrencyTest | ||
metadata: | ||
name: finalizer-concurrency-test | ||
namespace: '{{ namespace }}' | ||
wait: no | ||
|
||
- name: Create a configmap to allow reconciliation to unpause | ||
k8s: | ||
state: present | ||
definition: | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: finalizer-concurrency-results | ||
namespace: osdk-test | ||
wait: no | ||
|
||
- name: Wait for the custom resource to be deleted | ||
k8s_info: | ||
api_version: test.example.com/v1alpha1 | ||
kind: FinalizerConcurrencyTest | ||
namespace: osdk-test # TODO(asmacdo) Fixme | ||
name: finalizer-concurrency-test | ||
register: cr | ||
retries: 10 | ||
delay: 6 | ||
until: not cr.resources | ||
failed_when: cr.resources | ||
|
||
- name: Retrive the cm | ||
k8s_info: | ||
api_version: v1 | ||
kind: ConfigMap | ||
name: finalizer-concurrency-results | ||
namespace: osdk-test | ||
register: finalizer_test | ||
|
||
- name: Assert that finalizer ran | ||
assert: | ||
that: finalizer_test.resources.0.data.finalizer== 'success' |
This file contains 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 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 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 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 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