Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Use the AzureResource Informer; Refactor for clarity #20

Merged
merged 26 commits into from
Jan 8, 2020

Conversation

draychev
Copy link
Contributor

@draychev draychev commented Jan 3, 2020

Sincere apologies for the large PR. I prefer small, atomic PRs; this is not it.
The goal here is to make one last PR to clean-up the move from a previous repo. Also change the demo so it uses AzureResource CRD.

Changes in this PR

  • newcomer to the code base is GetComputeIDForService() -- this is a function, which when given a service name, determines where the endpoints forming this service are (what clusters, clouds, compute providers) -- this leverages the new AzureResource CRD and completes the demo using Service -> AzureResource as discussed in Create 'Service' CRD to register and reference k8s and non-k8s compute resources servicemeshinterface/smi-spec#67 (comment)
  • start the informers for the AzureResource and figure out what Azure URI to query ARM for from Service --> AzureResource match based on labels
  • No need to pass AZURE_RESOURCE_GROUP around - this is in the AzureResource CRD
  • gRPC tools moved to pkg/utils
  • The cmd/eds/clients.go, which had the setupClients function, was simplified and merged into cmd/eds/eds.go
  • both eds and sds CLI tools get port arg, with the appropriate default (addresses a request by @vramakrishnan in mesh: Adding mesh.provider types enum #16)
  • added minimal syscall handlers
  • added sample AzureResource custom k8s resource
  • moved run-eds.sh and run-sds.sh into ./scripts/ (demo script adjustments if necessary will follow shortly)
  • added a periodic job running every 5 seconds. This is very short term tool to help w/ development
  • added a mutex to ServiceCatalog to prepare this for concurrent updates
  • computeProviders is now a list (no longer a map) -- no need for Compute Provider enum (previous PR closed)
  • tweaked some of the interfaces -- PLEASE NOTE that Go interfaces are discussed separately here: rfc: Interfaces #22 -- the PR here does NOT intend to improve interfaces.
  • the Kubernetes compute provider and the MeshSpec are now 2 separate objects (used to be the same implementing 2 interfaces) -- for clarity - easier to comprehend

Interfaces Design Doc

Proper Interfaces design will be done via the following Design Doc (in the shape of a PR to facilitate discussion): #22

@draychev draychev added the wip Work-in-Progress label Jan 3, 2020
@draychev draychev force-pushed the draychev/use-azure-resource-4 branch from dfe86e4 to 62f54fc Compare January 3, 2020 21:10
@@ -2,6 +2,5 @@

export K8S_NAMESPACE=smc
export AZURE_SUBSCRIPTION=abc
export AZURE_RESOURCE_GROUP=rg
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need AZURE_RESOURCE_GROUP - the subscription UUID is now available in the AzureResource CRD

@@ -1,58 +0,0 @@
package main
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cmd/eds/clients.go had the setupClients function, which is now simplified and part of cmd/eds/eds.go

@@ -34,10 +35,16 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

grpcServer, lis := cmd.NewGrpc(serverType, port)
grpcServer, lis := utils.NewGrpc(serverType, *port)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @vramakrishnan requested - we moved the gRPC tools in pkg/utils

Comment on lines +43 to +47
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
<-sigChan

glog.Info("Goodbye!")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syscall handling block here is a bit of a noop at the moment. Reasons for putting it:
a) symmetry with eds.go
b) we are going to need this once proper integrations w/ a certificate management system(s) is implemented

servicesCache map[mesh.ServiceName][]mesh.IP
computeProviders map[string]mesh.ComputeProviderI
meshSpecProvider mesh.SpecI
computeProviders []mesh.ComputeProviderI
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of ComputeProviders (naming is discussed elsewhere) is now just a list. No need to categorize them in a map.

glog.Info("[EDS] Create NewEDSServer...")
return &EDS{
ctx: ctx,
catalog: catalog,
computeProviders: computeProviders,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing computeProviders - this should be an implementation detail of the catalog
There is a separate design doc / PR where this is discussed.

Run(stopCh <-chan struct{}) error
// Retrieve the IP addresses comprising the ServiceName.
GetIPs(ServiceName) []IP
GetID() string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding GetID() here -- although this is officially debated in another PR / design doc and will most likely change once the design has settled.

@@ -1,14 +1,13 @@
package cmd
package utils
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving gRPC to the utils pkg

cmd/eds/eds.go Outdated Show resolved Hide resolved
cmd/eds/eds.go Show resolved Hide resolved
pkg/catalog/catalog.go Outdated Show resolved Hide resolved
@draychev
Copy link
Contributor Author

draychev commented Jan 8, 2020

@snehachhabria thanks for the review!
I addressed the comments you left - could you PTAL!

Comment on lines +115 to +118
type kv struct {
k string
v string
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be renamed as KeyValue struct, key string and values string respectively ?

@@ -31,6 +31,9 @@ const (

maxAuthRetryCount = 10
retryPause = 10 * time.Second

azureProvidername = "Azure"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit : casing

@snehachhabria snehachhabria self-requested a review January 8, 2020 21:27
Copy link
Contributor

@snehachhabria snehachhabria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@draychev the changes LGTM

@draychev draychev merged commit 612802a into master Jan 8, 2020
@draychev draychev deleted the draychev/use-azure-resource-4 branch January 15, 2020 23:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants