Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/docker/docker/tools/ubi9/ubi-mi…
Browse files Browse the repository at this point in the history
…nimal-9.5
  • Loading branch information
mergify[bot] authored Dec 2, 2024
2 parents 5fa8768 + c6a8890 commit c8856e0
Show file tree
Hide file tree
Showing 45 changed files with 244 additions and 208 deletions.
6 changes: 3 additions & 3 deletions docker/postgres-kanister-tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
awscli==1.35.20
awscli==1.36.10
pip==24.3.1
setuptools==75.3.0
wheel==0.44.0
setuptools==75.6.0
wheel==0.45.1
6 changes: 3 additions & 3 deletions docker/postgresql/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
awscli==1.35.20
awscli==1.36.10
wal-e==1.1.1
pip==24.3.1
setuptools==75.3.0
wheel==0.44.0
setuptools==75.6.0
wheel==0.45.1
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/jpillora/backoff v1.0.0
github.com/json-iterator/go v1.1.12
github.com/kanisterio/errkit v0.0.2
github.com/kanisterio/safecli v0.0.8
github.com/kanisterio/safecli v0.0.9
github.com/kopia/kopia v0.17.1-0.20240927044625-1bceb7155ede
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
github.com/lib/pq v1.10.9
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kanisterio/errkit v0.0.2 h1:3v3HGz9lHIbZR6Jr9qIJpRjaqUX0rsJSLMEQGsMHiUk=
github.com/kanisterio/errkit v0.0.2/go.mod h1:ViQ6kPJ2gTJDEvRytmwde7pzG9/sndObF9BPZoEZixc=
github.com/kanisterio/safecli v0.0.8 h1:flvTiGksy/a0+zvqjaBSJwxESu/nFcG65yttmR0XwiA=
github.com/kanisterio/safecli v0.0.8/go.mod h1:KBraqj8mdv2cwAr9wecknGUb8jztTzUik0r7uE6yRA8=
github.com/kanisterio/safecli v0.0.9 h1:MBjXbS82fWhGUaOX1MP+xGyTcouh1GRzzu4EzqQV0rY=
github.com/kanisterio/safecli v0.0.9/go.mod h1:y1oYVoT2eqsmySCIS5yOzrxaYVywlMSEdWEKfLhBjgs=
github.com/kastenhq/check v0.0.0-20180626002341-0264cfcea734 h1:qulsCaCv+O2y9/sQ9nd5KChnAgFOWakTHQ9ZADjs6DQ=
github.com/kastenhq/check v0.0.0-20180626002341-0264cfcea734/go.mod h1:rdqSnvOJuKCPFW/h2rVLuXOAkRnHHdp9PZcKx4HCoDM=
github.com/kastenhq/stow v0.2.6-kasten.1.0.20231101232131-9321daa23aae h1:2cl4yuAJpdmLCx7G8eIsfNlQBLEfw0JDj6mTTyqc5qg=
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/cr/v1alpha1/repositoryserver_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package v1alpha1
import (
"testing"

"github.com/pkg/errors"
"github.com/kanisterio/errkit"
"gopkg.in/check.v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
Expand Down Expand Up @@ -86,7 +86,7 @@ func getRepositoryServerFromSpec(spec []byte) (*RepositoryServer, error) {
repositoryServer := &RepositoryServer{}
d := serializer.NewCodecFactory(runtime.NewScheme()).UniversalDeserializer()
if _, _, err := d.Decode([]byte(spec), nil, repositoryServer); err != nil {
return nil, errors.Wrap(err, "Failed to decode RepositoryServer")
return nil, errkit.Wrap(err, "Failed to decode RepositoryServer")
}
return repositoryServer, nil
}
4 changes: 2 additions & 2 deletions pkg/apis/cr/v1alpha1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"reflect"
"testing"

"github.com/pkg/errors"
"github.com/kanisterio/errkit"
"gopkg.in/check.v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
Expand Down Expand Up @@ -73,7 +73,7 @@ func getBlueprintFromSpec(spec []byte) (*Blueprint, error) {
blueprint := &Blueprint{}
d := serializer.NewCodecFactory(runtime.NewScheme()).UniversalDeserializer()
if _, _, err := d.Decode([]byte(spec), nil, blueprint); err != nil {
return nil, errors.Wrap(err, "Failed to decode spec into object")
return nil, errkit.Wrap(err, "Failed to decode spec into object")
}
return blueprint, nil
}
4 changes: 2 additions & 2 deletions pkg/blockstorage/azure/azuredisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,12 @@ func (s *AdStorage) SnapshotsList(ctx context.Context, tags map[string]string) (
return nil, errkit.Wrap(err, "SnapshotsClient.List in SnapshotsList")
}
for _, snap := range page.Value {
k10Snap, err := s.SnapshotParse(ctx, *snap)
parsedSnap, err := s.SnapshotParse(ctx, *snap)
if err != nil {
log.WithError(err).Print("Incorrect Snaphost type", field.M{"SnapshotID": snap.ID})
continue
}
snaps = append(snaps, k10Snap)
snaps = append(snaps, parsedSnap)
}
}
snaps = blockstorage.FilterSnapshotsWithTags(snaps, blockstorage.SanitizeTags(tags))
Expand Down
2 changes: 1 addition & 1 deletion pkg/blockstorage/tags/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
const (
// ClusterTagKey is used to tag resources with the cluster name
ClusterTagKey = "kanister.io/clustername"
// VersionTagKey is used to tag resources with the K10 version
// VersionTagKey is used to tag resources with a version
VersionTagKey = "kanister.io/version"
// AppNameTag is used to tag volumes with the app they belong to
AppNameTag = "kanister.io/appname"
Expand Down
32 changes: 16 additions & 16 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"strings"
"sync"

"github.com/kanisterio/errkit"
osversioned "github.com/openshift/client-go/apps/clientset/versioned"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"gopkg.in/tomb.v2"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -86,23 +86,23 @@ func New(c *rest.Config, reg prometheus.Registerer) *Controller {
func (c *Controller) StartWatch(ctx context.Context, namespace string) error {
crClient, err := versioned.NewForConfig(c.config)
if err != nil {
return errors.Wrap(err, "failed to get a CustomResource client")
return errkit.Wrap(err, "failed to get a CustomResource client")
}
if err := checkCRAccess(ctx, crClient, namespace); err != nil {
return err
}
clientset, err := kubernetes.NewForConfig(c.config)
if err != nil {
return errors.Wrap(err, "failed to get a k8s client")
return errkit.Wrap(err, "failed to get a k8s client")
}
dynClient, err := dynamic.NewForConfig(c.config)
if err != nil {
return errors.Wrap(err, "failed to get a k8s dynamic client")
return errkit.Wrap(err, "failed to get a k8s dynamic client")
}

osClient, err := osversioned.NewForConfig(c.config)
if err != nil {
return errors.Wrap(err, "failed to get a openshift client")
return errkit.Wrap(err, "failed to get a openshift client")
}

c.crClient = crClient
Expand Down Expand Up @@ -134,13 +134,13 @@ func (c *Controller) StartWatch(ctx context.Context, namespace string) error {

func checkCRAccess(ctx context.Context, cli versioned.Interface, ns string) error {
if _, err := cli.CrV1alpha1().ActionSets(ns).List(ctx, metav1.ListOptions{}); err != nil {
return errors.Wrap(err, "Could not list ActionSets")
return errkit.Wrap(err, "Could not list ActionSets")
}
if _, err := cli.CrV1alpha1().Blueprints(ns).List(ctx, metav1.ListOptions{}); err != nil {
return errors.Wrap(err, "Could not list Blueprints")
return errkit.Wrap(err, "Could not list Blueprints")
}
if _, err := cli.CrV1alpha1().Profiles(ns).List(ctx, metav1.ListOptions{}); err != nil {
return errors.Wrap(err, "Could not list Profiles")
return errkit.Wrap(err, "Could not list Profiles")
}
return nil
}
Expand Down Expand Up @@ -220,7 +220,7 @@ func (c *Controller) onAddActionSet(ctx context.Context, t *tomb.Tomb, as *crv1a
}
as, err := c.crClient.CrV1alpha1().ActionSets(as.GetNamespace()).Get(ctx, as.GetName(), metav1.GetOptions{})
if err != nil {
return errors.WithStack(err)
return errkit.WithStack(err)
}
if err = validate.ActionSet(as); err != nil {
return err
Expand Down Expand Up @@ -313,13 +313,13 @@ func (c *Controller) initActionSetStatus(ctx context.Context, as *crv1alpha1.Act
for _, a := range as.Spec.Actions {
if a.Blueprint == "" {
// TODO: If no blueprint is specified, we should consider a default.
err = errors.New("Blueprint is not specified for action")
err = errkit.New("Blueprint is not specified for action")
c.logAndErrorEvent(ctx, "Could not get blueprint:", "Blueprint not specified", err, as)
break
}
var bp *crv1alpha1.Blueprint
if bp, err = c.crClient.CrV1alpha1().Blueprints(as.GetNamespace()).Get(ctx, a.Blueprint, metav1.GetOptions{}); err != nil {
err = errors.Wrap(err, "Failed to query blueprint")
err = errkit.Wrap(err, "Failed to query blueprint")
c.logAndErrorEvent(ctx, "Could not get blueprint:", "Error", err, as)
break
}
Expand Down Expand Up @@ -349,7 +349,7 @@ func (c *Controller) initActionSetStatus(ctx context.Context, as *crv1alpha1.Act
func (c *Controller) initialActionStatus(a crv1alpha1.ActionSpec, bp *crv1alpha1.Blueprint) (*crv1alpha1.ActionStatus, error) {
bpa, ok := bp.Actions[a.Name]
if !ok {
return nil, errors.Errorf("Action %s for object kind %s not found in blueprint %s", a.Name, a.Object.Kind, a.Blueprint)
return nil, errkit.New(fmt.Sprintf("Action %s for object kind %s not found in blueprint %s", a.Name, a.Object.Kind, a.Blueprint))
}
phases := make([]crv1alpha1.Phase, 0, len(bpa.Phases))
for _, p := range bpa.Phases {
Expand Down Expand Up @@ -379,14 +379,14 @@ func (c *Controller) initialActionStatus(a crv1alpha1.ActionSpec, bp *crv1alpha1

func (c *Controller) handleActionSet(ctx context.Context, t *tomb.Tomb, as *crv1alpha1.ActionSet) (err error) {
if as.Status == nil {
return errors.New("ActionSet was not initialized")
return errkit.New("ActionSet was not initialized")
}
if as.Status.State != crv1alpha1.StatePending {
return nil
}
as.Status.State = crv1alpha1.StateRunning
if as, err = c.crClient.CrV1alpha1().ActionSets(as.GetNamespace()).Update(ctx, as, metav1.UpdateOptions{}); err != nil {
return errors.WithStack(err)
return errkit.WithStack(err)
}
ctx = field.Context(ctx, consts.ActionsetNameKey, as.GetName())
// adding labels with prefix "kanister.io/" in the context as field for better logging
Expand All @@ -399,7 +399,7 @@ func (c *Controller) handleActionSet(ctx context.Context, t *tomb.Tomb, as *crv1
for i, a := range as.Status.Actions {
var bp *crv1alpha1.Blueprint
if bp, err = c.crClient.CrV1alpha1().Blueprints(as.GetNamespace()).Get(ctx, a.Blueprint, metav1.GetOptions{}); err != nil {
err = errors.Wrap(err, "Failed to query blueprint")
err = errkit.Wrap(err, "Failed to query blueprint")
c.logAndErrorEvent(ctx, "Could not get blueprint:", "Error", err, as)
break
}
Expand All @@ -419,7 +419,7 @@ func (c *Controller) handleActionSet(ctx context.Context, t *tomb.Tomb, as *crv1
Message: err.Error(),
}
_, err = c.crClient.CrV1alpha1().ActionSets(as.GetNamespace()).Update(ctx, as, metav1.UpdateOptions{})
return errors.WithStack(err)
return errkit.WithStack(err)
}
log.WithContext(ctx).Print("Created actionset and started executing actions", field.M{"NewActionSetName": as.GetName()})
return nil
Expand Down
16 changes: 8 additions & 8 deletions pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"
"time"

"github.com/pkg/errors"
"github.com/kanisterio/errkit"
"github.com/prometheus/client_golang/prometheus"
promgomodel "github.com/prometheus/client_model/go"
"gopkg.in/check.v1"
Expand Down Expand Up @@ -171,12 +171,12 @@ func (s *ControllerSuite) waitOnActionSetState(as *crv1alpha1.ActionSet, state c
if as.Status.State == crv1alpha1.StatePending || as.Status.State == crv1alpha1.StateRunning {
return false, nil
}
return false, errors.New(fmt.Sprintf("Unexpected state: %s", as.Status.State))
return false, errkit.New(fmt.Sprintf("Unexpected state: %s", as.Status.State))
})
if err == nil {
return nil
}
return errors.Wrapf(err, "State '%s' never reached", state)
return errkit.Wrap(err, fmt.Sprintf("State '%s' never reached", state))
}

func (s *ControllerSuite) waitOnDeferPhaseState(as *crv1alpha1.ActionSet, state crv1alpha1.State) error {
Expand All @@ -201,7 +201,7 @@ func (s *ControllerSuite) waitOnDeferPhaseState(as *crv1alpha1.ActionSet, state
if err == nil {
return nil
}
return errors.Wrapf(err, "State '%s' never reached", state)
return errkit.Wrap(err, fmt.Sprintf("State '%s' never reached", state))
}

func (s *ControllerSuite) waitOnActionSetCompleteWithRunningPhases(as *crv1alpha1.ActionSet, rp *sets.Set[string]) error {
Expand Down Expand Up @@ -229,12 +229,12 @@ func (s *ControllerSuite) waitOnActionSetCompleteWithRunningPhases(as *crv1alpha
}
return false, nil
}
return false, errors.New(fmt.Sprintf("Unexpected state: %s", as.Status.State))
return false, errkit.New(fmt.Sprintf("Unexpected state: %s", as.Status.State))
})
if err == nil {
return nil
}
return errors.Wrapf(err, "ActionSet did not reach '%s' state", crv1alpha1.StateComplete)
return errkit.Wrap(err, fmt.Sprintf("ActionSet did not reach '%s' state", crv1alpha1.StateComplete))
}

func newBPWithOutputArtifact() *crv1alpha1.Blueprint {
Expand Down Expand Up @@ -731,7 +731,7 @@ func (s *ControllerSuite) TestRuntimeObjEventLogs(c *check.C) {
config, err := kube.LoadConfig()
c.Assert(err, check.IsNil)
ctlr := New(config, nil)
ctlr.logAndErrorEvent(ctx, msg, reason, errors.New("Testing Event Logs"), as, nilAs, bp)
ctlr.logAndErrorEvent(ctx, msg, reason, errkit.New("Testing Event Logs"), as, nilAs, bp)

// Test ActionSet error event logging
events, err := s.cli.CoreV1().Events(as.Namespace).Search(scheme.Scheme, as)
Expand All @@ -754,7 +754,7 @@ func (s *ControllerSuite) TestRuntimeObjEventLogs(c *check.C) {

// Testing empty Blueprint
testbp := &crv1alpha1.Blueprint{}
ctlr.logAndErrorEvent(ctx, msg, reason, errors.New("Testing Event Logs"), testbp)
ctlr.logAndErrorEvent(ctx, msg, reason, errkit.New("Testing Event Logs"), testbp)
events, err = s.cli.CoreV1().Events(bp.Namespace).Search(scheme.Scheme, testbp)
c.Assert(err, check.NotNil)
c.Assert(len(events.Items), check.Equals, 0)
Expand Down
22 changes: 11 additions & 11 deletions pkg/controllers/repositoryserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/go-logr/logr"
"github.com/jpillora/backoff"
"github.com/pkg/errors"
"github.com/kanisterio/errkit"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -50,20 +50,20 @@ type RepoServerHandler struct {

func (h *RepoServerHandler) CreateOrUpdateOwnedResources(ctx context.Context) error {
if err := h.getSecretsFromCR(ctx); err != nil {
return errors.Wrap(err, "Failed to get Kopia API server secrets")
return errkit.Wrap(err, "Failed to get Kopia API server secrets")
}

svc, err := h.reconcileService(ctx)
if err != nil {
return errors.Wrap(err, "Failed to reconcile service")
return errkit.Wrap(err, "Failed to reconcile service")
}

envVars, pod, err := h.reconcilePod(ctx, svc)
if err != nil {
return errors.Wrap(err, "Failed to reconcile Kopia API server pod")
return errkit.Wrap(err, "Failed to reconcile Kopia API server pod")
}
if err := h.waitForPodReady(ctx, pod); err != nil {
return errors.Wrap(err, "Kopia API server pod not in ready state")
return errkit.Wrap(err, "Kopia API server pod not in ready state")
}

// envVars are set only when credentials are of type AWS/Azure.
Expand Down Expand Up @@ -95,7 +95,7 @@ func (h *RepoServerHandler) reconcileService(ctx context.Context) (*corev1.Servi
return nil, err
}
if err := h.updateServerInfoInCRStatus(ctx, h.RepositoryServer.Status.ServerInfo.PodName, svc.Name); err != nil {
return nil, errors.Wrap(err, "Failed to update service name in RepositoryServer /status")
return nil, errkit.Wrap(err, "Failed to update service name in RepositoryServer /status")
}
return svc, err
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func (h *RepoServerHandler) createService(ctx context.Context, repoServerNamespa
}
err := h.Reconciler.Create(ctx, &svc)
if err != nil {
return nil, errors.Wrap(err, "Failed to create RepositoryServer service")
return nil, errkit.Wrap(err, "Failed to create RepositoryServer service")
}

err = poll.WaitWithBackoff(ctx, backoff.Backoff{
Expand Down Expand Up @@ -184,7 +184,7 @@ func (h *RepoServerHandler) createPodAndUpdateStatus(ctx context.Context, repoSe
return nil, nil, err
}
if err := h.updateServerInfoInCRStatus(ctx, pod.Name, h.RepositoryServer.Status.ServerInfo.ServiceName); err != nil {
return nil, nil, errors.Wrap(err, "Failed to update pod name in RepositoryServer /status")
return nil, nil, errkit.Wrap(err, "Failed to update pod name in RepositoryServer /status")
}
return envVars, pod, nil
}
Expand Down Expand Up @@ -236,7 +236,7 @@ func (h *RepoServerHandler) createPod(ctx context.Context, repoServerNamespace s
return nil, nil, err
}
if err := h.Reconciler.Create(ctx, pod); err != nil {
return nil, nil, errors.Wrap(err, "Failed to create RepositoryServer pod")
return nil, nil, errkit.Wrap(err, "Failed to create RepositoryServer pod")
}
return pod, envVars, err
}
Expand Down Expand Up @@ -284,7 +284,7 @@ func (h *RepoServerHandler) preparePodOverride(ctx context.Context, po *kube.Pod
h.RepositoryServerSecrets.serverTLS.Name,
po,
); err != nil {
return nil, errors.Wrap(err, "Failed to attach TLS Certificate configuration")
return nil, errkit.Wrap(err, "Failed to attach TLS Certificate configuration")
}
return podOverride, nil
}
Expand Down Expand Up @@ -315,7 +315,7 @@ func (h *RepoServerHandler) updateServerInfoInCRStatus(ctx context.Context, podN

func (h *RepoServerHandler) waitForPodReady(ctx context.Context, pod *corev1.Pod) error {
if err := kube.WaitForPodReady(ctx, h.KubeCli, pod.Namespace, pod.Name); err != nil {
return errors.Wrap(err, fmt.Sprintf("Failed while waiting for pod %s to be ready", pod.Name))
return errkit.Wrap(err, fmt.Sprintf("Failed while waiting for pod %s to be ready", pod.Name))
}
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"

"github.com/go-logr/logr"
"github.com/pkg/errors"
"github.com/kanisterio/errkit"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -69,11 +69,11 @@ func (r *RepositoryServerReconciler) Reconcile(ctx context.Context, req ctrl.Req
logger = logger.V(1)
cnf, err := ctrl.GetConfig()
if err != nil {
return ctrl.Result{}, errors.Wrap(err, "Failed to get k8s config")
return ctrl.Result{}, errkit.Wrap(err, "Failed to get k8s config")
}
kubeCli, err := kubernetes.NewForConfig(cnf)
if err != nil {
return ctrl.Result{}, errors.Wrap(err, "Failed to get a k8s client")
return ctrl.Result{}, errkit.Wrap(err, "Failed to get a k8s client")
}

repositoryServer := &crv1alpha1.RepositoryServer{}
Expand Down
Loading

0 comments on commit c8856e0

Please sign in to comment.