Skip to content

Commit

Permalink
socket: Remove socket activation feature
Browse files Browse the repository at this point in the history
Socket activation is no longer required since a proxy instance
is launched by the runtime for each pod.

Fixes clearcontainers#176.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Dec 14, 2017
1 parent c2cbc85 commit e3ab55e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 119 deletions.
27 changes: 3 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ VERSION_COMMIT := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION))



#
# systemd files
#

HAVE_SYSTEMD := $(shell pkg-config --exists systemd 2>/dev/null && echo 'yes')

ifeq ($(HAVE_SYSTEMD),yes)
UNIT_DIR := $(shell pkg-config --variable=systemdsystemunitdir systemd)
UNIT_FILES = cc-proxy.service cc-proxy.socket
GENERATED_FILES += $(UNIT_FILES)
endif

#
# Pretty printing
#
Expand All @@ -35,7 +23,7 @@ QUIET_GOBUILD = $(Q:@=@echo ' GOBUILD '$@;)
QUIET_GEN = $(Q:@=@echo ' GEN '$@;)

# Entry point
all: cc-proxy $(UNIT_FILES)
all: cc-proxy

#
# proxy
Expand Down Expand Up @@ -81,22 +69,13 @@ define INSTALL_FILE

endef

all-installable: cc-proxy $(UNIT_FILES)
all-installable: cc-proxy

install: all-installable
$(call INSTALL_EXEC,cc-proxy,$(LIBEXECDIR)/clear-containers)
$(foreach f,$(UNIT_FILES),$(call INSTALL_FILE,$f,$(UNIT_DIR)))

clean:
rm -f cc-proxy $(GENERATED_FILES)

$(GENERATED_FILES): %: %.in Makefile
@mkdir -p `dirname $@`
$(QUIET_GEN)sed \
-e 's|[@]bindir[@]|$(BINDIR)|g' \
-e 's|[@]libexecdir[@]|$(LIBEXECDIR)|' \
-e "s|[@]localstatedir[@]|$(LOCALSTATEDIR)|" \
"$<" > "$@"
rm -f cc-proxy

#
# dist
Expand Down
11 changes: 0 additions & 11 deletions cc-proxy.service.in

This file was deleted.

12 changes: 0 additions & 12 deletions cc-proxy.socket.in

This file was deleted.

42 changes: 15 additions & 27 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,35 +637,23 @@ func (proxy *proxy) init(uri string) error {
if proxy.socketPath, err = getSocketPath(uri); err != nil {
return fmt.Errorf("couldn't get a valid socket path: %v", err)
}
fds := listenFds()

if len(fds) > 1 {
return fmt.Errorf("too many activated sockets (%d)", len(fds))
} else if len(fds) == 1 {
fd := fds[0]
l, err = net.FileListener(fd)
if err != nil {
return fmt.Errorf("couldn't listen on socket: %v", err)
}

} else {
socketDir := filepath.Dir(proxy.socketPath)
if err = os.MkdirAll(socketDir, 0750); err != nil {
return fmt.Errorf("couldn't create socket directory: %v", err)
}
if err = os.Remove(proxy.socketPath); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("couldn't remove exiting socket: %v", err)
}
l, err = net.ListenUnix("unix", &net.UnixAddr{Name: proxy.socketPath, Net: "unix"})
if err != nil {
return fmt.Errorf("couldn't create AF_UNIX socket: %v", err)
}
if err = os.Chmod(proxy.socketPath, 0660|os.ModeSocket); err != nil {
return fmt.Errorf("couldn't set mode on socket: %v", err)
}

proxyLog.Info("listening on ", proxy.socketPath)
socketDir := filepath.Dir(proxy.socketPath)
if err = os.MkdirAll(socketDir, 0750); err != nil {
return fmt.Errorf("couldn't create socket directory: %v", err)
}
if err = os.Remove(proxy.socketPath); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("couldn't remove exiting socket: %v", err)
}
l, err = net.ListenUnix("unix", &net.UnixAddr{Name: proxy.socketPath, Net: "unix"})
if err != nil {
return fmt.Errorf("couldn't create AF_UNIX socket: %v", err)
}
if err = os.Chmod(proxy.socketPath, 0660|os.ModeSocket); err != nil {
return fmt.Errorf("couldn't set mode on socket: %v", err)
}

proxyLog.Info("listening on ", proxy.socketPath)

proxy.listener = l

Expand Down
45 changes: 0 additions & 45 deletions socket_activation.go

This file was deleted.

0 comments on commit e3ab55e

Please sign in to comment.