-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(podman): support add podman envs in the wizard [r8s-20] #12056
base: develop
Are you sure you want to change the base?
Conversation
0a82581
to
09fca56
Compare
I decided to go with a new container engine field instead of a new environment type. The container engine field as of now can be 'docker' or 'podman' I decided to go with this because of docker and podman both following the OCI interface. This means there are more cases where docker and podman environments are similar, than different. Another option that I considered was to create new Endpoint.Type enums for podman environments. I decided to go against this because it would require unnecessary environment type checking project wide, to follow the same logic as docker environments |
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.
After discussing this with Ali, we've considered the following approaches:
- A simple boolean to state whether the environment is based on the Podman runtime or not
- A new enum type for the container runtime
- A string based implementation that is supported by constants
We've decided to go with the 3rd option that gives enough flexibility for future enhancements without the rigidity and constraints of the first two options.
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.
Minor changes required otherwise LGTM
ea8aff7
to
c944813
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.
Backend LGTM
@@ -168,6 +172,8 @@ export enum EnvironmentCreationTypes { | |||
KubeConfigEnvironment, | |||
} | |||
|
|||
export type ContainerEngine = 'docker' | 'podman'; |
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.
Use an enum that can be used for comparison in the app, like PlatformType
export enum ContainerEngine {
Docker = 'docker',
Podman = 'podman',
}
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.
I have a slight preference for unions for being able to use values directly, still getting typescript lint errors as guard rails, and not requiring importing. If you still want enum, I can update it though
import azure from '@/assets/ico/vendor/azure.svg'; | ||
import docker from '@/assets/ico/vendor/docker.svg'; | ||
|
||
import { Icon } from '@@/Icon'; | ||
|
||
interface Props { | ||
type: EnvironmentType; | ||
containerEngine?: ContainerEngine; |
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.
Don't make it optional as it won't be (always defaults to docker
in the backend).
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.
It defaults to docker when creating a new environment, but there's no guarantee (yet) that existing environments have the container engine set.
I'll look into doing a migration that either sets all existing environments to 'docker' or a post init migration that checks the info from environments to determine 'podman' or 'docker' environments.
app/react/portainer/environments/wizard/EnvironmentTypeSelectView/EnvironmentTypeSelectView.tsx
Outdated
Show resolved
Hide resolved
app/react/portainer/environments/wizard/EnvironmentTypeSelectView/environment-types.ts
Outdated
Show resolved
Hide resolved
@@ -207,7 +224,8 @@ async function createEnvironment( | |||
}; | |||
|
|||
if (options) { | |||
const { groupId, tagIds = [] } = options.meta || {}; | |||
const { tls, azure, meta, containerEngine = 'docker' } = options; |
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.
If containerEngine
is mandatory in the backend, don't make it optional in the frontend with a default value but enforce it along the entire call chain (in EnvironmentOptions
and its callers)
If containerEngine
is optional in the backend, don't use a default value.
This comment applies to all the containerEngine
related parameters of this PR.
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.
Fair point!
I think that containerEngine should be optional, for the following reasons
- we shouldn't set the containerEngine for kubernetes environments (it's specific for only docker or podman envs)
- there are existing environments that won't be migrated to have a containerEngine field
I've removed the default 'docker' value
.../environments/EdgeAutoCreateScriptView/AutomaticEdgeEnvCreation/AutomaticEdgeEnvCreation.tsx
Outdated
Show resolved
Hide resolved
const isPodmanEnabledQuery = useFeatureFlag('podman'); | ||
// for the stepper, assume isPodmanEnabled is enabled, until shown otherwise | ||
const isPodmanEnabled = | ||
isPodmanEnabledQuery.data === undefined ? true : isPodmanEnabledQuery.data; | ||
const environmentTypes = getEnvironmentTypes(isPodmanEnabled); |
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.
In this case we should probably assume that the flag is disabled and not enabled by default. The purpose of a feature flag is to hide feature by default and only enable them on demand.
Also, use FeatureId.PODMAN
or a custom hook (see above)
const { data: isPodmanEnabled } = useFeatureFlag(FeatureId.PODMAN);
const environmentTypes = getEnvironmentTypes(!!isPodmanEnabled);
OR
const isPodmanEnabled = useIsPodmanEnabled();
const environmentTypes = getEnvironmentTypes(isPodmanEnabled);
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.
There's a weird exception where isPodmanEnabledQuery is still loading. I updated the comment and code to hopefully reflect this case better
2c7d8b9
to
85c3cc5
Compare
e8cfe74
to
c10e1ce
Compare
Fixes: r8s-20