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

Use "proper" web framework for HTTP servers #13

Closed
sharnoff opened this issue Jan 11, 2023 · 2 comments
Closed

Use "proper" web framework for HTTP servers #13

sharnoff opened this issue Jan 11, 2023 · 2 comments
Labels
a/tech_debt Area: related to tech debt c/autoscaling/scheduler Component: autoscaling: k8s scheduler

Comments

@sharnoff
Copy link
Member

sharnoff commented Jan 11, 2023

See: #8 (comment)

There's a few places we have HTTP servers:

  • pkg/plugin/run.go: (*AutoscaleEnforcer) runPermitHandler
  • pkg/agent/serve.go: startInformantServer
  • cmd/informant/main.go: main
  • pkg/plugin/dumpstate.go: (*AutoscaleEnforcer) startDumpStateServer
  • pkg/agent/dumpstate.go: (*agentState) StartDumpStateServer

(time of writing: 2023-01-10, commit 65d1528)
(updated: 2023-10-12, commit 166c8d0)

Ideally we'd have something less home-grown here, to reduce custom code & leverage existing wisdom.

@sharnoff sharnoff mentioned this issue Jan 11, 2023
2 tasks
bayandin pushed a commit that referenced this issue Feb 23, 2023
The current solution has some rough edges, but I'm not familiar enough
with the Docker go api to sort them out yet.

For now, this only works if you (at least) specify the image tag
explicitly - e.g. "vmdata-temp:latest" instead of "vmdata-temp".

This commit also adds --pull to force-pull the source image, bypassing this mechanism.
bayandin pushed a commit that referenced this issue Mar 22, 2023
The current solution has some rough edges, but I'm not familiar enough
with the Docker go api to sort them out yet.

For now, this only works if you (at least) specify the image tag
explicitly - e.g. "vmdata-temp:latest" instead of "vmdata-temp".

This commit also adds --pull to force-pull the source image, bypassing this mechanism.
bayandin pushed a commit that referenced this issue Mar 22, 2023
The current solution has some rough edges, but I'm not familiar enough
with the Docker go api to sort them out yet.

For now, this only works if you (at least) specify the image tag
explicitly - e.g. "vmdata-temp:latest" instead of "vmdata-temp".

This commit also adds --pull to force-pull the source image, bypassing this mechanism.
@vadim2404 vadim2404 added the a/tech_debt Area: related to tech debt label Jul 12, 2023
@sharnoff
Copy link
Member Author

sharnoff commented Oct 12, 2023

This is now mostly the scheduler plugin, because the vm-informant was removed in #442, and the agent's HTTP server (which only existed to handle connections from the informant) was removed in #506.

@sharnoff sharnoff changed the title Use "proper" web framework for HTTP servers Use "proper" web framework for plugin HTTP server Oct 12, 2023
@sharnoff sharnoff changed the title Use "proper" web framework for plugin HTTP server Use "proper" web framework for HTTP servers Oct 12, 2023
@sharnoff sharnoff added the c/autoscaling/scheduler Component: autoscaling: k8s scheduler label Feb 2, 2024
sharnoff added a commit that referenced this issue Feb 2, 2024
Closes #760.

AFAIK this hasn't been an issue in the past, but as we're trying to
improve reliability, it's good to get this out of the way before it
becomes an issue.

Note that this PR is quite minimal - expanding the existing tech debt we
have around how the scheduler plugin handles HTTP requests.
It's probably ok *enough* for now. I don't expect we'll be making too
many changes to it in the near future. See also: #13.

Tested locally by forcing it to panic on every request:

diff --git a/pkg/plugin/run.go b/pkg/plugin/run.go
index 007554a..6da7728 100644
--- a/pkg/plugin/run.go
+++ b/pkg/plugin/run.go
@@ -262,8 +262,10 @@ func (e *AutoscaleEnforcer) handleAgentRequest(
 		}
 	}

-	pod.vm.mostRecentComputeUnit = &e.state.conf.ComputeUnit
-	return &resp, 200, nil
+	panic(errors.New("test panic!"))
+
+	// pod.vm.mostRecentComputeUnit = &e.state.conf.ComputeUnit
+	// return &resp, 200, nil
 }

 // getComputeUnitForResponse tries to return compute unit that the agent supports

The change appears to work as intended.
sharnoff added a commit that referenced this issue Feb 12, 2024
Closes #760.

AFAIK this hasn't been an issue in the past, but as we're trying to
improve reliability, it's good to get this out of the way before it
becomes an issue.

Note that this PR is quite minimal - expanding the existing tech debt we
have around how the scheduler plugin handles HTTP requests.
It's probably ok *enough* for now. I don't expect we'll be making too
many changes to it in the near future. See also: #13.

Tested locally by forcing it to panic on every request:

diff --git a/pkg/plugin/run.go b/pkg/plugin/run.go
index 007554a..6da7728 100644
--- a/pkg/plugin/run.go
+++ b/pkg/plugin/run.go
@@ -262,8 +262,10 @@ func (e *AutoscaleEnforcer) handleAgentRequest(
 		}
 	}

-	pod.vm.mostRecentComputeUnit = &e.state.conf.ComputeUnit
-	return &resp, 200, nil
+	panic(errors.New("test panic!"))
+
+	// pod.vm.mostRecentComputeUnit = &e.state.conf.ComputeUnit
+	// return &resp, 200, nil
 }

 // getComputeUnitForResponse tries to return compute unit that the agent supports

The change appears to work as intended.
@stradig
Copy link
Contributor

stradig commented Feb 27, 2024

We are okay with the current state, the code is very readable.

@stradig stradig closed this as completed Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a/tech_debt Area: related to tech debt c/autoscaling/scheduler Component: autoscaling: k8s scheduler
Projects
None yet
Development

No branches or pull requests

3 participants