Skip to content

Commit

Permalink
set config to main and get pod before updating annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
curtbushko committed Sep 26, 2022
1 parent c0a8f70 commit b0d4c6b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 44 deletions.
76 changes: 36 additions & 40 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1226,13 +1226,13 @@ workflows:
requires:
- dev-upload-docker
nightly-acceptance-tests:
# triggers:
# - schedule:
# cron: "0 0 * * *"
# filters:
# branches:
# only:
# - main
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- build-distro:
OS: "linux"
Expand All @@ -1241,48 +1241,44 @@ workflows:
- dev-upload-docker:
requires:
- build-distros-linux
#
# - cleanup-gcp-resources
# - cleanup-azure-resources
# - cleanup-eks-resources
- cleanup-gcp-resources
- cleanup-azure-resources
- cleanup-eks-resources
# Disable until we can use UBI images.
# - acceptance-openshift:
# requires:
# - cleanup-azure-resources
# - acceptance-gke-1-23:
# requires:
# - cleanup-gcp-resources
# - dev-upload-docker
- acceptance-gke-1-23:
requires:
- cleanup-gcp-resources
- dev-upload-docker
- acceptance-gke-cni-1-23:
requires:
# - acceptance-gke-1-23
- acceptance-gke-1-23
- acceptance-eks-1-21:
requires:
- cleanup-eks-resources
- dev-upload-docker
# - acceptance-eks-1-21:
# requires:
# - cleanup-eks-resources
# - dev-upload-docker
- acceptance-eks-cni-1-21:
requires:
# - acceptance-eks-1-21
- acceptance-eks-1-21
- acceptance-aks-1-22:
requires:
- cleanup-azure-resources
- dev-upload-docker
# - acceptance-aks-1-22:
# requires:
# - cleanup-azure-resources
# - dev-upload-docker
- acceptance-aks-cni-1-22:
requires:
# - acceptance-aks-1-22
- dev-upload-docker

# nightly-acceptance-tests-consul:
# triggers:
# - schedule:
# cron: "0 0 * * *"
# filters:
# branches:
# only:
# - main
# jobs:
# - acceptance-kind-1-23-consul-nightly-1-11
# - acceptance-kind-1-23-consul-nightly-1-12
# - acceptance-kind-1-23-consul-nightly-1-13
- acceptance-aks-1-22

nightly-acceptance-tests-consul:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- acceptance-kind-1-23-consul-nightly-1-11
- acceptance-kind-1-23-consul-nightly-1-12
- acceptance-kind-1-23-consul-nightly-1-13
13 changes: 9 additions & 4 deletions control-plane/cni/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (c *Command) cmdAdd(args *skel.CmdArgs) error {

// We do not throw an error here because kubernetes will often throw a benign error where the pod has been
// updated in between the get and update of the annotation. Eventually kubernetes will update the annotation
ok := c.updateTransparentProxyStatusAnnotation(pod, podNamespace, waiting)
ok := c.updateTransparentProxyStatusAnnotation(podName, podNamespace, waiting)
if !ok {
logger.Info("unable to update %s pod annotation to waiting", keyTransparentProxyStatus)
}
Expand All @@ -215,7 +215,7 @@ func (c *Command) cmdAdd(args *skel.CmdArgs) error {

// We do not throw an error here because kubernetes will often throw a benign error where the pod has been
// updated in between the get and update of the annotation. Eventually kubernetes will update the annotation
ok = c.updateTransparentProxyStatusAnnotation(pod, podNamespace, complete)
ok = c.updateTransparentProxyStatusAnnotation(podName, podNamespace, complete)
if !ok {
logger.Info("unable to update %s pod annotation to complete", keyTransparentProxyStatus)
}
Expand Down Expand Up @@ -272,8 +272,13 @@ func parseAnnotation(pod corev1.Pod, annotation string) (iptables.Config, error)

// updateTransparentProxyStatusAnnotation updates the transparent-proxy-status annotation. We use it as a simple inicator of
// CNI status on the pod. Failing is not fatal.
func (c *Command) updateTransparentProxyStatusAnnotation(pod *corev1.Pod, namespace, status string) bool {
func (c *Command) updateTransparentProxyStatusAnnotation(podName, namespace, status string) bool {
// Refresh the pod so that we can update it without problems
pod, err := c.client.CoreV1().Pods(namespace).Get(context.Background(), podName, metav1.GetOptions{})
if err != nil {
return false
}
pod.Annotations[keyTransparentProxyStatus] = status
_, err := c.client.CoreV1().Pods(namespace).Update(context.Background(), pod, metav1.UpdateOptions{})
_, err = c.client.CoreV1().Pods(namespace).Update(context.Background(), pod, metav1.UpdateOptions{})
return err == nil
}

0 comments on commit b0d4c6b

Please sign in to comment.