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

Upgrade outdated golang dependencies #326

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .golangci.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
"disable-all": true,
"enable": [
"govet",
"revive",
"goimports",
"misspell",
"ineffassign",
"gofmt"
]
},
"run": {
"skip-files": [
"exclude-files": [
"/zz_generated_"
],
"deadline": "5m"
"timeout": "5m"
}
}
}
19 changes: 9 additions & 10 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
ARG KUBECTL=rancher/kubectl:v1.25.4
ARG KUBECTL=rancher/kubectl:v1.30.3
FROM ${KUBECTL} AS kubectl

FROM registry.suse.com/bci/golang:1.20
FROM registry.suse.com/bci/golang:1.22

COPY --from=kubectl /bin/kubectl /usr/local/bin/kubectl

ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ARG SONOBUOY_VERSION=0.56.16

ARG SONOBUOY_VERSION=0.57.1
RUN zypper -n install expect git jq docker vim less file curl wget iproute2 gawk
RUN if [ "${ARCH:-$(go env GOARCH)}" = "amd64" ]; then \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2; \
curl -sL "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.0.3/kustomize_v5.0.3_linux_amd64.tar.gz" | tar -xz -C /usr/local/bin; \
curl -sL "https://github.com/vmware-tanzu/sonobuoy/releases/download/v${SONOBUOY_VERSION}/sonobuoy_${SONOBUOY_VERSION}_linux_${ARCH}.tar.gz" | tar -xz -C /usr/local/bin; \
curl -sL "https://github.com/docker/compose/releases/download/v2.17.3/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose; \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.59.1; \
curl -sL "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.4.3/kustomize_v5.4.3_linux_amd64.tar.gz" | tar -xz -C /usr/local/bin; \
curl -sL "https://github.com/vmware-tanzu/sonobuoy/releases/download/v${SONOBUOY_VERSION}/sonobuoy_${SONOBUOY_VERSION}_linux_${ARCH}.tar.gz" | tar -xz -C /usr/local/bin; \
curl -sL "https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose; \
fi
RUN mkdir -p /usr/local/lib/docker/cli-plugins; \
curl -o /usr/local/lib/docker/cli-plugins/docker-buildx -fsSL "https://github.com/docker/buildx/releases/download/v0.11.2/buildx-v0.11.2.linux-${ARCH}"; \
curl -o /usr/local/lib/docker/cli-plugins/docker-buildx -fsSL "https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-${ARCH}"; \
chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx
ENV DAPPER_ENV REPO TAG DRONE_TAG
ENV DAPPER_SOURCE /go/src/github.com/rancher/system-upgrade-controller/
Expand Down
4 changes: 1 addition & 3 deletions e2e/cluster/local/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.7"

volumes:
kubeconfig:
name: e2e-local-kubeconfig
Expand All @@ -13,7 +11,7 @@ services:
context: ./images/k3s/.
args:
- ARCH=${ARCH}
command: server --disable=traefik,metrics-server --disable-helm-controller
command: server --disable=traefik,metrics-server --disable-helm-controller --tls-san 172.17.0.1
environment:
- K3S_TOKEN=e2e
hostname: k3s-server-1
Expand Down
26 changes: 13 additions & 13 deletions e2e/cluster/local/images/k3s/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Install the all-in-one binary so we can copy our run-time images into the image
# which helps avoid pulling them when running e2e tests.
ARG BCI="registry.suse.com/bci/bci-base:15.5"
ARG BCI="registry.suse.com/bci/bci-base:15.6"
FROM ${BCI} AS k3s
ARG ARCH
ARG K3S_VERSION="v1.25.9+k3s1"
ARG K3S_VERSION="v1.30.3+k3s1"
RUN set -x \
&& zypper -n in \
ca-certificates \
curl \
&& if [ "${ARCH?required}" != "amd64" ]; then \
K3S_SUFFIX="-${ARCH}"; \
fi \
&& curl -fsSL "https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s${K3S_SUFFIX}" > /bin/k3s \
&& chmod +x /bin/k3s \
&& ln -s /bin/k3s /bin/kubectl \
&& ln -s /bin/k3s /bin/ctr \
&& k3s --version
&& zypper -n in \
ca-certificates \
curl \
&& if [ "${ARCH?required}" != "amd64" ]; then \
K3S_SUFFIX="-${ARCH}"; \
fi \
&& curl -fsSL "https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s${K3S_SUFFIX}" > /bin/k3s \
&& chmod +x /bin/k3s \
&& ln -s /bin/k3s /bin/kubectl \
&& ln -s /bin/k3s /bin/ctr \
&& k3s --version

COPY scratch/*-${ARCH}.tar /var/lib/rancher/k3s/agent/images/
#ADD https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s-airgap-images-${ARCH}.tar /var/lib/rancher/k3s/agent/images/
Expand Down
4 changes: 2 additions & 2 deletions e2e/cluster/local/scripts/cluster-prepare
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -e
: "${ARCH?required}"
: "${DIST?required}"
: "${BCI_TAG:=15.4}"
: "${KUBECTL_TAG:=v1.25.4}"
: "${SONOBUOY_TAG:=v0.56.16}"
: "${KUBECTL_TAG:=v1.30.3}"
: "${SONOBUOY_TAG:=v0.57.1}"

docker-image-save() {
echo "Pulling '$1:$2' ..."
Expand Down
2 changes: 1 addition & 1 deletion e2e/framework/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func ChannelServer(location string, statusCode int) *httptest.Server {
Failf("cannot read hostname: %v", err)
}
server := &httptest.Server{
Config: &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Config: &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Location", location)
w.WriteHeader(statusCode)
})},
Expand Down
19 changes: 7 additions & 12 deletions e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,10 @@ func New(name string, opt ...Option) *Client {
fn(options)
}
client := &Client{
Framework: framework.Framework{
BaseName: name,
AddonResourceConstraints: make(map[string]framework.ResourceConstraint),
NamespacePodSecurityEnforceLevel: admissionapi.LevelPrivileged,
Options: options.Options,
},
Framework: *framework.NewFramework(name, options.Options, nil),
}
client.Framework.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged
ginkgo.BeforeEach(client.BeforeEach)
ginkgo.AfterEach(client.AfterEach)
return client
}

Expand Down Expand Up @@ -161,14 +156,14 @@ func (c *Client) WaitForPlanJobs(plan *upgradeapiv1.Plan, count int, timeout tim
})
}

func (c *Client) BeforeEach() {
func (c *Client) BeforeEach(ctx context.Context) {
c.beforeFramework()
c.Framework.BeforeEach()
c.Framework.BeforeEach(ctx)
c.setupController()
}

func (c *Client) AfterEach() {
c.Framework.AfterEach()
func (c *Client) AfterEach(ctx context.Context) {
c.Framework.AfterEach(ctx)
}

func (c *Client) setupController() {
Expand All @@ -181,7 +176,7 @@ func (c *Client) setupController() {
}, metav1.CreateOptions{})
framework.ExpectNoError(err)

err = frameworkauth.BindClusterRole(c.ClientSet.RbacV1(), "cluster-admin", c.Namespace.Name, rbacv1.Subject{
err = frameworkauth.BindClusterRole(context.TODO(), c.ClientSet.RbacV1(), "cluster-admin", c.Namespace.Name, rbacv1.Subject{
Kind: rbacv1.ServiceAccountKind,
Name: c.controllerServiceAccount.Name,
Namespace: c.controllerServiceAccount.Namespace,
Expand Down
4 changes: 2 additions & 2 deletions e2e/framework/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/onsi/ginkgo/v2"
"k8s.io/kubernetes/test/e2e/framework/ginkgowrapper"
"k8s.io/kubernetes/test/e2e/framework"
)

// Logf logs the info.
Expand Down Expand Up @@ -35,7 +35,7 @@ func Failf(format string, args ...interface{}) {
func FailfWithOffset(offset int, format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
Logf("FAIL", msg)
ginkgowrapper.Fail(nowStamp()+": "+msg, 1+offset)
framework.Fail(nowStamp()+": "+msg, 1+offset)
}

func nowStamp() string {
Expand Down
14 changes: 7 additions & 7 deletions e2e/suite/job_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"io"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/rancher/system-upgrade-controller/e2e/framework"
upgradeapiv1 "github.com/rancher/system-upgrade-controller/pkg/apis/upgrade.cattle.io/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -98,8 +98,8 @@ var _ = Describe("Job Generation", func() {
}
plan.Spec.Drain = &upgradeapiv1.DrainSpec{
DisableEviction: true,
DeleteLocalData: pointer.Bool(true),
DeleteEmptydirData: pointer.Bool(true),
DeleteLocalData: ptr.To(true),
DeleteEmptydirData: ptr.To(true),
PodSelector: &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{{
Key: "component",
Expand Down Expand Up @@ -139,7 +139,7 @@ var _ = Describe("Job Generation", func() {
})
AfterEach(func() {
if CurrentSpecReport().Failed() {
podList, _ := e2e.PodClient().List(context.Background(), metav1.ListOptions{})
podList, _ := e2e.ClientSet.CoreV1().Pods(e2e.Namespace.Name).List(context.Background(), metav1.ListOptions{})
for _, pod := range podList.Items {
containerNames := []string{}
for _, container := range pod.Spec.InitContainers {
Expand All @@ -150,7 +150,7 @@ var _ = Describe("Job Generation", func() {
}
for _, container := range containerNames {
reportName := fmt.Sprintf("podlogs-%s-%s", pod.Name, container)
logs := e2e.PodClient().GetLogs(pod.Name, &v1.PodLogOptions{Container: container})
logs := e2e.ClientSet.CoreV1().Pods(e2e.Namespace.Name).GetLogs(pod.Name, &v1.PodLogOptions{Container: container})
if logStreamer, err := logs.Stream(context.Background()); err == nil {
if podLogs, err := io.ReadAll(logStreamer); err == nil {
AddReportEntry(reportName, string(podLogs))
Expand Down
2 changes: 0 additions & 2 deletions examples/ubuntu/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.7"

services:

leader:
Expand Down
Loading
Loading