-
Notifications
You must be signed in to change notification settings - Fork 22
Accept server certificate on start #211
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
Conversation
WalkthroughThis pull request adds two Ansible tasks to retrieve and approve pending OpenShift certificate signing requests (CSRs) during CRC cloud deployment, with the workflow integrated into the main deployment task sequence between certificate replacement and cluster health verification steps. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml (2)
3-4: Usecommunity.kubernetes.k8s_infomodule instead of shell parsing.Shell-based parsing of
ocoutput is fragile; if the output format changes, the awk pattern may fail silently. Kubernetes-native Ansible modules are more robust and idiomatic.Replace the shell command with a proper Kubernetes module:
- name: Get csr in Pending state - ansible.builtin.shell: | - oc get csr --no-headers | awk '/Pending/ {print $1}' + community.kubernetes.k8s_info: + kind: CertificateSigningRequest + api_version: certificates.k8s.io/v1 + kubeconfig: "{{ kubeconfig_path }}" + field_selectors: + - status.conditions[0].type=Pending register: _pending_csr + vars: + _pending_csr_names: "{{ _pending_csr.resources | map(attribute='metadata.name') | list }}"Then adjust the approval task to use
_pending_csr_namesinstead of_pending_csr.stdout_lines.
9-11: Add error handling for certificate approval.If
oc adm certificate approvefails (e.g., CSR already approved), the entire deployment stops. Consider adding error handling or idempotency checks.- name: Approve OpenShift certificate if in Pending state when: _pending_csr.stdout_lines | length > 0 ansible.builtin.shell: | oc adm certificate approve {{ item }} + ignore_errors: true loop: "{{ _pending_csr.stdout_lines }}" + register: _approve_result + changed_when: "'approved' in _approve_result.stdout"Alternatively, use the
community.kubernetes.k8smodule with idempotent patch operations to avoid approval failures on re-runs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
ansible/roles/deploy-crc-cloud/tasks/accept_cert.yaml(1 hunks)ansible/roles/deploy-crc-cloud/tasks/main.yaml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build (macOS-latest, 1.20)
- GitHub Check: build (ubuntu-latest, 1.20)
- GitHub Check: build-and-push-image
🔇 Additional comments (1)
ansible/roles/deploy-crc-cloud/tasks/main.yaml (1)
19-20: Correct placement in the deployment sequence.The certificate acceptance task is appropriately positioned after kubelet and SSH key setup, and before cluster health validation. This aligns well with the PR objective of accepting pending certificates during early deployment stages.
It happens that on clean instance, when Kubelet is started, the host certificate change and the bootstrap procedure would fail, because of missing certificate acceptation. Accept certificates in "Pending" state to avoid errors. Signed-off-by: Daniel Pawlik <[email protected]>
a03c5be to
d2f113f
Compare
It happens that on clean instance, when Kubelet is started, the host certificate change and the bootstrap procedure would fail, because of missing certificate acceptation.
Accept certificates in "Pending" state to avoid errors.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.