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

podman generate systemd should only prepend separator when prefix is non-empty #13272

Closed
lovette opened this issue Feb 17, 2022 · 4 comments · Fixed by #13299
Closed

podman generate systemd should only prepend separator when prefix is non-empty #13272

lovette opened this issue Feb 17, 2022 · 4 comments · Fixed by #13299
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@lovette
Copy link

lovette commented Feb 17, 2022

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

When the --container-prefix and/or --pod-prefix options to podman generate systemd are set to empty string, the default --separator should not be prepended. It creates filenames that begin with a hyphen, which are frustrating to deal with.

$ podman generate systemd --new --name --files --pod-prefix='' --container-prefix='' mariadb-pod
-mariadb-pod.service
-mariadb.service

$ ls *.service
ls: invalid option -- '-'

$ ls -- *.service
-mariadb-pod.service  -mariadb.service

Of course, you can workaround this by also setting the --separator to an empty string.

$ podman generate systemd --new --name --files --pod-prefix='' --container-prefix='' --separator='' mariadb-pod
mariadb-pod.service
mariadb.service

Steps to reproduce the issue:

$ podman generate systemd --new --name --files --pod-prefix='' --container-prefix='' mariadb-pod

Describe the results you received:

% ls --
-mariadb-pod.service -mariadb.service

Describe the results you expected:

$ ls
mariadb-pod.service mariadb.service

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Client:       Podman Engine
Version:      4.0.0-rc5
API Version:  4.0.0-rc5
Go Version:   go1.17.5

Built:      Sat Feb 12 01:12:41 2022
OS/Arch:    linux/amd64

Output of podman info --debug:

host:
	arch: amd64
	buildahVersion: 1.24.1
	cgroupControllers:
	- cpuset
	- cpu
	- io
	- memory
	- hugetlb
	- pids
	- rdma
	- misc
	cgroupManager: systemd
	cgroupVersion: v2
	conmon:
		package: conmon-2.1.0-1.el9.x86_64
		path: /usr/bin/conmon
		version: 'conmon version 2.1.0, commit: 8ef5de138efb6f0aad657082cdea22cf037792cb'
	cpus: 2
	distribution:
		distribution: '"centos"'
		version: "9"
	eventLogger: journald
	hostname: dd-grogu-dev
	idMappings:
		gidmap: null
		uidmap: null
 kernel: 5.14.0-47.el9.x86_64
	linkmode: dynamic
	logDriver: journald
	memFree: 2074648576
	memTotal: 4073611264
	networkBackend: netavark
	ociRuntime:
		name: crun
		package: crun-1.4.2-1.el9.x86_64
		path: /usr/bin/crun
		version: |-
			crun version 1.4.2
			commit: f6fbc8f840df1a414f31a60953ae514fa497c748
			spec: 1.0.0
			+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
	os: linux
	remoteSocket:
		exists: true
		path: /run/podman/podman.sock
	security:
		apparmorEnabled: false
		capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
		rootless: false
		seccompEnabled: true
		seccompProfilePath: /usr/share/containers/seccomp.json
		selinuxEnabled: true
	serviceIsRemote: false
	slirp4netns:
		executable: /bin/slirp4netns
		package: slirp4netns-1.1.8-3.el9.x86_64
		version: |-
			slirp4netns version 1.1.8
			commit: d361001f495417b880f20329121e3aa431a8f90f
			libslirp: 4.4.0
			SLIRP_CONFIG_VERSION_MAX: 3
			libseccomp: 2.5.2
	swapFree: 2146430976
	swapTotal: 2147479552
	uptime: 50h 19m 42.78s (Approximately 2.08 days)
plugins:
 log:
	- k8s-file
	- none
	- passthrough
	- journald
	network:
	- bridge
	- macvlan
	volume:
	- local
registries:
	search:
	- registry.fedoraproject.org
	- registry.access.redhat.com
	- docker.io
	- quay.io
store:
	configFile: /etc/containers/storage.conf
	containerStore:
		number: 15
		paused: 0
		running: 15
		stopped: 0
	graphDriverName: overlay
	graphOptions:
		overlay.mountopt: nodev,metacopy=on
	graphRoot: /var/lib/containers/storage
	graphStatus:
		Backing Filesystem: xfs
		Native Overlay Diff: "false"
		Supports d_type: "true"
		Using metacopy: "true"
	imageCopyTmpDir: /var/tmp
	imageStore:
		number: 24
	runRoot: /run/containers/storage
	volumePath: /var/lib/containers/storage/volumes
version:
	APIVersion: 4.0.0-rc5
	Built: 1644628361
	BuiltTime: Sat Feb 12 01:12:41 2022
	GitCommit: ""
	GoVersion: go1.17.5
	OsArch: linux/amd64
	Version: 4.0.0-rc5

Package info (e.g. output of rpm -q podman or apt list podman):

podman-4.0.0-0.7.rc5.el9.x86_64

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):

Running on CentOS 9 Stream in a VMware Fusion VM.

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Feb 17, 2022
@Luap99
Copy link
Member

Luap99 commented Feb 17, 2022

I think using --separator="" is the best solution, removing the default separator might cause other problems. What if I only use --pod-prefix=''?

@Luap99 Luap99 added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Feb 17, 2022
@lovette
Copy link
Author

lovette commented Feb 17, 2022

The options all make sense as they stand. I just think the given separator should only be prepended if the relevant prefix is non-empty. Filenames starting with a hyphen is an annoying footgun 😁

An alternate wish would be to have --no-pod-prefix and --no-container-prefix options. And personally, I'm a suffix person, so corresponding --suffix options would be useful too.

@lovette lovette changed the title podman generate systemd should not prepend separator if prefixes are empty string podman generate systemd should only prepend separator when prefix is non-empty Feb 17, 2022
@Luap99
Copy link
Member

Luap99 commented Feb 17, 2022

Given the option is called separator and there is nothing to separate in this case it would make sense to this.
Interested in opening a PR?

@Luap99 Luap99 added the Good First Issue This issue would be a good issue for a first time contributor to undertake. label Feb 17, 2022
@lovette
Copy link
Author

lovette commented Feb 17, 2022

Happily if I could, but I don't know Go 😁

nirmal-j-patel added a commit to nirmal-j-patel/podman that referenced this issue Mar 17, 2022
…ate systemd

When podman generate systemd is invoked, it previously did not check if
container-prefix or pod-prefix are empty. When these are empty, the file name
starts with the separator, which is hyphen by default. This results in files
like '-containername.service'.

The code now checks if these prefixes are empty. If they are, the filename no
longer adds a separator. Instead, it uses name or ID of the container or pod.

Closes containers#13272

Signed-off-by: Nirmal Patel <npate012@gmail.com>
mheon pushed a commit to mheon/libpod that referenced this issue Mar 30, 2022
…ate systemd

When podman generate systemd is invoked, it previously did not check if
container-prefix or pod-prefix are empty. When these are empty, the file name
starts with the separator, which is hyphen by default. This results in files
like '-containername.service'.

The code now checks if these prefixes are empty. If they are, the filename no
longer adds a separator. Instead, it uses name or ID of the container or pod.

Closes containers#13272

Signed-off-by: Nirmal Patel <npate012@gmail.com>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
2 participants