Skip to content

Commit

Permalink
Merge pull request #240 from maiqueb/remove-etcd-backend
Browse files Browse the repository at this point in the history
storage, etcd: remove backend
  • Loading branch information
dougbtv authored Aug 9, 2022
2 parents 560a4b8 + d425c31 commit 428d2b3
Show file tree
Hide file tree
Showing 292 changed files with 118 additions and 88,522 deletions.
25 changes: 4 additions & 21 deletions cmd/whereabouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/k8snetworkplumbingwg/whereabouts/pkg/allocate"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/config"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/logging"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/storage"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/storage/kubernetes"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/types"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/version"
Expand All @@ -40,7 +39,7 @@ func cmdAdd(args *skel.CmdArgs) error {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("ADD - IPAM configuration successfully read: %+v", filterConf(*ipamConf))
logging.Debugf("ADD - IPAM configuration successfully read: %+v", *ipamConf)

// Initialize our result, and assign DNS & routing.
result := &current.Result{}
Expand All @@ -53,12 +52,7 @@ func cmdAdd(args *skel.CmdArgs) error {
ctx, cancel := context.WithTimeout(context.Background(), types.AddTimeLimit)
defer cancel()

switch ipamConf.Datastore {
case types.DatastoreETCD:
newip, err = storage.IPManagementEtcd(ctx, types.Allocate, *ipamConf, args.ContainerID, getPodRef(args.Args))
case types.DatastoreKubernetes:
newip, err = kubernetes.IPManagement(ctx, types.Allocate, *ipamConf, args.ContainerID, getPodRef(args.Args))
}
newip, err = kubernetes.IPManagement(ctx, types.Allocate, *ipamConf, args.ContainerID, getPodRef(args.Args))
if err != nil {
logging.Errorf("Error at storage engine: %s", err)
return fmt.Errorf("error at storage engine: %w", err)
Expand Down Expand Up @@ -94,18 +88,13 @@ func cmdDel(args *skel.CmdArgs) error {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("DEL - IPAM configuration successfully read: %+v", filterConf(*ipamConf))
logging.Debugf("DEL - IPAM configuration successfully read: %+v", *ipamConf)
logging.Debugf("Beginning delete for ContainerID: %v", args.ContainerID)

ctx, cancel := context.WithTimeout(context.Background(), types.DelTimeLimit)
defer cancel()

switch ipamConf.Datastore {
case types.DatastoreETCD:
_, err = storage.IPManagementEtcd(ctx, types.Deallocate, *ipamConf, args.ContainerID, getPodRef(args.Args))
case types.DatastoreKubernetes:
_, err = kubernetes.IPManagement(ctx, types.Deallocate, *ipamConf, args.ContainerID, getPodRef(args.Args))
}
_, err = kubernetes.IPManagement(ctx, types.Deallocate, *ipamConf, args.ContainerID, getPodRef(args.Args))
if err != nil {
logging.Verbosef("WARNING: Problem deallocating IP: %s", err)
// return fmt.Errorf("Error deallocating IP: %s", err)
Expand All @@ -114,12 +103,6 @@ func cmdDel(args *skel.CmdArgs) error {
return nil
}

func filterConf(conf types.IPAMConfig) types.IPAMConfig {
new := conf
new.EtcdPassword = "*********"
return new
}

// GetPodRef constructs the PodRef string from CNI arguments.
// It returns an empty string, if K8S_POD_NAMESPACE & K8S_POD_NAME arguments are not provided.
func getPodRef(args string) string {
Expand Down
Loading

0 comments on commit 428d2b3

Please sign in to comment.