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

[SUM-1192] Upgrade dependencies #4

Merged
merged 4 commits into from
Aug 5, 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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.13 AS builder
FROM golang:1.22.5 AS builder
WORKDIR /build
COPY go.* /build/
RUN go mod download
Expand Down
39 changes: 20 additions & 19 deletions cmd/storage-check/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func createStorageConfig(pvcname, accessMode string) *corev1.PersistentVolumeCla
pvcSpec := corev1.PersistentVolumeClaimSpec{
AccessModes: []v1.PersistentVolumeAccessMode{getAccessMode(accessMode)},
//Selector: ""
Resources: v1.ResourceRequirements{
Resources: v1.VolumeResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceName(v1.ResourceStorage): resource.MustParse(pvcSize),
},
Expand Down Expand Up @@ -256,7 +256,7 @@ func createStorage(pvcConfig *corev1.PersistentVolumeClaim) chan StorageResult {

result := StorageResult{}

storage, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Create(pvcConfig)
storage, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Create(ctx, pvcConfig, metav1.CreateOptions{})
if err != nil {
log.Infoln("Failed to create a storage in the cluster:", err)
result.Err = err
Expand All @@ -275,7 +275,7 @@ func createStorage(pvcConfig *corev1.PersistentVolumeClaim) chan StorageResult {
log.Infoln("Watching for storage to exist.")

// Watch that it is up.
watch, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Watch(metav1.ListOptions{
watch, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Watch(ctx, metav1.ListOptions{
Watch: true,
FieldSelector: "metadata.name=" + storage.Name,
})
Expand Down Expand Up @@ -341,8 +341,9 @@ func initializeStorage(job *batchv1.Job) chan InitStorageResult {
defer close(createChan)

result := InitStorageResult{}
createOpts := metav1.CreateOptions{}

initStorage, err := client.BatchV1().Jobs(checkNamespace).Create(job)
initStorage, err := client.BatchV1().Jobs(checkNamespace).Create(ctx, job, createOpts)
if err != nil {
log.Infoln("Failed to create a storage initializer Job in the cluster:", err)
result.Err = err
Expand All @@ -361,7 +362,7 @@ func initializeStorage(job *batchv1.Job) chan InitStorageResult {
log.Infoln("Watching for storage initializer Job to exist.")

// Watch that it is up.
watch, err := client.BatchV1().Jobs(checkNamespace).Watch(metav1.ListOptions{
watch, err := client.BatchV1().Jobs(checkNamespace).Watch(ctx, metav1.ListOptions{
Watch: true,
FieldSelector: "metadata.name=" + initStorage.Name,
// LabelSelector: defaultLabelKey + "=" + defaultLabelValueBase + strconv.Itoa(int(now.Unix())),
Expand Down Expand Up @@ -430,7 +431,7 @@ func checkStorage(job *batchv1.Job) chan CheckStorageResult {

result := CheckStorageResult{}

checkStorage, err := client.BatchV1().Jobs(checkNamespace).Create(job)
checkStorage, err := client.BatchV1().Jobs(checkNamespace).Create(ctx, job, metav1.CreateOptions{})
if err != nil {
log.Infoln("Failed to create a storage check Job in the cluster:", err)
result.Err = err
Expand All @@ -449,7 +450,7 @@ func checkStorage(job *batchv1.Job) chan CheckStorageResult {
log.Infoln("Watching for storage check Job to exist.")

// Watch that it is up.
watch, err := client.BatchV1().Jobs(checkNamespace).Watch(metav1.ListOptions{
watch, err := client.BatchV1().Jobs(checkNamespace).Watch(ctx, metav1.ListOptions{
Watch: true,
FieldSelector: "metadata.name=" + checkStorage.Name,
})
Expand Down Expand Up @@ -529,7 +530,7 @@ func deleteStorageAndWait(ctx context.Context) error {
time.Sleep(time.Second * 5)

// Watch that it is gone by listing repeatedly.
storageList, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).List(metav1.ListOptions{
storageList, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).List(ctx, metav1.ListOptions{
FieldSelector: "metadata.name=" + checkStorageName,
})
if err != nil {
Expand Down Expand Up @@ -595,7 +596,7 @@ func deleteStorageCheckAndWait(ctx context.Context) error {
time.Sleep(time.Second * 5)

// Watch that it is gone by listing repeatedly.
jobList, err := client.BatchV1().Jobs(checkNamespace).List(metav1.ListOptions{
jobList, err := client.BatchV1().Jobs(checkNamespace).List(ctx, metav1.ListOptions{
FieldSelector: "metadata.name=" + jobName,
})
if err != nil {
Expand Down Expand Up @@ -661,7 +662,7 @@ func deleteStorageInitJobAndWait(ctx context.Context) error {
time.Sleep(time.Second * 5)

// Watch that it is gone by listing repeatedly.
jobList, err := client.BatchV1().Jobs(checkNamespace).List(metav1.ListOptions{
jobList, err := client.BatchV1().Jobs(checkNamespace).List(ctx, metav1.ListOptions{
FieldSelector: "metadata.name=" + jobName,
})
if err != nil {
Expand Down Expand Up @@ -713,7 +714,7 @@ func deleteStorage() error {
}

// Delete the storage and return the result.
return client.CoreV1().PersistentVolumeClaims(checkNamespace).Delete(checkStorageName, &deleteOpts)
return client.CoreV1().PersistentVolumeClaims(checkNamespace).Delete(ctx, checkStorageName, deleteOpts)
}

// deleteStorageInitJob issues a foreground delete for the test storage init name.
Expand All @@ -728,7 +729,7 @@ func deleteStorageInitJob(job string) error {
}

// Delete the storage and return the result.
return client.BatchV1().Jobs(checkNamespace).Delete(job, &deleteOpts)
return client.BatchV1().Jobs(checkNamespace).Delete(ctx, job, deleteOpts)
}

// deleteStorageCheckJob issues a foreground delete for the storage check job name.
Expand All @@ -743,7 +744,7 @@ func deleteStorageCheckJob(job string) error {
}

// Delete the storage and return the result.
return client.BatchV1().Jobs(checkNamespace).Delete(job, &deleteOpts)
return client.BatchV1().Jobs(checkNamespace).Delete(ctx, job, deleteOpts)
}

// cleanUpOrphanedStorage cleans up storages created from previous checks.
Expand All @@ -755,7 +756,7 @@ func cleanUpOrphanedStorage() error {
defer close(cleanUpChan)

// Watch that it is gone.
watch, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Watch(metav1.ListOptions{
watch, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Watch(ctx, metav1.ListOptions{
Watch: true,
FieldSelector: "metadata.name=" + checkStorageName,
// LabelSelector: defaultLabelKey + "=" + defaultLabelValueBase + strconv.Itoa(int(now.Unix())),
Expand Down Expand Up @@ -799,7 +800,7 @@ func cleanUpOrphanedStorage() error {
}

// Send the delete request.
err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Delete(checkStorageName, &deleteOpts)
err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Delete(ctx, checkStorageName, deleteOpts)
if err != nil {
return errors.New("failed to delete previous storage: " + err.Error())
}
Expand All @@ -813,7 +814,7 @@ func findPreviousStorage() (bool, error) {

log.Infoln("Attempting to find previously created storage(s) belonging to this check.")

storageList, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).List(metav1.ListOptions{})
storageList, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).List(ctx, metav1.ListOptions{})
if err != nil {
log.Infoln("error listing storages:", err)
return false, err
Expand Down Expand Up @@ -849,7 +850,7 @@ func findPreviousStorageInitJob() (bool, error) {

log.Infoln("Attempting to find previously created storage init job belonging to this check.")

jobList, err := client.BatchV1().Jobs(checkNamespace).List(metav1.ListOptions{})
jobList, err := client.BatchV1().Jobs(checkNamespace).List(ctx, metav1.ListOptions{})
if err != nil {
log.Infoln("error listing Jobs:", err)
return false, err
Expand Down Expand Up @@ -887,7 +888,7 @@ func findPreviousStorageCheckJob() (bool, error) {

log.Infoln("Attempting to find previously created storage check job belonging to this check.")

jobList, err := client.BatchV1().Jobs(checkNamespace).List(metav1.ListOptions{})
jobList, err := client.BatchV1().Jobs(checkNamespace).List(ctx, metav1.ListOptions{})
if err != nil {
log.Infoln("error listing Jobs:", err)
return false, err
Expand Down Expand Up @@ -927,7 +928,7 @@ func waitForStorageToDelete() chan bool {
go func() {
defer close(deleteChan)
for {
_, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Get(checkStorageName, metav1.GetOptions{})
_, err := client.CoreV1().PersistentVolumeClaims(checkNamespace).Get(ctx, checkStorageName, metav1.GetOptions{})
if err != nil {
log.Debugln("error from Storages().Get():", err.Error())
if k8sErrors.IsNotFound(err) || strings.Contains(err.Error(), "not found") {
Expand Down
54 changes: 44 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,50 @@ replace google.golang.org/cloud => cloud.google.com/go v0.37.0
replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.3.0

require (
github.com/Comcast/kuberhealthy/v2 v2.2.0
github.com/Comcast/kuberhealthy/v2 v2.4.1
github.com/sirupsen/logrus v1.9.3
k8s.io/api v0.30.3
k8s.io/apimachinery v0.30.3
k8s.io/client-go v0.30.3
)

require (
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/sirupsen/logrus v1.4.0
github.com/spf13/pflag v1.0.3 // indirect
github.com/stretchr/testify v1.5.1 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
k8s.io/api v0.0.0-20190819141258-3544db3b9e44
k8s.io/apimachinery v0.15.7
k8s.io/client-go v0.0.0-20190819141724-e14f31a72a77
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240730131305-7a9a4e85957e // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

go 1.13
go 1.22.5
Loading