mirror of https://github.com/containers/podman.git
add kubernetes pause
Add the k8s pause binary to `pause/pause.c` and do the plumbing in the Makefile to install it in $libexec/podman/pause/pause. It is intended to replace the k8s pause image and hence the need for network connectivity when creating pods. [NO NEW TESTS NEEDED] since it will be tested in a following commit. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
parent
e86549b18d
commit
9d2b8d2791
23
Makefile
23
Makefile
|
@ -185,6 +185,10 @@ ifdef HOMEBREW_PREFIX
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# For building pause/pause.c
|
||||||
|
GCC ?= gcc
|
||||||
|
PAUSE_CFLAGS = -Os -static -Wall -Werror -DVERSION=v$(RELEASE_VERSION)
|
||||||
|
|
||||||
###
|
###
|
||||||
### Primary entry-point targets
|
### Primary entry-point targets
|
||||||
###
|
###
|
||||||
|
@ -196,7 +200,7 @@ default: all
|
||||||
all: binaries docs
|
all: binaries docs
|
||||||
|
|
||||||
.PHONY: binaries
|
.PHONY: binaries
|
||||||
binaries: podman podman-remote rootlessport ## Build podman, podman-remote and rootlessport binaries
|
binaries: podman podman-remote rootlessport pause
|
||||||
|
|
||||||
# Extract text following double-# for targets, as their description for
|
# Extract text following double-# for targets, as their description for
|
||||||
# the `help` target. Otherwise These simple-substitutions are resolved
|
# the `help` target. Otherwise These simple-substitutions are resolved
|
||||||
|
@ -374,6 +378,12 @@ bin/rootlessport: .gopathok $(SOURCES) go.mod go.sum
|
||||||
.PHONY: rootlessport
|
.PHONY: rootlessport
|
||||||
rootlessport: bin/rootlessport
|
rootlessport: bin/rootlessport
|
||||||
|
|
||||||
|
bin/pause: pause/pause.c
|
||||||
|
$(GCC) $(PAUSE_CFLAGS) pause/pause.c -o bin/pause
|
||||||
|
|
||||||
|
.PHONY: pause
|
||||||
|
pause: bin/pause
|
||||||
|
|
||||||
###
|
###
|
||||||
### Secondary binary-build targets
|
### Secondary binary-build targets
|
||||||
###
|
###
|
||||||
|
@ -733,7 +743,7 @@ install.remote-nobuild:
|
||||||
install.remote: podman-remote install.remote-nobuild
|
install.remote: podman-remote install.remote-nobuild
|
||||||
|
|
||||||
.PHONY: install.bin-nobuild
|
.PHONY: install.bin-nobuild
|
||||||
install.bin-nobuild:
|
install.bin-nobuild: install.pause
|
||||||
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR)
|
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR)
|
||||||
install ${SELINUXOPT} -m 755 bin/podman $(DESTDIR)$(BINDIR)/podman
|
install ${SELINUXOPT} -m 755 bin/podman $(DESTDIR)$(BINDIR)/podman
|
||||||
test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman bin/podman
|
test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman bin/podman
|
||||||
|
@ -787,8 +797,10 @@ install.docker-docs-nobuild:
|
||||||
.PHONY: install.docker-docs
|
.PHONY: install.docker-docs
|
||||||
install.docker-docs: docker-docs install.docker-docs-nobuild
|
install.docker-docs: docker-docs install.docker-docs-nobuild
|
||||||
|
|
||||||
.PHONY: install.docker-full
|
.PHONY: install.pause
|
||||||
install.docker-full: install.docker install.docker-docs
|
install.pause: pause
|
||||||
|
install ${SELINUXOPT} -m 755 -d $(DESTDIR)$(LIBEXECPODMAN)/pause
|
||||||
|
install ${SELINUXOPT} -m 755 bin/pause $(DESTDIR)$(LIBEXECPODMAN)/pause/pause
|
||||||
|
|
||||||
.PHONY: install.systemd
|
.PHONY: install.systemd
|
||||||
ifneq (,$(findstring systemd,$(BUILDTAGS)))
|
ifneq (,$(findstring systemd,$(BUILDTAGS)))
|
||||||
|
@ -819,6 +831,9 @@ else
|
||||||
install.systemd:
|
install.systemd:
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
.PHONY: install.pause
|
||||||
|
install.pause: pause
|
||||||
|
|
||||||
.PHONY: install.tools
|
.PHONY: install.tools
|
||||||
install.tools: .install.goimports .install.gitvalidation .install.md2man .install.ginkgo .install.golangci-lint .install.bats ## Install needed tools
|
install.tools: .install.goimports .install.gitvalidation .install.md2man .install.ginkgo .install.golangci-lint .install.bats ## Install needed tools
|
||||||
|
|
||||||
|
|
|
@ -528,6 +528,7 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
|
||||||
%{_usr}/lib/tmpfiles.d/podman.conf
|
%{_usr}/lib/tmpfiles.d/podman.conf
|
||||||
%dir %{_libexecdir}/%{name}
|
%dir %{_libexecdir}/%{name}
|
||||||
%{_libexecdir}/%{name}/rootlessport
|
%{_libexecdir}/%{name}/rootlessport
|
||||||
|
%{_libexecdir}/%{name}/pause/pause
|
||||||
|
|
||||||
%if 0%{?with_devel}
|
%if 0%{?with_devel}
|
||||||
%files -n libpod-devel -f devel.file-list
|
%files -n libpod-devel -f devel.file-list
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors.
|
||||||
|
Copyright 2021 The Podman Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define STRINGIFY(x) #x
|
||||||
|
#define VERSION_STRING(x) STRINGIFY(x)
|
||||||
|
|
||||||
|
#ifndef VERSION
|
||||||
|
#define VERSION HEAD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void sigdown(int signo) {
|
||||||
|
psignal(signo, "Shutting down, got signal");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sigreap(int signo) {
|
||||||
|
while (waitpid(-1, NULL, WNOHANG) > 0)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int i;
|
||||||
|
for (i = 1; i < argc; ++i) {
|
||||||
|
if (!strcasecmp(argv[i], "-v")) {
|
||||||
|
printf("pause.c %s\n", VERSION_STRING(VERSION));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getpid() != 1)
|
||||||
|
/* Not an error because pause sees use outside of infra containers. */
|
||||||
|
fprintf(stderr, "Warning: pause should be the first process\n");
|
||||||
|
|
||||||
|
if (sigaction(SIGINT, &(struct sigaction){.sa_handler = sigdown}, NULL) < 0)
|
||||||
|
return 1;
|
||||||
|
if (sigaction(SIGTERM, &(struct sigaction){.sa_handler = sigdown}, NULL) < 0)
|
||||||
|
return 2;
|
||||||
|
if (sigaction(SIGCHLD, &(struct sigaction){.sa_handler = sigreap,
|
||||||
|
.sa_flags = SA_NOCLDSTOP},
|
||||||
|
NULL) < 0)
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
pause();
|
||||||
|
fprintf(stderr, "Error: infinite loop terminated\n");
|
||||||
|
return 42;
|
||||||
|
}
|
Loading…
Reference in New Issue