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

Use dockershim.sock for CRI #751

Merged
merged 1 commit into from
Dec 11, 2019
Merged

Conversation

mogren
Copy link
Contributor

@mogren mogren commented Dec 11, 2019

Issue #714 related

Description of changes:
In the original commit, we only checked /var/run/cri.sock to get the Sandbox ID. This works fine for CRI-O or containerd with the CRI plugin, as long as the socket is mounted correctly, but when using docker we need the /var/run/dockershim.sock created by Kubelet, since it talks gRPC with the CRI API, while /var/run/docker.sock is http only.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mogren mogren added the bug label Dec 11, 2019
@mogren mogren requested a review from jaypipes December 11, 2019 01:30
Fix getting the sandbox id on docker as well.
@mogren mogren force-pushed the fix-sandbox-delete branch from 3fbfad9 to c0afbd0 Compare December 11, 2019 05:16
Copy link
Contributor

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the commit message and/or the PR summary message to explain why this commit is fixing a problem. Currently, the PR summary and commit message is a bit thread-bare and doesn't indicate why falling back to the dockershim socket actually worked...

@@ -101,7 +101,7 @@ spec:
- name: AWS_VPC_K8S_CNI_VETHPREFIX
value: eni
- name: AWS_VPC_K8S_CNI_MTU
value: 9001
value: "9001"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. this was a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for some reason I got an error applying the config without the quotes.

@@ -40,7 +40,6 @@ require (
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
google.golang.org/appengine v1.4.0 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. this is likely due to different Golang versions in our local development environments trampling on each other... My local go version is 1.12.7. I suspect you're on 1.13 and beyond?

if err != nil {
log.Warnf("During ipamd init, failed to get Pod information from Kubernetes API Server %v", err)
ipamdErrInc("nodeInitK8SGetLocalPodIPsFailed")
// This can happens when L-IPAMD starts before kubelet.
// TODO need to add node health stats here
return errors.Wrap(err, "failed to get running pods!")
}
log.Debugf("getLocalPodsWithRetry() found %d local pods", len(localPods))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good move...

socketPath = criSocketPath
}
log.Debugf("Getting running pod sandboxes from %q", socketPath)
conn, err := grpc.Dial(socketPath, grpc.WithInsecure())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we can turn this into a blocking call (WithBlock() with a backoff timeout) in a future commit...

@@ -36,7 +36,7 @@ fi

AGENT_LOG_PATH=${AGENT_LOG_PATH:-aws-k8s-agent.log}
HOST_CNI_BIN_PATH=${HOST_CNI_BIN_PATH:-/host/opt/cni/bin}
HOST_CNI_CONFDIR_PATH=${HOST_CNI_CONFDIR_PATH:-/host/opt/cni/net.d}
HOST_CNI_CONFDIR_PATH=${HOST_CNI_CONFDIR_PATH:-/host/etc/cni/net.d}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gahhhhhh!


# Best practice states we should send the container's CMD output to stdout, so
# let's tee back up the log file into stdout
cat $AGENT_LOG_PATH
cat "$AGENT_LOG_PATH"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting that quote-encapping the variable in the entrypoint.sh script fixed anything here and above. I know it's safer to quote-encap vars but I'm curious whether this was an actual fix for a problem in the script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't, but we were mixing quoted and unquoted, so I just made it consistent.

Copy link
Contributor

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty sir!

@jaypipes jaypipes merged commit 759820b into aws:master Dec 11, 2019
mogren pushed a commit to mogren/amazon-vpc-cni-k8s that referenced this pull request Dec 15, 2019
Fix getting the sandbox id on docker as well.
jaypipes pushed a commit that referenced this pull request Dec 19, 2019
Fix getting the sandbox id on docker as well.
@drakedevel
Copy link
Contributor

@mogren any reason not to just mount dockershim.sock as cri.sock? That's was the original idea, leaving it up to the DaemonSet to mount the appropriate path from the host (per #714 (comment)). That was how all of my tests on Docker in EKS were done, as well.

I don't think there's anything broken by doing this instead, but it's the only place in the codebase where there's a special case for Docker, and it appears unnecessary 😛

@mogren
Copy link
Contributor Author

mogren commented Dec 31, 2019

Heh, thanks @drakedevel I think you are right. I did try to use the containerd socket at first, but since the cri-plugin was not loaded, that didn't work. I then tried just using the default docker.sock, but that of course doesn't have the right API, so then I switched to the shim. I should have iterated some more and done that, mount it as cri.sock... Time for another follow up PR I guess. 😄

mogren pushed a commit to mogren/amazon-vpc-cni-k8s that referenced this pull request Apr 20, 2020
Fix getting the sandbox id on docker as well.
mogren pushed a commit that referenced this pull request Apr 20, 2020
Fix getting the sandbox id on docker as well.
@mogren mogren deleted the fix-sandbox-delete branch June 16, 2020 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants