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

Add support for local machine ID #91

Merged
merged 11 commits into from
Nov 20, 2023
Merged

Add support for local machine ID #91

merged 11 commits into from
Nov 20, 2023

Conversation

daniel-de-vera
Copy link
Contributor

Copy link
Member

@scott-cotton scott-cotton left a comment

Choose a reason for hiding this comment

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

started the review.

Some comments/questions:

  • Should we remove the api related stuff from internal/config/locald.go?
  • Should we remove the grpc/go-sdk model conversions?
  • Should we detect operator version and error out on old operator appropriately (since local is beta)?

@daniel-de-vera
Copy link
Contributor Author

started the review.

Some comments/questions:

  • Should we remove the api related stuff from internal/config/locald.go?

Not sure, I understand what you mean by that, can you expand?

  • Should we remove the grpc/go-sdk model conversions?

Do you mean across the whole CLI? (what would look like a massive change to me).

  • Should we detect operator version and error out on old operator appropriately (since local is beta)?

I think that's a good idea.

@scott-cotton
Copy link
Member

  • Should we remove the grpc/go-sdk model conversions?

Do you mean across the whole CLI? (what would look like a massive change to me).

I renamed these funcs:

23-11-09 scott@air cli % git diff | grep func
-func ToModelsSandboxSpec(grpcSpec *structpb.Struct) (*models.SandboxSpec, error) {
+func xToModelsSandboxSpec(grpcSpec *structpb.Struct) (*models.SandboxSpec, error) {
@@ -23,7 +23,7 @@ func ToModelsSandboxSpec(grpcSpec *structpb.Struct) (*models.SandboxSpec, error)
-func ToGRPCSandbox(sb *models.Sandbox) (*structpb.Struct, error) {
+func xToGRPCSandbox(sb *models.Sandbox) (*structpb.Struct, error) {
@@ -32,7 +32,7 @@ func ToGRPCSandbox(sb *models.Sandbox) (*structpb.Struct, error) {
-func ToGRPCSandboxSpec(sbs *models.SandboxSpec) (*structpb.Struct, error) {
+func xToGRPCSandboxSpec(sbs *models.SandboxSpec) (*structpb.Struct, error) {
@@ -42,7 +42,7 @@ func ToGRPCSandboxSpec(sbs *models.SandboxSpec) (*structpb.Struct, error) {
-func ToModelsSandbox(grpcSandbox *structpb.Struct) (*models.Sandbox, error) {
+func xToModelsSandbox(grpcSandbox *structpb.Struct) (*models.Sandbox, error) {

in internal/locald/api/sandboxmanager/convert and it compiles fine, so they are now unused.

@scott-cotton
Copy link
Member

  • Should we remove the api related stuff from internal/config/locald.go?

Not sure, I understand what you mean by that, can you expand?

Sorry, it was too vague. Was thinking that with the removal of sandbox apply from sandbox manager, we would probably not need the api key nor initialise APIConfig inside of anything in locald. I thought I remembered adding this CIConfig api support specifically for the sandbox apply proxy, and greping around it looks to me like we can remove APIKey from the CIConfig struct, as well as related code setting up the config for a *manager to communicate with the API.

wdyt?

@daniel-de-vera
Copy link
Contributor Author

@scott-cotton, I implemented this:

Should we detect operator version and error out on old operator appropriately (since local is beta)?

In PR #92

@daniel-de-vera
Copy link
Contributor Author

  • Should we remove the grpc/go-sdk model conversions?

Do you mean across the whole CLI? (what would look like a massive change to me).

I renamed these funcs:

23-11-09 scott@air cli % git diff | grep func
-func ToModelsSandboxSpec(grpcSpec *structpb.Struct) (*models.SandboxSpec, error) {
+func xToModelsSandboxSpec(grpcSpec *structpb.Struct) (*models.SandboxSpec, error) {
@@ -23,7 +23,7 @@ func ToModelsSandboxSpec(grpcSpec *structpb.Struct) (*models.SandboxSpec, error)
-func ToGRPCSandbox(sb *models.Sandbox) (*structpb.Struct, error) {
+func xToGRPCSandbox(sb *models.Sandbox) (*structpb.Struct, error) {
@@ -32,7 +32,7 @@ func ToGRPCSandbox(sb *models.Sandbox) (*structpb.Struct, error) {
-func ToGRPCSandboxSpec(sbs *models.SandboxSpec) (*structpb.Struct, error) {
+func xToGRPCSandboxSpec(sbs *models.SandboxSpec) (*structpb.Struct, error) {
@@ -42,7 +42,7 @@ func ToGRPCSandboxSpec(sbs *models.SandboxSpec) (*structpb.Struct, error) {
-func ToModelsSandbox(grpcSandbox *structpb.Struct) (*models.Sandbox, error) {
+func xToModelsSandbox(grpcSandbox *structpb.Struct) (*models.Sandbox, error) {

in internal/locald/api/sandboxmanager/convert and it compiles fine, so they are now unused.

Oh, I see! It's done now.

@daniel-de-vera
Copy link
Contributor Author

  • Should we remove the api related stuff from internal/config/locald.go?

Not sure, I understand what you mean by that, can you expand?

Sorry, it was too vague. Was thinking that with the removal of sandbox apply from sandbox manager, we would probably not need the api key nor initialise APIConfig inside of anything in locald. I thought I remembered adding this CIConfig api support specifically for the sandbox apply proxy, and greping around it looks to me like we can remove APIKey from the CIConfig struct, as well as related code setting up the config for a *manager to communicate with the API.

wdyt?

Got it, yes, looks like a good idea.
I will check it and remove unneeded things.

@daniel-de-vera
Copy link
Contributor Author

  • Should we remove the api related stuff from internal/config/locald.go?

Not sure, I understand what you mean by that, can you expand?

Sorry, it was too vague. Was thinking that with the removal of sandbox apply from sandbox manager, we would probably not need the api key nor initialise APIConfig inside of anything in locald. I thought I remembered adding this CIConfig api support specifically for the sandbox apply proxy, and greping around it looks to me like we can remove APIKey from the CIConfig struct, as well as related code setting up the config for a *manager to communicate with the API.

wdyt?

@scott-cotton, this is done now, in eaf51d8

@@ -43,6 +43,8 @@ func newSBController(log *slog.Logger, sandbox *tunapiv1.WatchLocalSandboxesResp
}
// run the controller
go ctrl.run()
// trigger a reconcile
ctrl.triggerReconcile()
Copy link
Member

Choose a reason for hiding this comment

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

I would put this in ctrl.run() so it is more self-contained.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I addressed this in #94

select {
case <-revtun.rtToClose:
default:
ctrl.log.Debug("sandbox controller closing revtun", "local", xwName)
Copy link
Member

Choose a reason for hiding this comment

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

I think that, in order for the select to protect against double closures, we would need to put the call to ctrl.log.Debug after the close()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I addressed this in #94

sbMon.stop()
}
sbw.sbMu.Unlock()

Copy link
Member

Choose a reason for hiding this comment

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

This code was hard to understand, maybe some comments would help:

  • the grpcserver has called graceful stop, so no new sandboxes will be processed during a call to this function
  • the delFn is called at the end of the sb monitor run, so the wg will wait for all monitors to stop running.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I addressed this in #94

Copy link
Member

@scott-cotton scott-cotton left a comment

Choose a reason for hiding this comment

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

Approving, left some minor suggestions in second review round.

daniel-de-vera and others added 4 commits November 15, 2023 09:27
* Implementation of sandboxes watcher status

* PR feeback

* Include machine id to local status
* Add support for old operators (< 0.14.1)

* Addition of operatorInfoUpdater

* Minor fix

* Bug fix

* Point libconnect to main

* Point github.com/signadot/go-sdk to main version

* PR feedback
@daniel-de-vera daniel-de-vera merged commit 58cbd65 into main Nov 20, 2023
@daniel-de-vera daniel-de-vera deleted the sandbox-machineID branch November 20, 2023 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants