Skip to content

fix: when applying Kubernetes manifests, resources should be updated …#1020

Merged
anson627 merged 3 commits intomainfrom
fix-apply-manifest-409-update
Feb 3, 2026
Merged

fix: when applying Kubernetes manifests, resources should be updated …#1020
anson627 merged 3 commits intomainfrom
fix-apply-manifest-409-update

Conversation

@anson627
Copy link
Collaborator

This pull request improves how Kubernetes manifests are applied in the client by adding support for updating resources when they already exist, rather than skipping their creation. It introduces a new _update_single_manifest method and updates both the implementation and associated tests to ensure resources are patched (updated) when a 409 conflict occurs.

Implementation changes:

  • Added the _update_single_manifest method to kubernetes_client.py, which uses the appropriate Kubernetes API to patch resources when they already exist.
  • Modified _apply_single_manifest to call _update_single_manifest on 409 (resource already exists) instead of skipping creation, and updated the log message to reflect the update action.

Test improvements:

  • Updated test_apply_single_manifest_resource_already_exists to check that _update_single_manifest is called and that the log message indicates an update rather than a skipped creation [1] [2].
  • Enhanced test_apply_manifest_from_file_api_exception_409_conflict to verify that the patch method is called for updates and that the correct log message is produced.…when they already exist (409 conflict) rather than skipped.

…when they already exist (409 conflict) rather than skipped.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances the Kubernetes client to update resources when they already exist (409 conflict) instead of skipping creation. It introduces a new _update_single_manifest method that patches existing resources and modifies the exception handling in _apply_single_manifest to call this update method.

Changes:

  • Added _update_single_manifest method to handle resource updates via patch operations for all supported Kubernetes resource types
  • Modified _apply_single_manifest to call _update_single_manifest on 409 conflicts instead of just logging and skipping
  • Updated tests to verify that update method is called and resources are patched correctly

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
modules/python/clients/kubernetes_client.py Added new _update_single_manifest method (170+ lines) with patch operations for all resource types; updated 409 exception handling in _apply_single_manifest to trigger updates
modules/python/tests/clients/test_kubernetes_client.py Enhanced two existing tests to verify _update_single_manifest is called and patch methods are invoked correctly when resources already exist

@anson627 anson627 merged commit 1803351 into main Feb 3, 2026
3 checks passed
@anson627 anson627 deleted the fix-apply-manifest-409-update branch February 3, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants