-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix recreate ResourceClaim bug (#114)
- Loading branch information
Showing
3 changed files
with
193 additions
and
2 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
180 changes: 180 additions & 0 deletions
180
test/roles/poolboy_test_simple/tasks/test-recreate-01.yaml
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,180 @@ | ||
--- | ||
# Test to resolve issue of resource claim being recreated binds to deleted handle | ||
- name: Create ResourceProvider test-recreate-01 | ||
kubernetes.core.k8s: | ||
definition: | ||
apiVersion: "{{ poolboy_domain }}/v1" | ||
kind: ResourceProvider | ||
metadata: | ||
name: test-recreate-01 | ||
namespace: "{{ poolboy_namespace }}" | ||
labels: >- | ||
{{ { | ||
poolboy_domain ~ "/test": "simple" | ||
} }} | ||
spec: | ||
override: | ||
apiVersion: "{{ poolboy_domain }}/v1" | ||
kind: ResourceClaimTest | ||
metadata: | ||
namespace: "{{ poolboy_test_namespace }}" | ||
spec: | ||
foo: bar | ||
validation: | ||
openAPIV3Schema: | ||
additionalProperties: false | ||
properties: | ||
metadata: | ||
additionalProperties: false | ||
properties: | ||
name: | ||
pattern: ^test-recreate-01-[a-z0-9]+$ | ||
type: string | ||
required: | ||
- name | ||
type: object | ||
|
||
- name: Create ResourceClaim test-recreate-01 | ||
kubernetes.core.k8s: | ||
definition: | ||
apiVersion: "{{ poolboy_domain }}/v1" | ||
kind: ResourceClaim | ||
metadata: | ||
name: test-recreate-01 | ||
namespace: "{{ poolboy_test_namespace }}" | ||
labels: >- | ||
{{ { | ||
poolboy_domain ~ "/test": "simple" | ||
} }} | ||
spec: | ||
resources: | ||
- provider: | ||
name: test-recreate-01 | ||
template: | ||
metadata: | ||
name: test-recreate-01-a | ||
|
||
- name: Verify handling of ResourceClaim test-recreate-01 | ||
kubernetes.core.k8s_info: | ||
api_version: "{{ poolboy_domain }}/v1" | ||
kind: ResourceClaim | ||
name: test-recreate-01 | ||
namespace: "{{ poolboy_test_namespace }}" | ||
register: r_get_resource_claim | ||
failed_when: >- | ||
r_get_resource_claim.resources[0].status.resources[0].state is undefined | ||
until: r_get_resource_claim is success | ||
delay: 1 | ||
retries: 10 | ||
|
||
- name: Save facts from for ResourceClaim test-recreate-01 | ||
set_fact: | ||
resource_handle_name: >- | ||
{{ r_get_resource_claim.resources[0].status.resourceHandle.name }} | ||
- name: Verify state of ResourceClaim test-recreate-01 | ||
vars: | ||
__state: "{{ r_get_resource_claim.resources[0] }}" | ||
assert: | ||
that: | ||
- __state.status.resources | length == 1 | ||
- __state.status.resources[0].state.metadata.name == 'test-recreate-01-a' | ||
|
||
- name: Verify creation of ResourceClaimTest test-recreate-01-a | ||
kubernetes.core.k8s_info: | ||
api_version: "{{ poolboy_domain }}/v1" | ||
kind: ResourceClaimTest | ||
name: test-recreate-01-a | ||
namespace: "{{ poolboy_test_namespace }}" | ||
register: r_get_resource_claim_test | ||
failed_when: r_get_resource_claim_test.resources | length != 1 | ||
until: r_get_resource_claim_test is success | ||
delay: 1 | ||
retries: 10 | ||
|
||
- name: Verify state of ResourceClaimTest test-recreate-01-a | ||
vars: | ||
__state: "{{ r_get_resource_claim_test.resources[0] }}" | ||
assert: | ||
that: | ||
- __state.spec.foo == 'bar' | ||
|
||
- name: Delete ResourceClaim test-recreate-01 | ||
kubernetes.core.k8s: | ||
api_version: "{{ poolboy_domain }}/v1" | ||
kind: ResourceClaim | ||
name: test-recreate-01 | ||
namespace: "{{ poolboy_test_namespace }}" | ||
state: absent | ||
|
||
- name: Verify delete of ResourceClaim test-recreate-01 | ||
kubernetes.core.k8s_info: | ||
api_version: "{{ poolboy_domain }}/v1" | ||
kind: ResourceClaim | ||
name: test-recreate-01 | ||
namespace: "{{ poolboy_test_namespace }}" | ||
register: r_get_resource_claim | ||
failed_when: r_get_resource_claim.resources | length != 0 | ||
until: r_get_resource_claim is success | ||
retries: 5 | ||
delay: 1 | ||
|
||
- name: Verify delete of ResourceHandle for test-recreate-01 | ||
kubernetes.core.k8s_info: | ||
api_version: "{{ poolboy_domain }}/v1" | ||
kind: ResourceHandle | ||
name: "{{ resource_handle_name }}" | ||
namespace: "{{ poolboy_namespace }}" | ||
register: r_get_resource_handle | ||
failed_when: r_get_resource_handle.resources | length != 0 | ||
until: r_get_resource_handle is success | ||
retries: 5 | ||
delay: 1 | ||
|
||
- name: Verify delete of ResourceClaimTest test-recreate-01-a | ||
kubernetes.core.k8s_info: | ||
api_version: "{{ poolboy_domain }}/v1" | ||
kind: ResourceClaimTest | ||
name: test-recreate-01-a | ||
namespace: "{{ poolboy_test_namespace }}" | ||
register: r_get_resource_claim_test | ||
failed_when: r_get_resource_claim_test.resources | length != 0 | ||
until: r_get_resource_claim_test is success | ||
delay: 1 | ||
retries: 10 | ||
|
||
- name: Receate ResourceClaim test-recreate-01 | ||
kubernetes.core.k8s: | ||
definition: | ||
apiVersion: "{{ poolboy_domain }}/v1" | ||
kind: ResourceClaim | ||
metadata: | ||
name: test-recreate-01 | ||
namespace: "{{ poolboy_test_namespace }}" | ||
labels: >- | ||
{{ { | ||
poolboy_domain ~ "/test": "simple" | ||
} }} | ||
spec: | ||
resources: | ||
- provider: | ||
name: test-recreate-01 | ||
template: | ||
metadata: | ||
name: test-recreate-01-a | ||
|
||
- name: Verify recreate handling of ResourceClaim test-recreate-01 | ||
kubernetes.core.k8s_info: | ||
api_version: "{{ poolboy_domain }}/v1" | ||
kind: ResourceClaim | ||
name: test-recreate-01 | ||
namespace: "{{ poolboy_test_namespace }}" | ||
register: r_get_resource_claim | ||
failed_when: >- | ||
r_get_resource_claim.resources[0].status.resources[0].state is undefined or | ||
r_get_resource_claim.resources[0].status.resourceHandle.name is undefined or | ||
r_get_resource_claim.resources[0].status.resourceHandle.name == resource_handle_name | ||
until: r_get_resource_claim is success | ||
delay: 1 | ||
retries: 10 | ||
... |
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