-
Notifications
You must be signed in to change notification settings - Fork 73
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
Fixes #18926: nodes API with include managementTechnologyDetails leads to error 500 response #3513
Merged
fanf
merged 1 commit into
Normation:branches/rudder/6.1
from
fanf:bug_18926/nodes_api_with_include_managementtechnologydetails_leads_to_error_500_response
Feb 28, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
118 changes: 118 additions & 0 deletions
118
webapp/sources/rudder/rudder-rest/src/test/resources/api/api_nodes.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
--- | ||
description: Get node (minimal) | ||
method: GET | ||
url: /api/nodes/node1?include=minimal | ||
response: | ||
code: 200 | ||
content: >- | ||
{ | ||
"action":"nodeDetails", | ||
"id":"node1", | ||
"result":"success", | ||
"data":{ | ||
"nodes":[ | ||
{ | ||
"id":"root", | ||
"hostname":"server.rudder.local", | ||
"status":"accepted" | ||
} | ||
] | ||
} | ||
} | ||
--- | ||
description: Get node (full) | ||
method: GET | ||
url: /api/nodes/node1?include=full | ||
response: | ||
code: 200 | ||
content: >- | ||
{ | ||
"action":"nodeDetails", | ||
"id":"node1", | ||
"result":"success", | ||
"data":{ | ||
"nodes":[ | ||
{ | ||
"id":"root", | ||
"hostname":"server.rudder.local", | ||
"status":"accepted", | ||
"os":{ | ||
"type":"Linux", | ||
"name":"Debian", | ||
"version":"7.0", | ||
"fullName":"Jessie", | ||
"kernelVersion":"3.2" | ||
}, | ||
"machine":{ | ||
"id":"machine1", | ||
"type":"Virtual", | ||
"provider":"vbox" | ||
}, | ||
"ipAddresses":["127.0.0.1","192.168.0.100"], | ||
"description":"", | ||
"lastInventoryDate":"2021-01-30 01:20", | ||
"policyServerId":"root", | ||
"managementTechnology":[{ | ||
"name":"Rudder", | ||
"version":"4.0.0", | ||
"capabilities":[], | ||
"nodeKind":"root", | ||
"rootComponents":[ | ||
"rudder-db", | ||
"rudder-inventory-endpoint", | ||
"rudder-inventory-ldap", | ||
"rudder-jetty", | ||
"rudder-ldap", | ||
"rudder-reports", | ||
"rudder-server-root", | ||
"rudder-webapp" | ||
] | ||
}], | ||
"properties":[], | ||
"policyMode":"enforce", | ||
"timezone":{"name":"UTC","offset":"+00"}, | ||
"environmentVariables":{"THE_VAR":"THE_VAR value!"}, | ||
"fileSystems":[{"name":"swap"}], | ||
"managementTechnologyDetails":{"cfengineKeys":[],"cfengineUser":"root"}, | ||
"networkInterfaces":[], | ||
"software":[ | ||
{"name":"s09","version":"1.0"}, | ||
{"name":"s06","version":"1.0"}, | ||
{"name":"s05","version":"1.0"}, | ||
{"name":"s13","version":"1.0"}, | ||
{"name":"s08","version":"1.0"}, | ||
{"name":"s02","version":"1.0"}, | ||
{"name":"s03","version":"1.0"}, | ||
{"name":"s04","version":"1.0"}, | ||
{"name":"s10","version":"1.0"}, | ||
{"name":"s11","version":"1.0"}, | ||
{"name":"s12","version":"1.0"}, | ||
{"name":"s01","version":"1.0"}, | ||
{"name":"s00","version":"1.0"}, | ||
{"name":"s07","version":"1.0"} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
--- | ||
description: List node with select and include managementTechnologie | ||
method: GET | ||
url: /api/nodes?include=minimal,managementTechnologyDetails&select=nodeAndPolicyServer&where=[{"objectType":"node","attribute":"nodeHostname","comparator":"eq","value":"node1.localhost"}] | ||
response: | ||
code: 200 | ||
content: >- | ||
{ | ||
"action":"listAcceptedNodes", | ||
"result":"success", | ||
"data":{ | ||
"nodes":[ | ||
{ | ||
"id":"node1", | ||
"hostname":"node1.localhost", | ||
"status":"accepted", | ||
"managementTechnologyDetails":{"cfengineKeys":[],"cfengineUser":"root"} | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why do you need the extra case?
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.
we use a syntax shortcut in methods accepting function as argument: you can create a partial function with the following syntax
{ case x => ... }
and so use it directly as argument, what we regularly do formap
and alike function - and in that case, we are careful to use a partial function which is actually total by not imposing restriction on thex
:But that really syntax for partial function, so you can put as many guard as you want in the pattern, use as many pattern as you want, and even don't make it total (and be sad when the pattern match exception happens):
So in our case, since I wanted to have a different logic for the two cases of
Option
:But then, I needed to apply a
fold
on result, and I don't know of a syntax that allow to do that with several pattern match in the partial function syntact, so I reverted to the usual pattern match syntax and only one branch for the partial function:And with the fold:
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.
Thank you for the time spent for the superb explanation of why adding the extra case, i learnt something