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 github.com/tinkerbell/dhcp library: #337

Merged
merged 23 commits into from
Aug 16, 2023

Conversation

jacobweinstock
Copy link
Member

@jacobweinstock jacobweinstock commented Aug 5, 2023

Description

This is an improved DHCP library. The package layout has been updated to improve the reflection of the services that Boots runs.

test directory and docker-compose were updated to work with these changes.

The cli flags and env vars have been updated and reorganized by function (syslog, dhcp, tftp, http ipxe binaries, http ipxe scripts). This helps func main be to more understandable.

The phonehome endpoint and all /_packet were removed. These were old deprecated endponts that don't serve much purpose now.

The syslog package was updated to handle shutdown via context, so that it can be used like the other services with errgroup.

Update nix shell file to use Go 1.20.

Why is this needed

Fixes: #266
Fixes: #195

How Has This Been Tested?

How are existing users impacted? What migration steps/scripts do we need?

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

This is an improved DHCP library. The
package layout has been updated to improve
the reflection of the services that Boots runs.

The `cmd/boots` package has been remove and main.go
is not top level. The extra packages are necessary.
References to `cmd/boots` were removed.

test directory and docker-compose were updated to work
with these changes.

The cli flags and env vars have been updated and reorganized
by function (syslog, dhcp, tftp, http ipxe binaries, http ipxe
scripts). This helps func main be to more understandable.

The phonehome endpoint and all `/_packet` were removed.
These were old deprecated endponts that don't serve much
purpose now.

The syslog package was updated to handle shutdown via context,
so that it can be used like the other services with `errgroup`.

Update nix shell file to use Go 1.20.

Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
@jacobweinstock jacobweinstock mentioned this pull request Aug 5, 2023
3 tasks
@jacobweinstock jacobweinstock marked this pull request as ready for review August 5, 2023 04:48
There isn't a strong enough case for
the backend code to have its own package.

Signed-off-by: Jacob Weinstock <[email protected]>
This enables honoring the `http-ipxe-binary-enabled`
and `http-ipxe-script-enabled` if they both are disabled.

Signed-off-by: Jacob Weinstock <[email protected]>
This sorts the flags in the usage output
by the service name in between the brackets "[]"
in the usage string.

Signed-off-by: Jacob Weinstock <[email protected]>
Clarify Boots interoperability with existing
DHCP servers.

Update flag and env var references. Add section on
the services Boots provides.

Signed-off-by: Jacob Weinstock <[email protected]>
@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Merging #337 (fd7ff9e) into main (da97000) will increase coverage by 16%.
The diff coverage is 33%.

❗ Current head fd7ff9e differs from pull request most recent head 59b6e4e. Consider uploading reports for the commit 59b6e4e to get more accurate results

@@          Coverage Diff          @@
##           main   #337     +/-   ##
=====================================
+ Coverage    13%    30%    +16%     
=====================================
  Files        18      6     -12     
  Lines      1732    426   -1306     
=====================================
- Hits        233    129    -104     
+ Misses     1482    288   -1194     
+ Partials     17      9      -8     
Files Changed Coverage Δ
cmd/boots/backend.go 0% <0%> (ø)
cmd/boots/main.go 0% <0%> (ø)
ipxe/script/auto.go 100% <ø> (ø)
ipxe/script/ipxe.go 24% <30%> (ø)
cmd/boots/env.go 32% <50%> (+13%) ⬆️
cmd/boots/flag.go 88% <88%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Order by service name in the "[]" and the flag name.

Signed-off-by: Jacob Weinstock <[email protected]>
@jacobweinstock
Copy link
Member Author

Hey @chrisdoherty4, apologies that this PR is so large. It's a significant library change so i was unable to avoid this churn. We can go over it together if that would help. I can do this in our open forum community meeting if that works.

This helps clarify data translation between
the handler.BackendReader and script.Data.

Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
HandlerMapping type in the http package
allows func main to not need the stdlib
http package and thus allowing bhttp to
be http.

Signed-off-by: Jacob Weinstock <[email protected]>
Simpler use of go run makes it easier to understand
and lessens the make fu needed.

Signed-off-by: Jacob Weinstock <[email protected]>
Improve clarity of purpose.

Signed-off-by: Jacob Weinstock <[email protected]>
The previous version was doing what
goimports was already doing.

Signed-off-by: Jacob Weinstock <[email protected]>
While i prefer single command main funcs
to live top level, the top level has a lot
of files aleady and it felt more difficult
to see and understand the Go files when
they lived at the top level.

Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
.golangci.yml Outdated
@@ -106,7 +106,8 @@ linters:
- asciicheck
- bodyclose
- cyclop
- deadcode
# deprecated
# - deadcode
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to just delete these? I don't think there's a reason to leave them in given we don't intend to reenable.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yes, fixed.

chrisdoherty4
chrisdoherty4 previously approved these changes Aug 16, 2023
Copy link
Member

@chrisdoherty4 chrisdoherty4 left a comment

Choose a reason for hiding this comment

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

Minimal feedback as everything seems good.

}

func backendFlags(c *config, fs *flag.FlagSet) {
fs.BoolVar(&c.backends.file.Enabled, "backend-file-enabled", false, "[backend] enable the file backend for DHCP and the HTTP iPXE script")
Copy link
Member

Choose a reason for hiding this comment

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

It seems like I could specify --backend-file-enabled and --backend-kube-enabled without any explicit error?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, correct. fixed now.

-osie-url [http] url where OSIE(Hook) images are located
-tink-server [http] ip:port for the Tink server
-tink-server-tls [http] use TLS for Tink server (default "false")
-trusted-proxies [http] comma separated list of trusted proxies
Copy link
Member

Choose a reason for hiding this comment

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

IPs or CIDRs or Domains?

Copy link
Member Author

Choose a reason for hiding this comment

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

CIDRs. added to the description.

-extra-kernel-args [http] extra set of kernel args (k=v k=v) that are appended to the kernel cmdline iPXE script
-http-addr [http] local IP and port to listen on for iPXE http script requests (default "%[1]v:80")
-http-ipxe-binary-enabled [http] enable iPXE http binary server (default "true")
-http-ipxe-script-enabled [http] enable iPXE http script server) (default "true")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
-http-ipxe-script-enabled [http] enable iPXE http script server) (default "true")
-http-ipxe-script-enabled [http] enable iPXE http script server (default "true")

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

-http-addr [http] local IP and port to listen on for iPXE http script requests (default "%[1]v:80")
-http-ipxe-binary-enabled [http] enable iPXE http binary server (default "true")
-http-ipxe-script-enabled [http] enable iPXE http script server) (default "true")
-osie-url [http] url where OSIE(Hook) images are located
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
-osie-url [http] url where OSIE(Hook) images are located
-osie-url [http] URL where OSIE(Hook) images are located

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

want := fmt.Sprintf(`USAGE
Run Boots server for provisioning

FLAGS
Copy link
Member

Choose a reason for hiding this comment

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

There are a number of acronym inconsistencies in the help. ip vs IP, http vs HTTP.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed


// ipxeScript is is needed to be able to translate the handler.BackendReader
// returned data to the script.Data struct.
type ipxeScript struct {
Copy link
Member

Choose a reason for hiding this comment

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

It seems odd for this to live here?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yes, updated to a better place.

This was in main package but didnt make sense being there.

Signed-off-by: Jacob Weinstock <[email protected]>
@jacobweinstock jacobweinstock added the ready-to-merge Signal to Mergify to merge the PR. label Aug 16, 2023
@mergify mergify bot merged commit d135982 into tinkerbell:main Aug 16, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Signal to Mergify to merge the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consolidate data model selection, add supporting flags for env vars. misbehaving DHCP client can crash boots
2 participants