Skip to content

Commit

Permalink
Stop setting GOPROXY in Dockerfile (#2736)
Browse files Browse the repository at this point in the history
* Stop setting GOPROXY in Dockerfile

We're seeing failures in CI related to goproxy.io. There's no need to
set this so simply don't.

Signed-off-by: Stephen Finucane <[email protected]>

* test: Remove use of global_env fact

It's confusing and unnecessary. Place everything in its regular place
instead.

Signed-off-by: Stephen Finucane <[email protected]>

* tests: Don't rely on GOPATH

This wasn't being set correctly and managing envvars via Ansible is
tricky at the best of times. Use hard coded paths instead.

Signed-off-by: Stephen Finucane <[email protected]>

* tests: Set environment

While we figure out why bashrc is not being respected.

Signed-off-by: Stephen Finucane <[email protected]>

---------

Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin authored Dec 7, 2024
1 parent d228854 commit f650ac3
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 57 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ RUN apk add --no-cache ca-certificates
# builder itself is always amd64
FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} AS builder

ARG GOPROXY=https://goproxy.io,direct
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
Expand Down
5 changes: 2 additions & 3 deletions tests/playbooks/roles/install-cpo-occm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ Prerequisites:
* The playbook is running on a host with devstack installed.
* golang, docker and kubectl should be installed.
* docker registry is up and running.
* GOPATH should be configured in {{ global_env }}
* KUBECONFIG should be configured in {{ global_env }}
* k8s cluster is running inside VMs on the devstack host.
* k8s cluster is running inside VMs on the devstack host.
* `~/.kube/config` exists and is pointing at the k8s cluster
16 changes: 8 additions & 8 deletions tests/playbooks/roles/install-cpo-occm/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
- name: Ensure CPO source folder
- name: Ensure CPO source folder is present
shell:
executable: /bin/bash
cmd: |
if [ ! -d $GOPATH/src/k8s.io/cloud-provider-openstack ]; then
mkdir -p $GOPATH/src/k8s.io; cd $_
git clone https://github.com/kubernetes/cloud-provider-openstack
if [ ! -d "{{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack" ]; then
echo "{{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack should exist but does not"
exit 1
fi
- name: Build and upload openstack-cloud-controller-manager image
shell:
executable: /bin/bash
cmd: |
cd $GOPATH/src/k8s.io/cloud-provider-openstack
cd {{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack
VERSION="v0.0.99" # Fake version, but in proper format.
make push-multiarch-image-openstack-cloud-controller-manager \
Expand Down Expand Up @@ -71,7 +71,7 @@
cmd: |
VERSION="v0.0.99" # Fake version, but in proper format.
cd $GOPATH/src/k8s.io/cloud-provider-openstack
cd {{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack
# replace image with built image
sed -i "s#registry.k8s.io/provider-os/openstack-cloud-controller-manager:[^'\"]\+#{{ remote_registry_host }}/openstack-cloud-controller-manager:${VERSION}#" manifests/controller-manager/openstack-cloud-controller-manager-ds.yaml
sed -i "s#node-role.kubernetes.io/control-plane: \"\"#node-role.kubernetes.io/control-plane: \"true\"#" manifests/controller-manager/openstack-cloud-controller-manager-ds.yaml
Expand All @@ -82,7 +82,7 @@
shell:
executable: /bin/bash
cmd: |
cd $GOPATH/src/k8s.io/cloud-provider-openstack
cd {{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack
kubectl apply -f manifests/controller-manager/openstack-cloud-controller-manager-ds.yaml
kubectl apply -f manifests/controller-manager/cloud-controller-manager-roles.yaml
Expand Down Expand Up @@ -133,7 +133,7 @@
shell:
executable: /bin/bash
cmd: |
cd $GOPATH/src/k8s.io/cloud-provider-openstack
cd {{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack
# GATEWAY_IP is the default value in devstack
GATEWAY_IP=172.24.5.1 \
Expand Down
3 changes: 1 addition & 2 deletions tests/playbooks/roles/install-csi-cinder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ Prerequisites:
* The playbook is running on a host with devstack installed.
* golang, docker and kubectl should be installed.
* docker registry is up and running.
* GOPATH should be configured in {{ global_env }}
* KUBECONFIG should be configured in {{ global_env }}
* k8s cluster is running inside VMs on the devstack host.
* `~/.kube/config` exists and is pointing at the k8s cluster
16 changes: 8 additions & 8 deletions tests/playbooks/roles/install-csi-cinder/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
- name: Ensure CPO source folder
- name: Ensure CPO source folder is present
shell:
executable: /bin/bash
cmd: |
if [ ! -d $GOPATH/src/k8s.io/cloud-provider-openstack ]; then
mkdir -p $GOPATH/src/k8s.io; cd $_
git clone https://github.com/kubernetes/cloud-provider-openstack
if [ ! -d "{{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack" ]; then
echo "{{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack should exist but does not"
exit 1
fi
- name: Build and upload cinder-csi-plugin image
shell:
executable: /bin/bash
cmd: |
cd $GOPATH/src/k8s.io/cloud-provider-openstack
cd {{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack
VERSION="v0.0.99" # Fake version, but in proper format.
make push-multiarch-image-cinder-csi-plugin \
Expand Down Expand Up @@ -59,7 +59,7 @@
# replace manifest cloud secret file
b64data=`cat {{ ansible_user_dir }}/cloud.conf | base64 -w 0`
cd $GOPATH/src/k8s.io/cloud-provider-openstack
cd {{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack
sed -i "/cloud\.conf/c\ cloud.conf: $b64data" manifests/cinder-csi-plugin/csi-secret-cinderplugin.yaml
Expand All @@ -74,7 +74,7 @@
shell:
executable: /bin/bash
cmd: |
cd $GOPATH/src/k8s.io/cloud-provider-openstack
cd {{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack
kubectl apply -f manifests/cinder-csi-plugin
ignore_errors: true

Expand Down Expand Up @@ -180,7 +180,7 @@
set -e
set -o pipefail
cd $GOPATH/src/k8s.io/cloud-provider-openstack
cd {{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack
mkdir -p /var/log/csi-pod
# TODO(chrigl): No idea why both tests fail in CI. On a real OpenStack both pass.
/tmp/kubernetes/test/bin/e2e.test \
Expand Down
2 changes: 1 addition & 1 deletion tests/playbooks/roles/install-csi-manila/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Prerequisites:
* The playbook is running on a host with devstack installed.
* golang, docker and kubectl should be installed.
* docker registry is up and running.
* KUBECONFIG should be configured in {{ global_env }}
* k8s cluster is running inside VMs on the devstack host.
* `~/.kube/config` exists and is pointing at the k8s cluster
10 changes: 5 additions & 5 deletions tests/playbooks/roles/install-csi-manila/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
- name: Ensure CPO source folder
- name: Ensure CPO source folder is present
shell:
executable: /bin/bash
cmd: |
if [ ! -d $GOPATH/src/k8s.io/cloud-provider-openstack ]; then
mkdir -p $GOPATH/src/k8s.io; cd $_
git clone https://github.com/kubernetes/cloud-provider-openstack
if [ ! -d "{{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack" ]; then
echo "{{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack should exist but does not"
exit 1
fi
- name: Build and upload manila-csi-plugin image
shell:
executable: /bin/bash
cmd: |
cd $GOPATH/src/k8s.io/cloud-provider-openstack
cd {{ ansible_user_dir }}/src/k8s.io/cloud-provider-openstack
VERSION="v0.0.99" # Fake version, but in proper format.
make push-multiarch-image-manila-csi-plugin \
Expand Down
20 changes: 12 additions & 8 deletions tests/playbooks/roles/install-golang/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@
when:
- curr_go_version.stdout != go_version

- name: Set golang env vars
set_fact:
golang_env:
GOPATH: '{{ ansible_user_dir }}'
PATH: '/usr/local/go/bin:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}'
- name: Set GOPATH
lineinfile:
path: ~/.bashrc
line: 'export GOPATH=$HOME'
create: true
state: present

- name: Merge golang env vars into global env
set_fact:
global_env: '{{ global_env | combine(golang_env) }}'
- name: Add go binary path to PATH
lineinfile:
path: ~/.bashrc
line: 'export PATH=/usr/local/go/bin:{{ ansible_user_dir }}/bin:$PATH'
create: true
state: present
15 changes: 9 additions & 6 deletions tests/playbooks/roles/install-k3s-bare-single/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@
retries: 12
delay: 10

- name: Set kubeconfig env
set_fact:
kubeconfig: "/etc/rancher/k3s/k3s.yaml"
- name: Create ~/.kube directory
ansible.builtin.file:
path: ~/.kube
state: directory

- name: Merge KUBECONFIG env vars into global env
set_fact:
global_env: "{{ global_env | combine({'KUBECONFIG': kubeconfig}) }}"
- name: Copy kubeconfig to ~/.kube
ansible.builtin.copy:
src: /etc/rancher/k3s/k3s.yaml
dest: ~/.kube/config
remote_src: true
8 changes: 0 additions & 8 deletions tests/playbooks/roles/install-k3s/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,3 @@
until: result.stdout == (worker_node_count + 1)|string
retries: 12
delay: 10

- name: Set kubeconfig env
set_fact:
kubeconfig: "{{ ansible_user_dir }}/.kube/config"

- name: Merge KUBECONFIG env vars into global env
set_fact:
global_env: "{{ global_env | combine({'KUBECONFIG': kubeconfig}) }}"
7 changes: 4 additions & 3 deletions tests/playbooks/test-csi-cinder-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
vars:
e2e_test_version: v1.31.2
user: stack
global_env: {}
devstack_workdir: /home/{{ user }}/devstack

roles:
Expand All @@ -24,6 +23,8 @@
worker_node_count: 0
- role: install-cpo-occm
run_e2e: false
environment: "{{ global_env }}"
- role: install-csi-cinder
environment: "{{ global_env }}"
environment:
GOPATH: '{{ ansible_user_dir }}'
PATH: '/usr/local/go/bin:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}'
KUBECONFIG: '{{ ansible_user_dir }}/.kube/config'
6 changes: 4 additions & 2 deletions tests/playbooks/test-csi-manila-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

vars:
user: stack
global_env: {}
devstack_workdir: /home/{{ user }}/devstack

roles:
Expand All @@ -25,4 +24,7 @@
run_e2e: false
- role: install-helm
- role: install-csi-manila
environment: "{{ global_env }}"
environment:
GOPATH: '{{ ansible_user_dir }}'
PATH: '/usr/local/go/bin:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}'
KUBECONFIG: '{{ ansible_user_dir }}/.kube/config'
2 changes: 0 additions & 2 deletions tests/playbooks/test-occm-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

vars:
user: stack
global_env: {}
devstack_workdir: /home/{{ user }}/devstack
octavia_provider: ""

Expand All @@ -28,4 +27,3 @@
- role: install-cpo-occm
run_e2e: "{{ run_e2e }}"
octavia_provider: "{{ octavia_provider }}"
environment: "{{ global_env }}"

0 comments on commit f650ac3

Please sign in to comment.