Closed dwertent closed 9 months ago
PR Description updated to latest commit (https://github.com/kubescape/storage/commit/8b92cc2110db97123040e31e0fe5b76fc977cbe2)
๐ฏ Main theme: Modifying the deletion strategy of application profiles based on template hash
๐ PR summary: This PR introduces changes to the deletion strategy of application profiles in the cleanup process. It replaces the deleteByWlid
function with deleteByTemplateHashOrWlid
for certain resources. A new field RunningTemplateHash
is added to the ResourceMaps
struct. The function fetchInstanceIdsAndImageIdsFromRunningPods
is renamed and now also fetches replicas from running pods. The version of the dependency github.com/kubescape/k8s-interface
is updated.
๐ Type of PR: Bug fix
๐งช Relevant tests added: No
โฑ๏ธ Estimated effort to review [1-5]: 3, because the PR involves changes in the deletion strategy which requires careful review to ensure it doesn't introduce any issues. The PR is of moderate size and complexity.
๐ Security concerns: No security concerns found
๐ก General suggestions: It would be beneficial to include unit tests for the new function deleteByTemplateHashOrWlid
to ensure its correctness. Also, consider adding comments to the new and updated functions to provide context and explain their purpose and how they work.
relevant file | pkg/cleanup/cleanup.go |
suggestion |
Consider handling the case where both |
relevant line | func deleteByTemplateHashOrWlid(, string, metadata *metav1.ObjectMeta, resourceMaps ResourceMaps) bool { |
relevant file | pkg/cleanup/discovery.go |
suggestion |
It would be good to handle the case where the |
relevant line | if replicaHash, ok := pod.GetLabel("pod-template-hash"); ok { |
Summary:
Type
bug_fix
Description
deleteByWlid
function has been replaced bydeleteByTemplateHashOrWlid
for "applicationactivities", "applicationprofiles", and "applicationprofilesummaries" in theresourceKindToHandler
map.deleteByTemplateHashOrWlid
has been added which deletes based on template hash or wlid.fetchInstanceIdsAndImageIdsFromRunningPods
has been renamed tofetchInstanceIdsAndImageIdsAndReplicasFromRunningPods
and now also fetches replicas from running pods.RunningTemplateHash
has been added to theResourceMaps
struct.github.com/kubescape/k8s-interface
has been updated from v0.0.153 to v0.0.154.PR changes walkthrough
1 files
cleanup.go
pkg/cleanup/cleanup.go
**This file has seen changes in the import statements and the
`resourceKindToHandler` map. The function `deleteByWlid` has
been replaced by `deleteByTemplateHashOrWlid` for the keys
"applicationactivities", "applicationprofiles", and
"applicationprofilesummaries". A new function
`deleteByTemplateHashOrWlid` has been added which deletes
based on template hash or wlid.**
1 files
discovery.go
pkg/cleanup/discovery.go
**The function `fetchInstanceIdsAndImageIdsFromRunningPods`
has been renamed to
`fetchInstanceIdsAndImageIdsAndReplicasFromRunningPods` and
now also fetches replicas from running pods. A new field
`RunningTemplateHash` has been added to the `ResourceMaps`
struct.**
2 files
go.mod
go.mod
**The version of the dependency
`github.com/kubescape/k8s-interface` has been updated from
v0.0.153 to v0.0.154.**
go.sum
go.sum
**The checksums for the dependency
`github.com/kubescape/k8s-interface` have been updated to
reflect the new version v0.0.154.**
User description
Sorry, we do not accept changes directly against this repository. Please see CONTRIBUTING.md for information on where and how to contribute instead.