Skip to content
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

Parse more defensively #302

Closed

Conversation

Rory-Reid
Copy link

I'm opening this with the full belief that these changes are far too destructive and opinionated to actually be worth merging in. This PR exists to document and demonstrate the pain points I had trying to make FluentDocker work with Podman (v 4.6.2 at the time of writing), and maybe help break the ice for #300.

It feels like Podman is too dissimilar from docker for this library to faithfully support it, or without breaking and losing the ability to directly invoke docker network ls and docker top via this library (possibly other commands too).

I think if there was an interest in actively supporting podman in its current form with this library, the changes I've made to parsing network ls and top should instead try to parse as much detail as possible, safely. I wouldn't mind trying to tackle that myself, but I figure there's no point me spending time on it if there is no desire to support the quirks and differences of podman in FluentDocker today.

Thanks for reading and thank you for this great tool.

This includes a failing test for a result observed with podman
The only place this is used (.WaitForHealthy()) already performs a null-
safe check against the Status, comparing it to "Healthy" only. Changing
the property to nullable allows more defensive parsing if it is an empty
string for whatever reason, and is still interpreted as "Unhealthy"
where it matters.
This adds and uses a custom converter which will parse
Container.Config.Entrypoint from a json string array I.E.

```json
{
  "EntryPoint": [
    "my-entrypoint"
  ]
}
```

Or from a single string value, I.E:

```json
{
  "EntryPoint": "my-entrypoint"
}
```
This removes unused fields from the output of the `docker network ls`
command, to avoid parsing errors when one or more formatted properties
are unavailable on a host machine.

**Warning:** This could potentially break client code, if any client
actively relies on the public method:

- IContainerHost.DockerHost.NetworkLs();
This removes the need to parse all output from docker top, preventing
parsing errors where format of columns may differ from host to host.

**Warning:** This could potentially break client code, if any client
actively relies on the public method:

- IContainerService.DockerHost.Top(...).Processes.Rows
@Rory-Reid
Copy link
Author

Changed my mind actually, it's not that much more effort to submit something cleaner and non-destructive.

@Rory-Reid Rory-Reid closed this Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant