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

Revert "add label with parent resource version" #154

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

dwertent
Copy link

@dwertent dwertent commented Dec 3, 2023

type:

bug_fix


description:

This PR reverts changes related to the addition of a parent resource version label which was causing label naming compatibility issues. The changes are reflected in multiple Go files and the Go module file. The main changes include:

  • Removal of the ParentResourceVersion field from the WatchedContainerData struct in utils.go.
  • Modification of the getContainerInfo function in relevancy_manager.go to no longer return parentResourceVersion.
  • Changes in network_neighbors.go and network_neighbors_test.go to adjust the generation of network neighbor names and labels.
  • Downgrade of the k8s-interface package version in go.mod from v0.0.150 to v0.0.148.

main_files_walkthrough:

files:
  • pkg/utils/utils.go: Removed the ParentResourceVersion field from the WatchedContainerData struct.
  • pkg/relevancymanager/v1/relevancy_manager.go: Modified the getContainerInfo function to no longer return parentResourceVersion.
  • pkg/networkmanager/network_neighbors.go: Adjusted the generation of network neighbor names and labels.
  • pkg/networkmanager/network_neighbors_test.go: Adjusted the generation of network neighbor names and labels in the test cases.
  • go.mod: Downgraded the k8s-interface package version from v0.0.150 to v0.0.148.

User Description:

Reverts #151

This change will break label naming compatibility.

Copy link

PR Description updated to latest commit (a47b695)

Copy link

PR Analysis

  • 🎯 Main theme: Reverting changes related to the addition of a parent resource version label
  • 📝 PR summary: This PR reverts changes that added a parent resource version label, which was causing label naming compatibility issues. The changes are reflected in multiple Go files and the Go module file. The main changes include the removal of the ParentResourceVersion field, modification of the getContainerInfo function, adjustments in the generation of network neighbor names and labels, and downgrade of the k8s-interface package version.
  • 📌 Type of PR: Bug fix
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 3, because the PR involves changes in multiple files and requires understanding of the context and the reason why the changes are being reverted.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • 💡 General suggestions: The PR seems to be well-structured and the changes are clearly explained. However, it would be beneficial to add tests that validate the changes and ensure that the issues that led to this revert do not occur again in the future.

  • 🤖 Code feedback:
    • relevant file: pkg/relevancymanager/v1/relevancy_manager.go
      suggestion: Consider adding error handling for the case when the parent workload cannot be found. This could help to avoid potential issues in the future. [important]
      relevant line: '+ return imageID, imageTag, parentWlid, instanceID, fmt.Errorf("fail to get parent workload %s in namespace %s with error: %v", pod.GetName(), pod.GetNamespace(), err)'

    • relevant file: pkg/networkmanager/network_neighbors.go
      suggestion: It might be a good idea to add a default case in the if-else statement for handling the splitting of the apiVersionSplitted variable. This could help to handle unexpected cases and improve the robustness of the code. [medium]
      relevant line: '+ } else if len(apiVersionSplitted) == 1 {'

    • relevant file: pkg/relevancymanager/v1/relevancy_manager.go
      suggestion: It might be beneficial to add a check for the validity of the imageID and imageTag after they are retrieved. This could help to ensure that valid data is being used in the subsequent code. [medium]
      relevant line: '+ imageID, imageTag, parentWlid, instanceID, err := rm.getContainerInfo(container.K8s.Namespace, container.K8s.PodName, container.K8s.ContainerName)'

    • relevant file: go.mod
      suggestion: It would be helpful to add a comment explaining why the version of k8s-interface package is being downgraded. This could provide context for future developers who might be looking at this change. [medium]
      relevant line: '+ github.com/kubescape/k8s-interface v0.0.148'

How to use

Instructions

To invoke the PR-Agent, add a comment using one of the following commands:
/review: Request a review of your Pull Request.
/describe: Update the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
/ask <QUESTION>: Ask a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.
/add_docs: Generate docstring for new components introduced in the PR.
/generate_labels: Generate labels for the PR based on the PR's contents.
see the tools guide for more details.

To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

Copy link

github-actions bot commented Dec 3, 2023

Summary:

  • License scan: success
  • Credentials scan: success
  • Vulnerabilities scan: success
  • Unit test: success
  • Go linting: success

@matthyx matthyx merged commit 622d7d4 into main Dec 4, 2023
6 checks passed
@matthyx matthyx deleted the revert-151-versionlabel branch December 4, 2023 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants