How to solve ONOS controller build problem? - bazel

I'm trying to build ONOS controller from source code, but at some point of the bazel build process, i get a lot of errors as you can see bellow:
Starting local Bazel server and connecting to it...
... still trying to connect to local Bazel server after 10 seconds ...
INFO: Analyzed target //:onos (1728 packages loaded, 58166 targets configured).
INFO: Found 1 target...
INFO: Deleting stale sandbox base /home/kevin/.cache/bazel/_bazel_root/b80cf3299f3992e280eed8f85033340e/sandbox
ERROR: /home/kevin/onos/BUILD:52:1: Executing genrule //:onos-karaf failed (Exit 2) bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
tar: apache-karaf-4.2.9/etc/org.ops4j.pax.logging.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/java.util.logging.properties: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/org.apache.karaf.command.acl.feature.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/org.apache.karaf.shell.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/org.apache.karaf.kar.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/jmx.acl.osgi.compendium.cm.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/distribution.info: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/org.apache.karaf.command.acl.config.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/system.properties: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/jre.properties: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/all.policy: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/org.apache.karaf.command.acl.shell.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/users.properties: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/startup.properties: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/jmx.acl.org.apache.karaf.config.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/org.apache.karaf.command.acl.jaas.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/org.apache.felix.eventadmin.impl.EventAdmin.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/scripts/shell.completion.script: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/scripts: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/jmx.acl.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/custom.properties: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/profile.cfg: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.9/etc/org.apache.karaf.features.xml: Cannot change ownership to uid 1001, gid 1001: Invalid argument
That is just a small part, there's hundreds of lines of errors. Still, this specific part "Cannot change ownership to uid 1001, gid 1001: Invalid argument" is displayed in every line.
What can i do to solve this problem?
edit:
I tried the solution described here: https://unix.stackexchange.com/questions/548108/cannot-change-ownership-to-uid-1001-gid-1001-invalid-argument
but no changes.

try to add --no-same-owner to the script where it is running tar
vim /opt/onos/tools/package/onos-prep-karaf
change line 22 to:
tar xf $KARAF_TAR --no-same-owner
and then run sudo bazel build onos again.

Related

docker mount - Error response from daemon: invalid mount config for type "bind"

I am facing an issue with mounting a host directory into docker container with both -v and --mount options.
Using mount:
docker run --mount type=bind,source=/home/myuser/docker_test/out_dir,target=/home/out_dir --user 12345:1000 -it docker-name:0.1 bash
docker: Error response from daemon: invalid mount config for type "bind": stat /home/myuser/docker_test/out_dir: permission denied.
But I am able to do stat on this directory.
stat /home/myuser/docker_test/out_dir
File: '/home/myuser/docker_test/out_dir'
Size: 4096 Blocks: 8 IO Block: 32768 directory
Device: 33h/51d Inode: 9275022755226025350 Links: 2
Access: (0770/drwxrwx---) Uid: (12345/ myuser) Gid: ( 1000/ hercules)
Access: 2022-12-01 02:12:54.430582000 -0500
Modify: 2022-12-01 02:12:38.239629000 -0500
Change: 2022-12-01 02:12:38.239629000 -0500
Birth: -
Using -v:
docker run -v /home/myuser/docker_test/out_dir:/home/out_dir --user 12345:1000 -it docker-name:0.1:0.1 bash
docker: Error response from daemon: error while creating mount source path '/home/myuser/docker_test/out_dir': mkdir /home/myuser/docker_test: permission denied.
ERRO[0000] error waiting for container: context canceled
I don't know why it's trying to do mkdir but /home/myuser/docker_test already exists and is writable for the current user.
Am I missing something here?
BTW - /home is a NFS mounted directory.
EDIT: mounting /tmp worked. So this means it is related to the NFS mounted directory /home.
EDIT 2
I am working on a network machine where I don’t have root (sudo) access.
The docker service is installed by root user.
/home/myuser/docker_test/out_dir has 700 (rwx------) permissions. If I change the permission to 755, it will work. But I can’t change the directory permissions.
My question is why stat is failing when the user starting the docker has the permissions to access the source directory?
Is the stat being called by the docker executable as some ‘other’ user?
Use:
sudo docker run -v /home/myuser/docker_test/out_dir:/home/out_dir --user 12345:1000 -it docker-name:0.1:0.1 bash

Failed to copy local file to the k8s container of the keycloak by using kubectl cp

This is what my commend looks like
kubectl cp /Users/Documents/keycloak-deployment/import/realm-export-sdp.json sdp-steve/keycloak-7458697ddb-tbzp8:/tmp
And I got the error message as below:
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:235: starting container process caused "exec: \"tar\": executable file not found in $PATH"
error: Internal error occurred: error executing command in container: read unix #->/var/run/docker.sock: read: connection reset by peer
Does anyone know how to handle this error? Thank you in advance.
Your container image must have tar binary present for running kubectl cp subcommand. As a result, you are getting the following error:
"exec: \"tar\": executable file not found in $PATH
See the below snippet:
kubectl cp --help
Copy files and directories to and from containers.
Examples:
# !!!Important Note!!!
# Requires that the 'tar' binary is present in your container
# image. If 'tar' is not present, 'kubectl cp' will fail.
#
# For advanced use cases, such as symlinks, wildcard expansion or
# file mode preservation, consider using 'kubectl exec'.
You may check this page showing why tar is needed.

how subuid works in context of docker?

Below is the content of /etc/subuid on my system.
On host
#cat /etc/subuid
incgnito:100000:65536
$ id -u
1000
1000 is UID of user incgnito
Now as per above content, UID 0 on container should be mapped to UID 100000 on system, but after logging to container , I found UID 0 inside container is mapped to UID 1000 on my system.
On Container
# cat /proc/1/uid_map
0 1000 1
1 100000 65536
Can anyone help me to understand this concept?

Docker - where to view full logs for service scale

Fairly simple question but I can't seem to Google it. Basically I'm running the following command, and the output is being cropped:
$ docker service scale omni_platform_omni_gallery_db=1
omni_platform_omni_gallery_db scaled to 1
overall progress: 0 out of 1 tasks
1/1: invalid mount config for type "bind": bind source path does not exist: /ho…
I need to view the full output, and I can't seem to find a /var/log/docker.log or anything of that kind.
Any help is appreciated thanks :)
EDIT:
I tried the following too, to no avail:
$ docker service ps omni_platform_omni_gallery_db --format {{.Error}}
"invalid mount config for type…"
"invalid mount config for type…"
"invalid mount config for type…"
"invalid mount config for type…"
"invalid mount config for type…"
Okay so I've been on the right track with that ps command. It also has a --no-trunc option, so the correct syntax would be the following:
$ docker service ps omni_platform_omni_gallery_db --format {{.Error}} --no-trunc
"invalid mount config for type "bind": bind source path does not exist: /home/data"
"invalid mount config for type "bind": bind source path does not exist: /home/data"
"invalid mount config for type "bind": bind source path does not exist: /home/data"
"invalid mount config for type "bind": bind source path does not exist: /home/data"
"invalid mount config for type "bind": bind source path does not exist: /home/data"

Building docker image, inside an alpine linux container

We are using docker containers running alpine linux as build agents in bamboo. As part of the build plan a docker image needs to be created.
Our build agent has docker installed, however we are getting errors as the docker daemon isn't running. Starting the daemon with
/usr/local/bin/dockerd
gives the following:
INFO[0000] libcontainerd: new containerd process, pid: 640
ERRO[0001] 'overlay' is not supported over overlayfs
INFO[0001] Graph migration to content-addressability took 0.00 seconds
INFO[0001] Loading containers: start.
WARN[0001] Running modprobe bridge br_netfilter failed with message: modprobe: can't change directory to '/lib/modules': No such file or directory
, error: exit status 1
WARN[0001] Running modprobe nf_nat failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1
WARN[0001] Running modprobe xt_conntrack failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: Iptables not found
To try and get round this I've installed iptables. Now when I try to run the docker daemon I get:
INFO[0000] libcontainerd: new containerd process, pid: 705
ERRO[0001] 'overlay' is not supported over overlayfs
INFO[0001] Graph migration to content-addressability took 0.00 seconds
INFO[0001] Loading containers: start.
WARN[0001] Running modprobe bridge br_netfilter failed with message: modprobe: can't change directory to '/lib/modules': No such file or directory
, error: exit status 1
WARN[0001] Running modprobe nf_nat failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1
WARN[0001] Running modprobe xt_conntrack failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.0: can't initialize iptables table `nat': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
(exit status 3)
I'm a little stuck on where to go now as sudo isn't a thing on alpine.
Running the Docker daemon inside the Docker container is generally a dodgy prospect. We have this exact same requirement, and we solve it by mounting /var/run/docker.sock from the Docker host into the Docker container:
docker run -v /var/run/docker.sock:/var/run/docker.sock --privileged
That way the docker command inside the build agent container is actually talking to the Docker daemon on the host, not inside the container. Works really well for us.

Resources