-
Notifications
You must be signed in to change notification settings - Fork 60
Refactor/ota 2633/aktualizr info output #1215
Conversation
fa28876
to
8f01598
Compare
There are a couple of clang-tidy warnings. Also, I'm a bit wary of the change that requires the |
Codecov Report
@@ Coverage Diff @@
## master #1215 +/- ##
==========================================
+ Coverage 79.18% 79.33% +0.15%
==========================================
Files 170 170
Lines 10044 10086 +42
==========================================
+ Hits 7953 8002 +49
+ Misses 2091 2084 -7
Continue to review full report at Codecov.
|
8f01598
to
6f3912b
Compare
Are you using another version of clang-tidy than 6.0 (or with other settings)? It looks like you're trying to fix warnings that are not flagged on CI. |
6f3912b
to
fe7d77b
Compare
Once, this PR is merged corresponding changes must be done in meta-updater as it relies on aktualizr-info in its tests (https://github.com/advancedtelematic/meta-updater/search?q=aktualizr-info&unscoped_q=aktualizr-info) |
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.
While developing "ptest" for posix secondaries I noticed that aktualizr-info can't fetch the requested info from DB quite often (most likely because aktualizr locks access to the DB during its work). I overcame this issue in the test by running aktualizr-info in a loop until it actually succeeds (or number of iteration exceed the maximum allowed).
The question is, if a customer application that utilizes aktualizr/libaktualizr uses aktualizr-info and relies on its output then there are two question appears:
-
What should the customer application do if aktualizr-info fails to fetch requested info ? Do polling/launch it multiple times ? Or maybe, aktualizr-info should guarantee somehow that the requested info is fetched ?
-
It's more convenient and reliable to use some structured format for passing info between apps, e.g. json. Perhaps, makes sense to add such functionality into aktualizr-info ? For example, if there is such use case as an app using aktualizr would like to get info about installed versions on each ECU then having output in json format would be something useful.
} | ||
return EXIT_SUCCESS; | ||
} | ||
|
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.
Regarding these multiple "if () { do_foo(); return EXIT_SUCCESS;}", does it mean that it's not possible to get output of a few types of info/metadata within a single call to aktualizr-info ?
Also, these blocks of "if ... return EXIT_SUCCESS" statements look like ideal candidates for defining a map <std::string, std::function> and having a single block of code that works for all options, e.g. "for op in options { if is_specified(op) { foo_mapop; return EXIT_SUCCESS;}. This is rather matter of style and is minor comment that can be ignored.
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.
The early exit is probably undesirable. Whether the suggested refactoring is worth it is debatable; I have no strong feelings on that.
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.
Regarding these multiple "if () { do_foo(); return EXIT_SUCCESS;}", does it mean that it's not possible to get output of a few types of info/metadata within a single call to aktualizr-info ?
Also, these blocks of "if ... return EXIT_SUCCESS" statements look like ideal candidates for defining a map <std::string, std::function> and having a single block of code that works for all options, e.g. "for op in options { if is_specified(op) { foo_mapop; return EXIT_SUCCESS;}. This is rather matter of style and is minor comment that can be ignored.
We do not need multiple outputs since we going to use the actualizr-info output in PIPE.
The block with "if .. return" looks ugly, but it does the same job you propose but generates less of CPU instructions.
Also, can we consider our main function as a single block of code? We can use exit() vs return but this particular case it's the same.
By the way, I using this tool https://godbolt.org/ to check the compiler output, time to time
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 do not need multiple outputs since we going to use the actualizr-info output in PIPE.
I disagree. There is no reason not to support multiple outputs if the user asks for it. We've supported that until now, and I see no reason to remove it.
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.
Since we enable output for multiple arguments, should we rename command --name-only?
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.
No, that is the one specific exception. I had forgotten about that; I made that as a special option for one of the backend devs. That one should indeed only print the name.
aktualizr-info is used primarily internally, so I'm not too worried about this. It would be better to do it right, but no one should be depending on this for production use cases.
Yes, we've considered that and I'm open to it. I believe some e2e tests rely on aktualizr-info output, though, so it's worth coordinating with them. (@rdanitz or @stevana can you confirm?) |
Yes, structured |
0f87cbf
to
ffc1fe5
Compare
@stevana This should be a big step in that direction. Uptane metadata is now printed so that it can be piped directly to
That actually already exists. |
@patrickvacek: Nice! /cc @rdanitz @balajirrao |
…ulation. Signed-off-by: kbushgit <kbushko@intellias.com>
…ipe, removing garbage + updated tests Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
…vailable + update tests Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
…overage report Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
5c26969
to
f773f4c
Compare
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.
Tested manually and works exactly as expected. Thanks!
Refactoring an output of aktualizr-info app.
If the user does not provide any arguments the help will be printed.
To print general information with human readable formatting, use --info.
--ecu-keys and --tls-keys was left, this commands print result more in h2m format, which requires additional parsing.
All other commands print pure information into stdout without garbage, which can be used directly in the pipe.