Hi,
I am facing issue while iSCSI login to iSCSI target from within a docker plugin.
I have a GO code which performs iSCSI operations from within the plugin, but when I try to perform iSCSI login from within my plugin code, it cannot log in to the portals, it throws an error saying, iSCSI driver not found, but then if I perform iSCSI login from the docker daemon host manually the login succeeds, and if I run the code again then it returns saying iscsiadm: default: 1 session requested, but 1 already present
So, basically I cannot log in to iSCSI target from the docker plugin, but all the iSCSI operations work successfully from the docker daemon host.
Please help me, I want to run the iSCSI login from the plugin code
Code running iSCSI login:
out, err := exec.Command("iscsiadm", "-m", "node", "-l", "-T", targetIQN).CombinedOutput()
if err != nil {
log.Fatalf("Error encountered in iscsi login to target '%s': Error code '%s', Error : '%s'", targetIQN, err, string(out))
return "", errors.New("error doing iscsi Login cmd")
}
log.Debug("Output of login command\n: ", string(out))
Issue:
The iSCSI login fails with the following error:
iscsiadm: initiator reported error (12 - iSCSI driver not found. Please make sure it is loaded, and retry the operation)
iscsiadm: Could not log into all portals
Environment:
1. Docker Daemon Host: Ubuntu 18.04
Linux stack-virtual-machine 4.15.0-45-generic #48~16.04.1-Ubuntu SMP Tue Jan 29 18:03:48 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
2. iSCSI package: open-iscsi
3. Docker Plugin: Ubuntu 18.04
Dockerfile
FROM ubuntu:18.04
ENV GO_VERSION=1.11.4 \
GOROOT=/goroot \
GOPATH=/gopath
ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin
# Check if we need to copy initiator file from host to plugin container
RUN mkdir -p /var/lib/docker-volumes/plugin
RUN apt-get update -y && \
# Install needed packages
apt-get install --no-install-recommends -y -q curl build-essential git vim apt-transport-https software-properties-common ca-certificates open-iscsi && \
# Install GOLang
mkdir ${GOROOT} && curl https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz | tar xvzf - -C ${GOROOT} --strip-components=1 && \
mkdir ${GOPATH} && \
# remove apt cache from image
apt-get clean all
# it will work only after making the repo public
COPY . ${GOPATH}/src/github.com/temp/plugins/plugin
COPY initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
WORKDIR ${GOPATH}/src/github.com/temp/plugins/plugin
RUN go get github.com/docker/go-plugins-helpers/volume
RUN go get github.com/Sirupsen/logrus
RUN set -ex \
&& apt-get install gcc libc-dev \
&& go install --ldflags '-extldflags "-static"'
RUN mkdir /etc/plugin
CMD ["/gopath/bin/plugin"]
OS Version/build:
root@virtual-machine:/home/stack# docker version
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:10:01 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
This is my config.json for the plugin:
{ "description": "Docker volume plugin", "documentation": "https://docs.docker.com/engine/extend/plugins/", "entrypoint": ["/gopath/bin/docker-plugin"], "network": { "type": "host" }, "Env": [ { "Description": "Config file from /etc/plugin on host", "Name": "config", "Settable": [ "value" ], "Value": "/etc/plugin/plugin-config.json" }, { "Description": "Default location of Log file on host", "Name": "log-location", "Settable": [ "value" ], "Value": "/var/log/plugin/plugin.json" } ], "interface" : { "types": ["docker.volumedriver/1.0"], "socket": "plugin.sock" }, "mounts": [ { "type": "bind", "source": "/etc/plugin", "destination": "/etc/plugin", "options": ["rbind"] }, { "type": "bind", "source": "/var/log/plugin", "destination": "/var/log/plugin", "options": ["rbind"] }, { "type": "bind", "source": "/dev", "destination": "/dev", "options": ["rbind"] } ], "PropagatedMount": "/var/lib/docker-volumes/plugin", "linux": { "capabilities": ["CAP_SYS_ADMIN"], "allowAllDevices": true } }