-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #1447 changed places where we check for nil interface{} in the callback functions for AwaitUntil to cast first. However this can result in an invalid type conversion panic depending on how the value is returned from the operation function. In Go, an interface var contains both a type and value so there are 2 cases for a nil: 1) The type is non-nil and the value is nil 2) The type and value are nil For #1, the interface{} var is not actually nil so checking 'if result == nil' yields false. Eg, var s *string var i interface{} = s if i == nil { // yields false b/c i is typed } In this case, we can cast to the expected type and then check for nil. s := i.(*string) if s == nil { // yields true } For #2, the interface{} var is untyped so nil check yields true: var i interface{} = nil if i == nil { // yields true } So in cases where we directly return nil from an operation function, the nil check in the result function is valid. The actual reason for #1447 was b/c of a nil pointer panic in AwaitGatewaysWithStatus. This function was previously changed to call 'findGateway' and return its values. However 'findGateway' returns *unstructured.Unstructured so now the operation function returned a typed interface{} var. So if 'findGateway' returns a nil *unstructured.Unstructured value, the 'result == nil' check in the result function yields false. This resulted in the panic when 'result' was later casted and accessed. So we basically need to undo #1447. For AwaitGatewayWithStatus and AwaitGatewayFullyConnected, check the error from 'findGateway' and return a nil interface{} value. Signed-off-by: Tom Pantelis <[email protected]>
- Loading branch information
Showing
5 changed files
with
24 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters