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

Making powervc-certificate optional #86

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions playbooks/roles/ocp-csi-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,25 @@ Requirements

- Running OCP 4.x cluster is needed.
- Cluster must not contain default StorageClass.
- A secret with PowerVC certificate in the `default` namespace.
Secret name must be `powervc-certificate` and must contains `certificate` field.
eg.

```
apiVersion: v1
kind: Secret
metadata:
name: powervc-certificate
namespace: default
type: Opaque
stringData:
certificate: |
-----BEGIN CERTIFICATE-----
IBAgwIBUCCAwIBAgIUn2gAbw0LWHtozBNiLdUtELvr1pyPAzcNAQYjAwDQYJKoZIhv
...
Un2gAIBAb -----END CERTIFICATE-----
```
- Optional :
- A secret with PowerVC certificate in the `default` namespace
Secret name should be `powervc-certificate` and must contains `certificate` field.
eg.

```
apiVersion: v1
kind: Secret
metadata:
name: powervc-certificate
namespace: default
type: Opaque
stringData:
certificate: |
-----BEGIN CERTIFICATE-----
IBAgwIBUCCAwIBAgIUn2gAbw0LWHtozBNiLdUtELvr1pyPAzcNAQYjAwDQYJKoZIhv
...
Un2gAIBAb -----END CERTIFICATE-----
```
irapandey marked this conversation as resolved.
Show resolved Hide resolved

Role Variables
--------------
Expand Down
8 changes: 5 additions & 3 deletions playbooks/roles/ocp-csi-driver/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@
name: powervc-certificate
namespace: default
register: powervc_certificate
ignore_errors: yes

- name: Fail if the powervc-certificate does not exists in default namespace
fail:
- name: If the powervc-certificate does not exists in default namespace
debug:
msg: "PowerVC certificate secret is not present!"
when: powervc_certificate.resources | length == 0

- fail:
- name: If powervc-certificate is empty
Copy link
Contributor

Choose a reason for hiding this comment

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

This task will fail if the above condition is true.

Copy link
Author

Choose a reason for hiding this comment

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

I ran it on a cluster - it just gives a message

TASK [ocp-csi-driver : Check if the PowerVC certificate's secret is exists] *************************************************************************************************************************************************************************
ok: [localhost]

TASK [ocp-csi-driver : If the powervc-certificate does not exists in default namespace] *************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "PowerVC certificate secret is not present!"
}

TASK [ocp-csi-driver : If powervc-certificate is empty] *********************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "PowerVC certificate is empty! Please check the certificate's secret."
}

Copy link
Author

Choose a reason for hiding this comment

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

I have removed the name parameters and replaces fail with debug

Copy link
Author

Choose a reason for hiding this comment

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

TASK [ocp-csi-driver : Check if the PowerVC certificate's secret is exists] *************************************************************************************************************************************************************************
ok: [localhost]

TASK [ocp-csi-driver : If the powervc-certificate does not exists in default namespace] *************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "PowerVC certificate secret is not present!"
}

TASK [ocp-csi-driver : debug] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "PowerVC certificate is empty! Please check the certificate's secret."
}

TASK [ocp-csi-driver : Create namespace for CSI driver validation] **********************************************************************************************************************************************************************************
ok: [localhost]

debug:
msg: "PowerVC certificate is empty! Please check the certificate's secret."
when: >
(powervc_certificate.resources[0].data.certificate is not defined) or
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add one more condition to validate only if the certificate is exists powervc_certificate.resources | length != 0 ?

Copy link
Author

Choose a reason for hiding this comment

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

made the changes - can you review and let me know if that looks good

Expand Down