From e2cac2a9279286ba44063a8536d7a8520fb32321 Mon Sep 17 00:00:00 2001 From: cannarelladev Date: Thu, 12 Oct 2023 15:35:19 +0200 Subject: [PATCH] Added grpc server, liqo credentials getter, fixed and improved resources and models --- apis/reservation/v1alpha1/contract_types.go | 7 +- .../reservation/v1alpha1/reservation_types.go | 3 + .../reservation/v1alpha1/transaction_types.go | 3 + .../v1alpha1/zz_generated.deepcopy.go | 6 +- cmd/rear-controller/main.go | 23 ++- .../reservation.fluidos.eu_contracts.yaml | 44 +++--- .../reservation.fluidos.eu_reservations.yaml | 6 + .../reservation.fluidos.eu_transactions.yaml | 5 + go.mod | 54 ++++--- go.sum | 149 +++++++++++------- pkg/rear-controller/gateway/provider.go | 9 +- pkg/rear-controller/gateway/utils.go | 46 ++++++ .../grpc/liqo-resource-manager.go | 132 ++++++++++++++++ pkg/rear-controller/grpc/service.go | 81 ++++++++++ pkg/utils/models/gateway.go | 1 + pkg/utils/models/reservation.go | 29 ++-- pkg/utils/parseutil/parseutil.go | 19 ++- pkg/utils/resourceforge/forge.go | 41 ++++- 18 files changed, 534 insertions(+), 124 deletions(-) create mode 100644 pkg/rear-controller/grpc/liqo-resource-manager.go create mode 100644 pkg/rear-controller/grpc/service.go diff --git a/apis/reservation/v1alpha1/contract_types.go b/apis/reservation/v1alpha1/contract_types.go index 8605515..7e2dd65 100644 --- a/apis/reservation/v1alpha1/contract_types.go +++ b/apis/reservation/v1alpha1/contract_types.go @@ -37,7 +37,7 @@ type ContractSpec struct { Flavour nodecorev1alpha1.Flavour `json:"flavour"` // TransactionID is the ID of the transaction that this contract is part of - TransactionID string `json:"transactionID,omitempty"` + TransactionID string `json:"transactionID"` // The partition represents the dimension of the resources sold/bought. // So it will reflect the dimension of the resources allocated on the remote cluster and reflected on the local virtual node. @@ -46,11 +46,14 @@ type ContractSpec struct { // This is the Node identity of the buyer FLUIDOS Node. Buyer nodecorev1alpha1.NodeIdentity `json:"buyer"` + // BuyerClusterID is the Liqo ClusterID used by the seller to search a contract and the related resources during the peering phase. + BuyerClusterID string `json:"buyerClusterID"` + // This is the Node identity of the seller FLUIDOS Node. Seller nodecorev1alpha1.NodeIdentity `json:"seller"` // This credentials will be used by the customer to connect and enstablish a peering with the seller FLUIDOS Node through Liqo. - Credentials *LiqoCredentials `json:"credentials,omitempty"` + SellerCredentials LiqoCredentials `json:"sellerCredentials"` // This is the expiration time of the contract. It can be empty if the contract is not time limited. ExpirationTime string `json:"expirationTime,omitempty"` diff --git a/apis/reservation/v1alpha1/reservation_types.go b/apis/reservation/v1alpha1/reservation_types.go index ab903bb..2c1b837 100644 --- a/apis/reservation/v1alpha1/reservation_types.go +++ b/apis/reservation/v1alpha1/reservation_types.go @@ -39,6 +39,9 @@ type ReservationSpec struct { // This is the Node identity of the buyer FLUIDOS Node. Buyer nodecorev1alpha1.NodeIdentity `json:"buyer"` + // BuyerClusterID is the Liqo ClusterID used by the seller to search a contract and the related resources during the peering phase. + BuyerClusterID string `json:"buyerClusterID"` + // This is the Node identity of the seller FLUIDOS Node. Seller nodecorev1alpha1.NodeIdentity `json:"seller"` diff --git a/apis/reservation/v1alpha1/transaction_types.go b/apis/reservation/v1alpha1/transaction_types.go index 231ffdc..dc26a29 100644 --- a/apis/reservation/v1alpha1/transaction_types.go +++ b/apis/reservation/v1alpha1/transaction_types.go @@ -27,6 +27,9 @@ type TransactionSpec struct { // Buyer is the buyer Identity of the Fluidos Node that is reserving the Flavour Buyer nodecorev1alpha1.NodeIdentity `json:"buyer"` + // ClusterID is the Liqo ClusterID of the Fluidos Node that is reserving the Flavour + ClusterID string `json:"clusterID"` + // Partition is the partition of the flavour that is being reserved Partition Partition `json:"partition,omitempty"` diff --git a/apis/reservation/v1alpha1/zz_generated.deepcopy.go b/apis/reservation/v1alpha1/zz_generated.deepcopy.go index 4973537..9a77e86 100644 --- a/apis/reservation/v1alpha1/zz_generated.deepcopy.go +++ b/apis/reservation/v1alpha1/zz_generated.deepcopy.go @@ -88,11 +88,7 @@ func (in *ContractSpec) DeepCopyInto(out *ContractSpec) { in.Partition.DeepCopyInto(&out.Partition) out.Buyer = in.Buyer out.Seller = in.Seller - if in.Credentials != nil { - in, out := &in.Credentials, &out.Credentials - *out = new(LiqoCredentials) - **out = **in - } + out.SellerCredentials = in.SellerCredentials if in.ExtraInformation != nil { in, out := &in.ExtraInformation, &out.ExtraInformation *out = make(map[string]string, len(*in)) diff --git a/cmd/rear-controller/main.go b/cmd/rear-controller/main.go index 177026a..fb1686d 100644 --- a/cmd/rear-controller/main.go +++ b/cmd/rear-controller/main.go @@ -41,6 +41,7 @@ import ( contractmanager "github.com/fluidos-project/node/pkg/rear-controller/contract-manager" discoverymanager "github.com/fluidos-project/node/pkg/rear-controller/discovery-manager" gateway "github.com/fluidos-project/node/pkg/rear-controller/gateway" + "github.com/fluidos-project/node/pkg/rear-controller/grpc" "github.com/fluidos-project/node/pkg/utils/flags" //+kubebuilder:scaffold:imports ) @@ -90,17 +91,30 @@ func main() { cache := mgr.GetCache() - indexFunc := func(obj client.Object) []string { + // Index the TransactionID field of the Contract CRD + indexFuncTransaction := func(obj client.Object) []string { contract := obj.(*reservationv1alpha1.Contract) return []string{contract.Spec.TransactionID} } - if err := cache.IndexField(context.Background(), &reservationv1alpha1.Contract{}, "spec.transactionID", indexFunc); err != nil { + // Index the ClusterID field of the Contract CRD + indexFuncClusterID := func(obj client.Object) []string { + contract := obj.(*reservationv1alpha1.Contract) + return []string{contract.Spec.BuyerClusterID} + } + + if err := cache.IndexField(context.Background(), &reservationv1alpha1.Contract{}, "spec.transactionID", indexFuncTransaction); err != nil { setupLog.Error(err, "unable to create index for field", "field", "spec.transactionID") os.Exit(1) } + if err := cache.IndexField(context.Background(), &reservationv1alpha1.Contract{}, "spec.buyerClusterID", indexFuncClusterID); err != nil { + setupLog.Error(err, "unable to create index for field", "field", "spec.buyerClusterID") + os.Exit(1) + } + gw := gateway.NewGateway(mgr.GetClient()) + grpcServer := grpc.NewGrpcServer(mgr.GetClient()) if err = (&discoverymanager.DiscoveryReconciler{ Client: mgr.GetClient(), @@ -140,6 +154,11 @@ func main() { gw.StartHttpServer() }() + // Start the REAR GRPC server + go func() { + grpcServer.Start() + }() + // TODO: Uncomment this when the webhook is ready. For now it does not work (Ale) // pcv := discoverymanager.NewPCValidator(mgr.GetClient()) diff --git a/deployments/node/crds/reservation.fluidos.eu_contracts.yaml b/deployments/node/crds/reservation.fluidos.eu_contracts.yaml index 52e0839..2087007 100644 --- a/deployments/node/crds/reservation.fluidos.eu_contracts.yaml +++ b/deployments/node/crds/reservation.fluidos.eu_contracts.yaml @@ -48,24 +48,11 @@ spec: - ip - nodeID type: object - credentials: - description: This credentials will be used by the customer to connect - and enstablish a peering with the seller FLUIDOS Node through Liqo. - properties: - clusterID: - type: string - clusterName: - type: string - endpoint: - type: string - token: - type: string - required: - - clusterID - - clusterName - - endpoint - - token - type: object + buyerClusterID: + description: BuyerClusterID is the Liqo ClusterID used by the seller + to search a contract and the related resources during the peering + phase. + type: string expirationTime: description: This is the expiration time of the contract. It can be empty if the contract is not time limited. @@ -380,14 +367,35 @@ spec: - ip - nodeID type: object + sellerCredentials: + description: This credentials will be used by the customer to connect + and enstablish a peering with the seller FLUIDOS Node through Liqo. + properties: + clusterID: + type: string + clusterName: + type: string + endpoint: + type: string + token: + type: string + required: + - clusterID + - clusterName + - endpoint + - token + type: object transactionID: description: TransactionID is the ID of the transaction that this contract is part of type: string required: - buyer + - buyerClusterID - flavour - seller + - sellerCredentials + - transactionID type: object status: description: ContractStatus defines the observed state of Contract diff --git a/deployments/node/crds/reservation.fluidos.eu_reservations.yaml b/deployments/node/crds/reservation.fluidos.eu_reservations.yaml index 0e84480..42644c5 100644 --- a/deployments/node/crds/reservation.fluidos.eu_reservations.yaml +++ b/deployments/node/crds/reservation.fluidos.eu_reservations.yaml @@ -86,6 +86,11 @@ spec: - ip - nodeID type: object + buyerClusterID: + description: BuyerClusterID is the Liqo ClusterID used by the seller + to search a contract and the related resources during the peering + phase. + type: string partition: description: Parition is the partition of the flavour that is being reserved @@ -166,6 +171,7 @@ spec: type: string required: - buyer + - buyerClusterID - seller - solverID type: object diff --git a/deployments/node/crds/reservation.fluidos.eu_transactions.yaml b/deployments/node/crds/reservation.fluidos.eu_transactions.yaml index 8f56522..ec04673 100644 --- a/deployments/node/crds/reservation.fluidos.eu_transactions.yaml +++ b/deployments/node/crds/reservation.fluidos.eu_transactions.yaml @@ -49,6 +49,10 @@ spec: - ip - nodeID type: object + clusterID: + description: ClusterID is the Liqo ClusterID of the Fluidos Node that + is reserving the Flavour + type: string flavourID: description: FlavourID is the ID of the flavour that is being reserved type: string @@ -99,6 +103,7 @@ spec: type: string required: - buyer + - clusterID - flavourID type: object status: diff --git a/go.mod b/go.mod index a8e2b09..acfc961 100644 --- a/go.mod +++ b/go.mod @@ -4,19 +4,22 @@ go 1.21.0 require ( github.com/gorilla/mux v1.8.0 - k8s.io/api v0.28.0 - k8s.io/apimachinery v0.28.0 - k8s.io/client-go v0.28.0 + github.com/liqotech/liqo v0.9.4 + google.golang.org/grpc v1.59.0-dev + k8s.io/api v0.28.2 + k8s.io/apimachinery v0.28.2 + k8s.io/client-go v0.28.2 k8s.io/klog/v2 v2.100.1 - k8s.io/metrics v0.28.0 - sigs.k8s.io/controller-runtime v0.15.0 + k8s.io/metrics v0.28.2 + sigs.k8s.io/controller-runtime v0.15.1 ) require ( + github.com/aws/aws-sdk-go v1.44.213 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.9.0 // indirect + github.com/emicklei/go-restful/v3 v3.10.1 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-logr/logr v1.2.4 // indirect @@ -30,8 +33,9 @@ require ( github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/imdario/mergo v0.3.12 // indirect + github.com/google/uuid v1.3.1 // indirect + github.com/imdario/mergo v0.3.15 // indirect + github.com/jmespath/go-jmespath v0.4.0 // 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 @@ -40,29 +44,35 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.15.1 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.6.0 // indirect + github.com/virtual-kubelet/virtual-kubelet v1.10.0 // indirect + go.uber.org/atomic v1.10.0 // indirect + go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/net v0.13.0 // indirect - golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sys v0.10.0 // indirect - golang.org/x/term v0.10.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/crypto v0.13.0 // indirect + golang.org/x/exp v0.0.0-20221114191408-850992195362 // indirect + golang.org/x/net v0.15.0 // indirect + golang.org/x/oauth2 v0.10.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect - gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect + golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b // indirect + gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.30.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/protobuf v1.31.0 // 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/apiextensions-apiserver v0.27.2 // indirect - k8s.io/component-base v0.27.2 // indirect + k8s.io/apiextensions-apiserver v0.28.2 // indirect + k8s.io/component-base v0.28.2 // indirect k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect + k8s.io/kubectl v0.28.2 // indirect k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect diff --git a/go.sum b/go.sum index 5eba16c..32844e6 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/aws/aws-sdk-go v1.44.213 h1:WahquyWs7cQdz0vpDVWyWETEemgSoORx0PbWL9oz2WA= +github.com/aws/aws-sdk-go v1.44.213/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -8,8 +10,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE= -github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= +github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= @@ -46,15 +48,19 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/pprof v0.0.0-20230323073829-e72429f035bd h1:r8yyd+DJDmsUhGrRBxH5Pj7KeFK5l+Y3FsgT8keqKtk= +github.com/google/pprof v0.0.0-20230323073829-e72429f035bd/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -69,10 +75,14 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/liqotech/liqo v0.9.4 h1:LwKDSO/0E5uCXd6vfxoEQ59bFVJ1jb1JfR1AEB8jjK8= +github.com/liqotech/liqo v0.9.4/go.mod h1:SYbULfgspXacnmyIY7PLbYtHsUnXozRbCvPVGf65N/w= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA= +github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -80,23 +90,23 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= -github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= -github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU= -github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4= +github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI= +github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= -github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -109,60 +119,85 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/virtual-kubelet/virtual-kubelet v1.10.0 h1:eV/mFFqThOJLz7Gjn1Ev8LchanGKGA2qZlsW6wipb4g= +github.com/virtual-kubelet/virtual-kubelet v1.10.0/go.mod h1:7Pvdei1p82C9uWS1VzLrnXbHTwQcGBoqShahChpacgI= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/exp v0.0.0-20221114191408-850992195362 h1:NoHlPRbyl1VFI6FjwHtPQCN7wAMXI6cKcqrmXhOOfBQ= +golang.org/x/exp v0.0.0-20221114191408-850992195362/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY= -golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= -golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= -golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= +golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -171,20 +206,27 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= -golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gomodules.xyz/jsonpatch/v2 v2.3.0 h1:8NFhfS6gzxNqjLIYnZxg319wZ5Qjnx4m/CcX+Klzazc= -gomodules.xyz/jsonpatch/v2 v2.3.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= +golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b h1:9JncmKXcUwE918my+H6xmjBdhK2jM/UTUNXxhRG1BAk= +golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b/go.mod h1:yp4gl6zOlnDGOZeWeDfMwQcsdOIQnMdhuPx9mwwWBL4= +gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= +gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/grpc v1.59.0-dev h1:kGGaLrcUHIrrkQ82zIKBy3ERlPAO3DpVN3gbA8NShgg= +google.golang.org/grpc v1.59.0-dev/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -192,32 +234,33 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.28.0 h1:3j3VPWmN9tTDI68NETBWlDiA9qOiGJ7sdKeufehBYsM= -k8s.io/api v0.28.0/go.mod h1:0l8NZJzB0i/etuWnIXcwfIv+xnDOhL3lLW919AWYDuY= -k8s.io/apiextensions-apiserver v0.27.2 h1:iwhyoeS4xj9Y7v8YExhUwbVuBhMr3Q4bd/laClBV6Bo= -k8s.io/apiextensions-apiserver v0.27.2/go.mod h1:Oz9UdvGguL3ULgRdY9QMUzL2RZImotgxvGjdWRq6ZXQ= -k8s.io/apimachinery v0.28.0 h1:ScHS2AG16UlYWk63r46oU3D5y54T53cVI5mMJwwqFNA= -k8s.io/apimachinery v0.28.0/go.mod h1:X0xh/chESs2hP9koe+SdIAcXWcQ+RM5hy0ZynB+yEvw= -k8s.io/client-go v0.28.0 h1:ebcPRDZsCjpj62+cMk1eGNX1QkMdRmQ6lmz5BLoFWeM= -k8s.io/client-go v0.28.0/go.mod h1:0Asy9Xt3U98RypWJmU1ZrRAGKhP6NqDPmptlAzK2kMc= -k8s.io/component-base v0.27.2 h1:neju+7s/r5O4x4/txeUONNTS9r1HsPbyoPBAtHsDCpo= -k8s.io/component-base v0.27.2/go.mod h1:5UPk7EjfgrfgRIuDBFtsEFAe4DAvP3U+M8RTzoSJkpo= +k8s.io/api v0.28.2 h1:9mpl5mOb6vXZvqbQmankOfPIGiudghwCoLl1EYfUZbw= +k8s.io/api v0.28.2/go.mod h1:RVnJBsjU8tcMq7C3iaRSGMeaKt2TWEUXcpIt/90fjEg= +k8s.io/apiextensions-apiserver v0.28.2 h1:J6/QRWIKV2/HwBhHRVITMLYoypCoPY1ftigDM0Kn+QU= +k8s.io/apiextensions-apiserver v0.28.2/go.mod h1:5tnkxLGa9nefefYzWuAlWZ7RZYuN/765Au8cWLA6SRg= +k8s.io/apimachinery v0.28.2 h1:KCOJLrc6gu+wV1BYgwik4AF4vXOlVJPdiqn0yAWWwXQ= +k8s.io/apimachinery v0.28.2/go.mod h1:RdzF87y/ngqk9H4z3EL2Rppv5jj95vGS/HaFXrLDApU= +k8s.io/client-go v0.28.2 h1:DNoYI1vGq0slMBN/SWKMZMw0Rq+0EQW6/AK4v9+3VeY= +k8s.io/client-go v0.28.2/go.mod h1:sMkApowspLuc7omj1FOSUxSoqjr+d5Q0Yc0LOFnYFJY= +k8s.io/component-base v0.28.2 h1:Yc1yU+6AQSlpJZyvehm/NkJBII72rzlEsd6MkBQ+G0E= +k8s.io/component-base v0.28.2/go.mod h1:4IuQPQviQCg3du4si8GpMrhAIegxpsgPngPRR/zWpzc= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= -k8s.io/metrics v0.28.0 h1:rO+zfTT2A5GvCdRD44vFAQgdz8Sa6OMsNYkEGpBQz0k= -k8s.io/metrics v0.28.0/go.mod h1:0RSSFOwf1qlDU54bLMDEDa81cz02mNlG4mxitIRsQCs= +k8s.io/kubectl v0.28.2 h1:fOWOtU6S0smdNjG1PB9WFbqEIMlkzU5ahyHkc7ESHgM= +k8s.io/kubectl v0.28.2/go.mod h1:6EQWTPySF1fn7yKoQZHYf9TPwIl2AygHEcJoxFekr64= +k8s.io/metrics v0.28.2 h1:Z/oMk5SmiT/Ji1SaWOPfW2l9W831BLO9/XxDq9iS3ak= +k8s.io/metrics v0.28.2/go.mod h1:QTIIdjMrq+KodO+rmp6R9Pr1LZO8kTArNtkWoQXw0sw= k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.15.0 h1:ML+5Adt3qZnMSYxZ7gAverBLNPSMQEibtzAgp0UPojU= -sigs.k8s.io/controller-runtime v0.15.0/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= +sigs.k8s.io/controller-runtime v0.15.1 h1:9UvgKD4ZJGcj24vefUFgZFP3xej/3igL9BsOUTb/+4c= +sigs.k8s.io/controller-runtime v0.15.1/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= diff --git a/pkg/rear-controller/gateway/provider.go b/pkg/rear-controller/gateway/provider.go index 3bb0e37..04e9249 100644 --- a/pkg/rear-controller/gateway/provider.go +++ b/pkg/rear-controller/gateway/provider.go @@ -308,9 +308,16 @@ func (g *Gateway) purchaseFlavour(w http.ResponseWriter, r *http.Request) { return } + liqoCredentials, err := GetLiqoCredentials(context.Background(), g.client) + if err != nil { + klog.Errorf("Error getting Liqo Credentials: %s", err) + http.Error(w, "Error getting Liqo Credentials", http.StatusInternalServerError) + return + } + // Create a new contract klog.Infof("Creating a new contract...") - contract = *resourceforge.ForgeContract(*flavourSold, transaction) + contract = *resourceforge.ForgeContract(*flavourSold, transaction, liqoCredentials) err = g.client.Create(context.Background(), &contract) if err != nil { klog.Errorf("Error creating the Contract: %s", err) diff --git a/pkg/rear-controller/gateway/utils.go b/pkg/rear-controller/gateway/utils.go index 9f1f188..a1d1827 100644 --- a/pkg/rear-controller/gateway/utils.go +++ b/pkg/rear-controller/gateway/utils.go @@ -15,11 +15,19 @@ package gateway import ( + "context" "encoding/json" "fmt" "net/http" + "sigs.k8s.io/controller-runtime/pkg/client" + + reservationsv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" "github.com/fluidos-project/node/pkg/utils/models" + + "github.com/liqotech/liqo/pkg/auth" + "github.com/liqotech/liqo/pkg/utils" + foreigncluster "github.com/liqotech/liqo/pkg/utils/foreignCluster" ) // buildSelector builds a selector from a request body @@ -79,3 +87,41 @@ func encodeResponse(w http.ResponseWriter, data interface{}) { w.WriteHeader(http.StatusOK) w.Write(resp) } + +const ( + authTokenSecretNamePrefix = "remote-token-" + + tokenKey = "token" + + liqoNamespace = "liqo" +) + +func GetLiqoCredentials(ctx context.Context, cl client.Client) (*reservationsv1alpha1.LiqoCredentials, error) { + localToken, err := auth.GetToken(ctx, cl, liqoNamespace) + if err != nil { + return nil, err + } + + clusterIdentity, err := utils.GetClusterIdentityWithControllerClient(ctx, cl, liqoNamespace) + if err != nil { + return nil, err + } + + authEP, err := foreigncluster.GetHomeAuthURL(ctx, cl, liqoNamespace) + if err != nil { + return nil, err + } + + // If the local cluster has not a cluster name, we print the use the local clusterID to not leave this field empty. + // This can be changed by the user when pasting this value in a remote cluster. + if clusterIdentity.ClusterName == "" { + clusterIdentity.ClusterName = clusterIdentity.ClusterID + } + + return &reservationsv1alpha1.LiqoCredentials{ + ClusterName: clusterIdentity.ClusterName, + ClusterID: clusterIdentity.ClusterID, + Endpoint: authEP, + Token: localToken, + }, nil +} diff --git a/pkg/rear-controller/grpc/liqo-resource-manager.go b/pkg/rear-controller/grpc/liqo-resource-manager.go new file mode 100644 index 0000000..d5372d2 --- /dev/null +++ b/pkg/rear-controller/grpc/liqo-resource-manager.go @@ -0,0 +1,132 @@ +// Copyright 2022-2023 FLUIDOS Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package grpc + +import ( + context "context" + "fmt" + "log" + "net" + + grpc "google.golang.org/grpc" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/client" + + resourcemonitors "github.com/liqotech/liqo/pkg/liqo-controller-manager/resource-request-controller/resource-monitors" + + "github.com/fluidos-project/node/pkg/utils/flags" +) + +type grpcServer struct { + Server *grpc.Server + client client.Client + //contractHandler connector.ContractHandler + stream resourcemonitors.ResourceReader_SubscribeServer + resourcemonitors.ResourceReaderServer +} + +func NewGrpcServer(cl client.Client) *grpcServer { + return &grpcServer{ + Server: grpc.NewServer(), + client: cl, + } +} + +func (s *grpcServer) Start() { + grpcUrl := ":" + flags.GRPC_PORT + + // gRPC Configuration + klog.Info("Configuring gRPC Server") + lis, err := net.Listen("tcp", grpcUrl) + if err != nil { + log.Fatalf("gRPC failed to listen: %v", err) + } + + klog.Infof("gRPC Server Listening on %s", grpcUrl) + // gRPC Server start listener + if err := s.Server.Serve(lis); err != nil { + log.Fatalf("gRPC failed to serve: %v", err) + } +} + +/* func (s *grpcServer) RegisterContractHandler(ch connector.ContractHandler) { + s.contractHandler = ch +} */ + +func (s *grpcServer) ReadResources(ctx context.Context, req *resourcemonitors.ClusterIdentity) (*resourcemonitors.ResourceList, error) { + readResponse := &resourcemonitors.ResourceList{Resources: map[string]*resource.Quantity{}} + + log.Printf("ReadResource for clusterID %s", req.ClusterID) + resources, err := s.GetOfferResourcesByClusterID(req.ClusterID) + if err != nil { + // TODO: maybe should be resurned an empty resource list + return nil, err + } + + log.Printf("Retrieved resources for clusterID %s: %v", req.ClusterID, resources) + for key, value := range *resources { + readResponse.Resources[key.String()] = &value + } + + return readResponse, nil +} + +func (s *grpcServer) Subscribe(req *resourcemonitors.Empty, srv resourcemonitors.ResourceReader_SubscribeServer) error { + // Implement here your logic + s.stream = srv + ctx := srv.Context() + + fmt.Println("Subscribe") + + s.NotifyChange(context.Background(), &resourcemonitors.ClusterIdentity{ClusterID: resourcemonitors.AllClusterIDs}) + + for { + select { + case <-ctx.Done(): + klog.Info("liqo controller manager disconnected") + return nil + } + } +} + +func (s *grpcServer) NotifyChange(ctx context.Context, req *resourcemonitors.ClusterIdentity) error { + // Implement here your logic + if s.stream == nil { + return fmt.Errorf("you must first subscribe a controller manager to notify a change") + } else { + s.stream.Send(req) + } + return nil +} + +func (s *grpcServer) RemoveCluster(ctx context.Context, req *resourcemonitors.ClusterIdentity) (*resourcemonitors.Empty, error) { + // Implement here your logic + return nil, fmt.Errorf("Not implemented") +} + +func (s *grpcServer) GetOfferResourcesByClusterID(clusterID string) (*corev1.ResourceList, error) { + log.Printf("Getting resources for cluster ID: %s", clusterID) + resources, err := getContractResourcesByClusterID(s.client, clusterID) + if err != nil { + return nil, err + } + return resources, nil +} + +func (s *grpcServer) UpdatePeeringOffer(clusterID string) { + s.NotifyChange(context.Background(), &resourcemonitors.ClusterIdentity{ClusterID: clusterID}) +} diff --git a/pkg/rear-controller/grpc/service.go b/pkg/rear-controller/grpc/service.go new file mode 100644 index 0000000..25d1a83 --- /dev/null +++ b/pkg/rear-controller/grpc/service.go @@ -0,0 +1,81 @@ +// Copyright 2022-2023 FLUIDOS Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package grpc + +import ( + "context" + "fmt" + + corev1 "k8s.io/api/core/v1" + "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/client" + + reservationv1alpha1 "github.com/fluidos-project/node/apis/reservation/v1alpha1" +) + +func getContractResourcesByClusterID(cl client.Client, clusterID string) (*corev1.ResourceList, error) { + var contracts reservationv1alpha1.ContractList + + if err := cl.List(context.Background(), &contracts, client.MatchingFields{"spec.clusterID": clusterID}); err != nil { + if client.IgnoreNotFound(err) != nil { + klog.Errorf("Error when listing Contracts: %s", err) + return nil, err + } + } + + if len(contracts.Items) == 0 { + klog.Errorf("No contracts found for cluster %s", clusterID) + return nil, fmt.Errorf("No contracts found for cluster %s", clusterID) + } + + if len(contracts.Items) > 1 { + resources := multipleContractLogic(contracts.Items) + return resources, nil + } + + contract := contracts.Items[0] + + return mapQuantityToResourceList(contract.Spec.Partition), nil +} + +func multipleContractLogic(contracts []reservationv1alpha1.Contract) *corev1.ResourceList { + resources := &corev1.ResourceList{} + for _, contract := range contracts { + resources = addResources(*resources, contract.Spec.Partition) + } + return resources +} + +// This function adds the resources of a contract to the existing resourceList +func addResources(resources corev1.ResourceList, partition reservationv1alpha1.Partition) *corev1.ResourceList { + for key, value := range *mapQuantityToResourceList(partition) { + if prevRes, ok := resources[key]; !ok { + resources[key] = value + } else { + prevRes.Add(value) + resources[key] = prevRes + } + } + return &resources +} + +func mapQuantityToResourceList(partition reservationv1alpha1.Partition) *corev1.ResourceList { + return &corev1.ResourceList{ + corev1.ResourceCPU: partition.Cpu, + corev1.ResourceMemory: partition.Memory, + corev1.ResourceEphemeralStorage: partition.EphemeralStorage, + corev1.ResourceStorage: partition.Storage, + } +} diff --git a/pkg/utils/models/gateway.go b/pkg/utils/models/gateway.go index 8146ca7..32df4ff 100644 --- a/pkg/utils/models/gateway.go +++ b/pkg/utils/models/gateway.go @@ -29,5 +29,6 @@ type ResponsePurchase struct { type ReserveRequest struct { FlavourID string `json:"flavourID"` Buyer NodeIdentity `json:"buyerID"` + ClusterID string `json:"clusterID"` Partition Partition `json:"partition"` } diff --git a/pkg/utils/models/reservation.go b/pkg/utils/models/reservation.go index cfc4fb8..fcfff55 100644 --- a/pkg/utils/models/reservation.go +++ b/pkg/utils/models/reservation.go @@ -30,17 +30,28 @@ type Transaction struct { FlavourID string `json:"flavourID"` Partition Partition `json:"partition"` Buyer NodeIdentity `json:"buyer"` - StartTime string `json:"startTime,omitempty"` + ClusterID string `json:"clusterID"` + StartTime string `json:"startTime"` } // Contract represents a Contract object with its characteristics type Contract struct { - ContractID string `json:"contractID"` - TransactionID string `json:"transactionID"` - Flavour Flavour `json:"flavour"` - Buyer NodeIdentity `json:"buyerID"` - Seller NodeIdentity `json:"seller"` - ExpirationTime string `json:"expirationTime,omitempty"` - ExtraInformation map[string]string `json:"extraInformation,omitempty"` - Partition Partition `json:"partition,omitempty"` + ContractID string `json:"contractID"` + TransactionID string `json:"transactionID"` + Flavour Flavour `json:"flavour"` + Buyer NodeIdentity `json:"buyerID"` + BuyerClusterID string `json:"buyerClusterID"` + Seller NodeIdentity `json:"seller"` + SellerCredentials LiqoCredentials `json:"sellerCredentials"` + ExpirationTime string `json:"expirationTime,omitempty"` + ExtraInformation map[string]string `json:"extraInformation,omitempty"` + Partition Partition `json:"partition,omitempty"` +} + +// LiqoCredentials contains the credentials of a Liqo cluster to enstablish a peering. +type LiqoCredentials struct { + ClusterID string `json:"clusterID"` + ClusterName string `json:"clusterName"` + Token string `json:"token"` + Endpoint string `json:"endpoint"` } diff --git a/pkg/utils/parseutil/parseutil.go b/pkg/utils/parseutil/parseutil.go index c24f72b..a453ba3 100644 --- a/pkg/utils/parseutil/parseutil.go +++ b/pkg/utils/parseutil/parseutil.go @@ -181,12 +181,19 @@ func ParseFlavour(flavour nodecorev1alpha1.Flavour) models.Flavour { // ForgeContractObject creates a Contract Object func ParseContract(contract *reservationv1alpha1.Contract) models.Contract { return models.Contract{ - ContractID: contract.Name, - Flavour: ParseFlavour(contract.Spec.Flavour), - Buyer: ParseNodeIdentity(contract.Spec.Buyer), - TransactionID: contract.Spec.TransactionID, - Partition: ParsePartition(contract.Spec.Partition), - Seller: ParseNodeIdentity(contract.Spec.Seller), + ContractID: contract.Name, + Flavour: ParseFlavour(contract.Spec.Flavour), + Buyer: ParseNodeIdentity(contract.Spec.Buyer), + BuyerClusterID: contract.Spec.BuyerClusterID, + TransactionID: contract.Spec.TransactionID, + Partition: ParsePartition(contract.Spec.Partition), + Seller: ParseNodeIdentity(contract.Spec.Seller), + SellerCredentials: models.LiqoCredentials{ + ClusterID: contract.Spec.SellerCredentials.ClusterID, + ClusterName: contract.Spec.SellerCredentials.ClusterName, + Token: contract.Spec.SellerCredentials.Token, + Endpoint: contract.Spec.SellerCredentials.Endpoint, + }, } } diff --git a/pkg/utils/resourceforge/forge.go b/pkg/utils/resourceforge/forge.go index 6441206..cca9411 100644 --- a/pkg/utils/resourceforge/forge.go +++ b/pkg/utils/resourceforge/forge.go @@ -99,7 +99,7 @@ func ForgeReservation(peeringCandidate advertisementv1alpha1.PeeringCandidate, p } // ForgeContract creates a Contract CR -func ForgeContract(flavour nodecorev1alpha1.Flavour, transaction models.Transaction) *reservationv1alpha1.Contract { +func ForgeContract(flavour nodecorev1alpha1.Flavour, transaction models.Transaction, lc *reservationv1alpha1.LiqoCredentials) *reservationv1alpha1.Contract { return &reservationv1alpha1.Contract{ ObjectMeta: metav1.ObjectMeta{ Name: namings.ForgeContractName(flavour.Name), @@ -112,10 +112,12 @@ func ForgeContract(flavour nodecorev1alpha1.Flavour, transaction models.Transact IP: transaction.Buyer.IP, NodeID: transaction.Buyer.NodeID, }, - Seller: flavour.Spec.Owner, - TransactionID: transaction.TransactionID, - Partition: parseutil.ParsePartitionFromObj(transaction.Partition), - ExpirationTime: time.Now().Add(flags.EXPIRATION_CONTRACT).Format(time.RFC3339), + BuyerClusterID: transaction.ClusterID, + Seller: flavour.Spec.Owner, + SellerCredentials: *lc, + TransactionID: transaction.TransactionID, + Partition: parseutil.ParsePartitionFromObj(transaction.Partition), + ExpirationTime: time.Now().Add(flags.EXPIRATION_CONTRACT).Format(time.RFC3339), }, Status: reservationv1alpha1.ContractStatus{ Phase: nodecorev1alpha1.PhaseStatus{ @@ -128,7 +130,6 @@ func ForgeContract(flavour nodecorev1alpha1.Flavour, transaction models.Transact // ForgeFlavourFromMetrics creates a new flavour custom resource from the metrics of the node func ForgeFlavourFromMetrics(node models.NodeInfo, ni nodecorev1alpha1.NodeIdentity) (flavour *nodecorev1alpha1.Flavour) { - return &nodecorev1alpha1.Flavour{ ObjectMeta: metav1.ObjectMeta{ Name: namings.ForgeFlavourName(node.UID, ni.Domain), @@ -176,6 +177,7 @@ func ForgeTransactionObj(ID string, req models.ReserveRequest) models.Transactio return models.Transaction{ TransactionID: ID, Buyer: req.Buyer, + ClusterID: req.ClusterID, FlavourID: req.FlavourID, Partition: req.Partition, StartTime: tools.GetTimeNow(), @@ -187,10 +189,23 @@ func ForgeContractObj(contract *reservationv1alpha1.Contract) models.Contract { ContractID: contract.Name, Flavour: parseutil.ParseFlavour(contract.Spec.Flavour), Buyer: parseutil.ParseNodeIdentity(contract.Spec.Buyer), + BuyerClusterID: contract.Spec.BuyerClusterID, Seller: parseutil.ParseNodeIdentity(contract.Spec.Seller), + SellerCredentials: models.LiqoCredentials{ + ClusterID: contract.Spec.SellerCredentials.ClusterID, + ClusterName: contract.Spec.SellerCredentials.ClusterName, + Token: contract.Spec.SellerCredentials.Token, + Endpoint: contract.Spec.SellerCredentials.Endpoint, + }, Partition: parseutil.ParsePartition(contract.Spec.Partition), TransactionID: contract.Spec.TransactionID, ExpirationTime: contract.Spec.ExpirationTime, + ExtraInformation: func() map[string]string { + if contract.Spec.ExtraInformation != nil { + return contract.Spec.ExtraInformation + } + return nil + }(), } } @@ -216,14 +231,27 @@ func ForgeContractFromObj(contract models.Contract) *reservationv1alpha1.Contrac IP: contract.Buyer.IP, NodeID: contract.Buyer.NodeID, }, + BuyerClusterID: contract.BuyerClusterID, Seller: nodecorev1alpha1.NodeIdentity{ NodeID: contract.Seller.NodeID, IP: contract.Seller.IP, Domain: contract.Seller.Domain, }, + SellerCredentials: reservationv1alpha1.LiqoCredentials{ + ClusterID: contract.SellerCredentials.ClusterID, + ClusterName: contract.SellerCredentials.ClusterName, + Token: contract.SellerCredentials.Token, + Endpoint: contract.SellerCredentials.Endpoint, + }, TransactionID: contract.TransactionID, Partition: parseutil.ParsePartitionFromObj(contract.Partition), ExpirationTime: contract.ExpirationTime, + ExtraInformation: func() map[string]string { + if contract.ExtraInformation != nil { + return contract.ExtraInformation + } + return nil + }(), }, Status: reservationv1alpha1.ContractStatus{ Phase: nodecorev1alpha1.PhaseStatus{ @@ -249,6 +277,7 @@ func ForgeTransactionFromObj(reservation *models.Transaction) *reservationv1alph IP: reservation.Buyer.IP, NodeID: reservation.Buyer.NodeID, }, + ClusterID: reservation.ClusterID, Partition: parseutil.ParsePartitionFromObj(reservation.Partition), }, }