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
OCPBUGS-28575: Fix issue with PS type mismatch #2051
OCPBUGS-28575: Fix issue with PS type mismatch #2051
Conversation
This commit fixes an issue which would be seen when the cni config file was created with no content. When using the -replace operator with $null, an empty object array was returned. This caused comparison issues with the expected config as it was comparing an array with a string.
@sebsoto: This pull request references Jira Issue OCPBUGS-28575, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Skipping CI for Draft Pull Request. |
/approve cancel |
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.
Left few questions, otherwise LGTM
@@ -140,7 +140,10 @@ $cni_template=$cni_template.Replace("provider_address",$provider_address) | |||
# Compare CNI config with existing file, and replace if necessary | |||
$existing_config="" | |||
if(Test-Path -Path CNI_CONFIG_PATH) { | |||
` + " $existing_config=((Get-Content -Path \"CNI_CONFIG_PATH\" -Raw) -Replace \"`r\",\"\")" + ` | |||
$config_file_content=(Get-Content -Path CNI_CONFIG_PATH -Raw) | |||
if($config_file_content -ne $null) { |
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.
should it also check for non empty?
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.
If you're asking if it should check if the file is empty, thats what this is doing
$config_file_content will be $null if /k/cni/config/cni.conf is empty
@@ -140,7 +140,10 @@ $cni_template=$cni_template.Replace("provider_address",$provider_address) | |||
# Compare CNI config with existing file, and replace if necessary | |||
$existing_config="" | |||
if(Test-Path -Path CNI_CONFIG_PATH) { | |||
` + " $existing_config=((Get-Content -Path \"CNI_CONFIG_PATH\" -Raw) -Replace \"`r\",\"\")" + ` | |||
$config_file_content=(Get-Content -Path CNI_CONFIG_PATH -Raw) |
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.
Shouldn't an existing file without content throw an error?
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.
That is not the case
PS C:\Users\Administrator> rm /k/cni/config/cni.conf; New-Item /k/cni/config/cni.conf -type file
Directory: C:\k\cni\config
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 1/30/2024 5:23 PM 0 cni.conf
PS C:\Users\Administrator> cat /k/cni/config/cni.conf
PS C:\Users\Administrator> $foo=(cat /k/cni/config/cni.conf)
PS C:\Users\Administrator> $foo
PS C:\Users\Administrator> $foo.gettype()
You cannot call a method on a null-valued expression.
At line:1 char:1
+ $foo.gettype()
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
/lgtm |
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.
/lgtm
/jira-refresh |
/cherry-pick release-4.15 |
@sebsoto: once the present PR merges, I will cherry-pick it on top of release-4.15 in a new PR and assign it to you. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mansikulkarni96 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/jira refresh |
@sebsoto: This pull request references Jira Issue OCPBUGS-28575, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/test remaining-required |
/test security |
@sebsoto: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@sebsoto: Jira Issue OCPBUGS-28575: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-28575 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@sebsoto: new pull request created: #2052 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This commit fixes an issue which would be seen when the cni config file was created with no content. When using the -replace operator with $null, an empty object array was returned. This caused comparison issues with the expected config as it was comparing an array with a string.