Closed windsource closed 4 months ago
We can try a no-wrap functionality which cuts the line according to the size of the terminal. To enrich the "Pending(StartingFailed) No more retries." with more information we can use transition function for states or we can use the information available. Maybe we also need an additional sub-state for the no-more-retries.
We can try a no-wrap functionality which cuts the line according to the size of the terminal. To enrich the "Pending(StartingFailed) No more retries." with more information we can use transition function for states or we can use the information available. Maybe we also need an additional sub-state for the no-more-retries.
Unfortunately, the tabled
crate does not support a direct no-wrap option. It supports only to truncate and output a customized suffix. However I search for alternatives.
@krucod3: I have broken down the issues into different topics after analysis and introduced a solution proposal below:
The flickering is produced, because the execution states are switched very fast between Pending(Starting)
and Pending(StartingFailed)
because of the retries. The Pending(Starting)
is set each time a create workload is executed and afterwards if it still fails the Pending(StartingFailed)
is output. Because the execution states has different length and the "additional info" column is also moved and the terminal window is too small the output flickers.
The additional info message is wrapped into multiple lines, because the terminal window is not big enough (the width). Unfortunately, there is no "no-wrap" setting for the table output in the tabled crate available. But this does anyway not alone produce the flickering it is just layout of the text. In addition, there are some additional newlines inside the additional info that was directly fetched from the runtime itself (e.g. \nSee 'podman run --help'\n
). Here we can improve and replace newlines through ", " to have at least a single line error message. It is not a fix for the missing no-wrap but it improves the output as the table layout is not messed up because of unnecessary newlines, which are unhandy in tabled layouts.
The final error message must be enhanced with the cause again, which is available in the context it is created.
Current implemented solution:
I have reduced the flickering by introducing a new PendingSubstate (Pending(RetryStarting)
) for the workload during its retries are executed. The execution state Pending(StartingFailed)
is output when the retry limit was exceeded. The stable additional sub state in the table output signals the user that retries are executed and prevents that the columns are moved and that the output flickers.
Execution states when retries are executed until the limit is exceeded: Pending(Starting) -> Pending(RetryStarting) -> Pending(StartingFailed)
In addition, I kept the Pending(StartingFailed) execution state as last execution state after exceeded retries and appended just the error cause again, because I thought that this state is already communicating the final failed state to the user. But we can of course introduce a separate state. But with the separate state I do not know when to output Pending(StartingFailed), it is not needed anymore or?
Furthermore, I format the additional info message right before the output and I trim the string at the beginning and end and replace newlines with ", " in-between to have a single line error.
Example output of the new substate during retries: I show also now the current number of retries and the max retries to the user and the stripped additional info message.
Final Pending(StartingFailed) state:
If you think it looks better without an additional state then we can also use the Pending(Starting)
state and output the retries like on the extra substate within the additional info columns.
Somehow we need to handle long lines, i.e. lines that are longer than the terminal width. I see two options:
If we break a line and continue in another column then it looks ugly.
Somehow we need to handle long lines, i.e. lines that are longer than the terminal width. I see two options:
- Truncate the line
- Break the line but keep the text in the current column
If we break a line and continue in another column then it looks ugly.
I have tested a truncating and a wrap of the additional info column and both functions require a maximum width as a number as an argument. You can use percentage values, but it didn't work with the column-specific setting (compiler error). In order to get the available remaining width of the terminal for the last column, a manual calculation is necessary. The terminal size can be easily obtained using an existing crate in our code base, but determining the size of the columns using the Tabled create Table object is rather cumbersome (string table output parsing) or the column size can only be determined inaccurately. All the manual workarounds in the code appear to be impractical and error-prone. I have created an issue describing our problem: https://github.com/zhiburt/tabled/issues/407. I hope the authors suggest a solution or a workaround.
There are two PRs open, #275 with unchanged table display and #303 including all from #275 but having the following wrap/truncate logic implemented on top to improve the table output quality:
When the user runs ank apply ...
, the additional info column is truncated and suffixed by '...' according to the available terminal width.
When the user runs 'ank get workloads', the additional info column shows the full detailed message, but the column is wrapped according the available terminal width.
For both commands, if the terminal window is too small so that the header column names cannot be shown in a single line I output the default table and no wrap/truncate is done. This prevents ugly output like this:
How it looks:
If desired, in addition I can use the "--verbose" flag for disabling/enabling the output of the executed command to reduce the info message length and thus the column content. This is only possible with greater effort since we need to change the ExecutionState
object to include the command in a separate field. Otherwise a string operation must be done afterwards to remove the command with a regex, which I do not prefer.
PR was reviewed and merged.
Assume an Ankaios manifest with an error inside like:
When this is applied using
ank apply
the output flickers and is hard to read for the user. In regular intervals a newline is added between the header and the table content. SeeIn addition the final output does not contain the cause anymore:
which makes it even harder for the user to determine the problem (here the invalid option).
Current Behavior
When
ank apply
is called and the manifest contains an error a retry is executed and the output between the retries changes its position.Expected Behavior
The output should not change its position such that it is easier for the user the read it and determine the error source. In addition the final message and also
ank get workloads
should show the real error message and notNo more retries
.Steps to Reproduce
sudo systemctl start ank-server ank-agent
Context (Environment)
Logs
Additional Information
Final result
The propability of flickering output was decreased by keeping the state
Pending(Starting)
with an additional info message signaling that retries are done (Retry X of 20: <failure_cause>) are being executed. This prevents the previous behavior that the columns content are moved back and forward when switching quickly between
Pending(Starting)and
Pending(StartingFailed)during retries causing the table output to flicker. In addition, the table output layout was improved to handle long additional info messages with newlines in a table better. In the
ank applycommand the additional info column is truncated to the remaining terminal width and in the
ank get workloads` command the full additional info message is shown, but wrapped to the remaining terminal width. If the terminal is too small so that not even the header fits in one line, the default table is output with no truncating/wrapping at all to prevent strange output.