Skip to content

Comments

🐛 Fixes #472 Remove stateless kai resources when set to false#533

Merged
jmontleon merged 2 commits intokonveyor:mainfrom
jmontleon:term-kai-when-false
Feb 4, 2026
Merged

🐛 Fixes #472 Remove stateless kai resources when set to false#533
jmontleon merged 2 commits intokonveyor:mainfrom
jmontleon:term-kai-when-false

Conversation

@jmontleon
Copy link
Member

@jmontleon jmontleon commented Feb 3, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Ensured config always includes a proper models mapping and added a terminating newline to avoid parsing issues.
  • Refactor

    • Simplified deployment logic to use centralized state flags, reducing nested conditions and improving reliability of component provisioning.
  • Chores

    • Rendered database-related environment settings only when the corresponding service is enabled to prevent unnecessary configuration exposure.

@jmontleon jmontleon changed the title 🐛 Fixes #472 Remove stateless llm proxy and solution server resources when set to false 🐛 Fixes #472 Remove stateless kai resources when set to false Feb 3, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

Centralizes deployment state in Ansible tasks, converting nested conditionals to state-driven tasks for KAI DB, LLM Proxy, and Solution Server; ensures kai-api deployment only sets KAI_DB_DSN when the solution server is enabled; fixes llm-proxy ConfigMap YAML by providing models: [] in the else-branch and adds a trailing newline.

Changes

Cohort / File(s) Summary
LLM Proxy ConfigMap template
roles/tackle/templates/kai/llm-proxy-configmap.yaml.j2
Fix else-branch YAML to include models: [] (ensures models key exists) and add a trailing newline at EOF.
Ansible task flow
roles/tackle/tasks/kai.yml
Replace nested conditional blocks with centralized state facts (kai_common_state, kai_llm_proxy_state, kai_solution_server_state) and convert DB, LLM Proxy, and Solution Server resources into discrete tasks gated by those state variables.
Kai API deployment template
roles/tackle/templates/kai/kai-api-deployment.yaml.j2
Wrap KAI_DB_DSN env var rendering in a Jinja conditional so it is included only when kai_solution_server_enabled is true.

Sequence Diagram(s)

sequenceDiagram
  participant Ansible
  participant StateCalc as "State Calculator"
  participant K8sAPI as "Kubernetes API"
  participant LLMProxy as "LLM Proxy Components"
  participant SolutionAPI as "KAI Solution Server"
  participant DB as "KAI DB"

  rect rgba(200,220,255,0.5)
  Ansible->>StateCalc: Evaluate kai_common_state, kai_llm_proxy_state, kai_solution_server_state
  StateCalc-->>Ansible: States
  end

  rect rgba(200,255,200,0.5)
  Ansible->>K8sAPI: Create/merge KAI DB (if kai_common_state)
  K8sAPI-->>DB: Deploy DB resources
  end

  rect rgba(255,230,200,0.5)
  Ansible->>K8sAPI: Create ConfigMap, Deployment, Service for LLM Proxy (if kai_llm_proxy_state)
  K8sAPI-->>LLMProxy: Provision LLM Proxy resources
  end

  rect rgba(255,200,220,0.5)
  Ansible->>K8sAPI: Deploy KAI Solution Server (if kai_solution_server_state)
  K8sAPI-->>SolutionAPI: Deploy Solution Server (env KAI_DB_DSN only rendered when enabled)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through tasks both near and far,
States aligned like twinkling stars,
Configs tidy, envs now true,
Deployments hum—hooray! anew 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing an issue where stateless KAI resources are not properly removed when disabled. The changes across multiple files implement state-driven control to ensure resources are cleaned up when set to false.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jmontleon jmontleon requested review from djzager and fabianvf February 3, 2026 18:58
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@roles/tackle/tasks/kai.yml`:
- Around line 83-87: The ConfigMap task "Create LLM Proxy Client Configuration"
currently uses "state: present" with "when: kai_solution_server_enabled | bool"
so it is skipped rather than removed when the server is disabled; change the
task to set state conditionally (e.g. state: present if
kai_solution_server_enabled | bool else absent) or drive state from the
lifecycle variable kai_solution_server_state so the k8s module will create or
delete the template kai/llm-proxy-client-configmap.yaml.j2 appropriately instead
of merely skipping the task.
- Around line 67-71: The ConfigMap task "Create LLM Proxy ConfigMap" currently
uses state: present with a when: kai_llm_proxy_enabled | bool so it is only
skipped when disabled and never removed; change it to always run and set the
state based on kai_llm_proxy_enabled (e.g. state: "{{ 'present' if
kai_llm_proxy_enabled | bool else 'absent' }}") and remove the when clause,
keeping the same template kai/llm-proxy-configmap.yaml.j2 so the ConfigMap is
created when true and deleted when false.
🧹 Nitpick comments (1)
roles/tackle/tasks/kai.yml (1)

73-98: Minor: Inconsistent spacing after state:.

Some lines have double spaces (state: "{{ ... }}"), others have single. Consider normalizing for consistency.

✨ Proposed fix for spacing consistency
 - name: Create LLM Proxy Deployment
   k8s:
-    state:  "{{ kai_llm_proxy_state }}"
+    state: "{{ kai_llm_proxy_state }}"
     template: kai/llm-proxy-deployment.yaml.j2

 - name: Create LLM Proxy Service
   k8s:
-    state:  "{{ kai_llm_proxy_state }}"
+    state: "{{ kai_llm_proxy_state }}"
     template: kai/llm-proxy-service.yaml.j2

(Same for lines 91 and 97)

@jmontleon jmontleon force-pushed the term-kai-when-false branch from c36b3d2 to b317260 Compare February 3, 2026 19:12
@jmontleon jmontleon requested a review from mguetta1 February 3, 2026 19:13
@jmontleon jmontleon force-pushed the term-kai-when-false branch from b317260 to 905c924 Compare February 3, 2026 19:54
Copy link
Contributor

@fabianvf fabianvf left a comment

Choose a reason for hiding this comment

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

Not sure why the test failed so unhelpfully

value: /api
- name: KAI_LLM_PARAMS
value: '{{ kai_llm_params | to_json }}'
{% if kai_solution_server_enabled|bool %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit, this template is for the kai-solution-server, so I don't think we need this extra guard

Copy link
Member Author

@jmontleon jmontleon Feb 3, 2026

Choose a reason for hiding this comment

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

When kai-solution-server is false pg_password is undefined causing an undefined variable error if it's not guarded by the conditional.

@jmontleon jmontleon force-pushed the term-kai-when-false branch from 905c924 to 5cb0837 Compare February 4, 2026 00:28
Copy link
Contributor

@mguetta1 mguetta1 left a comment

Choose a reason for hiding this comment

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

LGTM

@jmontleon jmontleon force-pushed the term-kai-when-false branch from 5cb0837 to 05188a8 Compare February 4, 2026 15:31
Signed-off-by: Jason Montleon <jmontleo@redhat.com>
@jmontleon jmontleon force-pushed the term-kai-when-false branch from 05188a8 to 98a806d Compare February 4, 2026 15:44
…t to false

Signed-off-by: Jason Montleon <jmontleo@redhat.com>
@jmontleon jmontleon force-pushed the term-kai-when-false branch from 66d6187 to 05e3bcd Compare February 4, 2026 16:12
@jmontleon jmontleon self-assigned this Feb 4, 2026
@jmontleon jmontleon added the cherry-pick/release-0.9 This PR should be cherry-picked to release-0.9 branch label Feb 4, 2026
@jmontleon jmontleon merged commit fe9f99a into konveyor:main Feb 4, 2026
24 of 26 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 4, 2026
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Ensured config always includes a proper models mapping and added a
terminating newline to avoid parsing issues.

* **Refactor**
* Simplified deployment logic to use centralized state flags, reducing
nested conditions and improving reliability of component provisioning.

* **Chores**
* Rendered database-related environment settings only when the
corresponding service is enabled to prevent unnecessary configuration
exposure.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jason Montleon <jmontleo@redhat.com>
Signed-off-by: Cherry Picker <noreply@github.com>
@konveyor-ci-bot
Copy link

PR cherry-picked to branch release-0.9. Backport PR: #539

jmontleon added a commit that referenced this pull request Feb 5, 2026
…539)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Ensured config always includes a proper models mapping and added a
terminating newline to avoid parsing issues.

* **Refactor**
* Simplified deployment logic to use centralized state flags, reducing
nested conditions and improving reliability of component provisioning.

* **Chores**
* Rendered database-related environment settings only when the
corresponding service is enabled to prevent unnecessary configuration
exposure.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jason Montleon <jmontleo@redhat.com>
Signed-off-by: Cherry Picker <noreply@github.com>

Signed-off-by: Jason Montleon <jmontleo@redhat.com>
Signed-off-by: Cherry Picker <noreply@github.com>
Co-authored-by: Jason Montleon <jmontleo@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/release-0.9 This PR should be cherry-picked to release-0.9 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants