-
Notifications
You must be signed in to change notification settings - Fork 79
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
Spring cleaning #258
Spring cleaning #258
Conversation
b85712a
to
53bef91
Compare
Codecov Report
@@ Coverage Diff @@
## main #258 +/- ##
====================================
- Coverage 40% 39% -2%
====================================
Files 41 37 -4
Lines 2580 2424 -156
====================================
- Hits 1037 948 -89
+ Misses 1468 1413 -55
+ Partials 75 63 -12
Continue to review full report at Codecov.
|
de9d836
to
8b2f83b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I only reviewed for language formatting and idioms. I'd want another set of eyes for PXE content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a terribly large PR, quite a lot of movement. Would have really preferred if it was broken into smaller chunks.
func mustBuildMirrorBaseURL() string { | ||
s, err := buildMirrorBaseURL() | ||
if s == "" { | ||
panic(fmt.Sprintf(`conf: MirrorBaseURL: %q: %s\n`, s, err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was already here from before, I've actually removed one other case of unwanted behavior. I'll rework the code though so that we don't need the conf package anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried re-working but then came across all the other things in https://github.com/tinkerbell/boots/blob/main/conf/config.go and stopped trying. I've made it so osie is better about this as a small step in the right direction. Getting rid of all the must*
in conf is going to explode this PR even further.
go.mod
Outdated
google.golang.org/grpc v1.44.0 | ||
inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 | ||
) | ||
|
||
require github.com/golangci/golangci-lint v1.45.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this provide? Feels out of place. does this package get included in the binary build? how much size does it add to the binary? The go.mod
in this package has a lot of dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Makefile has a target that runs golangci-lint and says @echo be sure golangci-lint is installed: https://golangci-lint.run/usage/install/
which really makes no sense when we are pinning go tools using tools.go
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the other imports in tools.go don't show up in the go.mod. i wondering why golangci-lint needs to?
installers/osie/main.go
Outdated
type installer struct{} | ||
|
||
func Installer() job.BootScripter { | ||
if env.Get("DATA_MODEL_VERSION") != "1" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being introduced here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've lifted this up to here from where it used to be, this env var was being checked for every ipxe script that was generated (https://github.com/tinkerbell/boots/blob/main/installers/osie/main.go#L115-L116) instead of just once at boot since they aren't going to change. I'll move this to be done in cmd/boots/main.go and pass it in as args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
installers/osie/main.go
Outdated
"grpc_cert_url=" + require("TINKERBELL_GRPC_AUTHORITY"), | ||
"packet_base_url=" + workflowURL, | ||
} | ||
if registry := env.Get("DOCKER_REGISTRY"); registry != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environment variables should endeavor to be read in func main.
"Only func main has the right to decide which flags, env variables, config files are available to the user" -- ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to the other comment and I'll rework to avoid this now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
Hey @jacobweinstock yeah I recognize this is a big PR. I kind of went that way to avoid a long series of small quick PRs when effectively they are all refactors/tidying up of things. I can definitely split up into smaller PRs but honestly I think it'd be easier to go through this commit by commit, each should be pretty self-explanatory/stand-alone and digestable. Let me know if that works or not. #255 is close so to ready and I'll be rebasing on top of it. |
f671dce
to
16c6bac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed for go style and backend support, I will defer to other reviewers for most of the content
installers/osie/main.go
Outdated
"grpc_authority=" + require("TINKERBELL_CERT_URL"), | ||
"grpc_cert_url=" + require("TINKERBELL_GRPC_AUTHORITY"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mix up here:
"grpc_authority=" + require("TINKERBELL_CERT_URL"), | |
"grpc_cert_url=" + require("TINKERBELL_GRPC_AUTHORITY"), | |
"grpc_authority=" + require("TINKERBELL_GRPC_AUTHORITY"), | |
"grpc_cert_url=" + require("TINKERBELL_CERT_URL"), |
Also:
- Isn't
TINKERBELL_CERT_URL
deprecated/gone and replaced withTINKERBELL_TLS=bool
? - You'll need a way to plumb down the tink API for the Kubernetes backend data model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops I've still forgotten about k8s backend, have to update that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept CERT_URL and left TLS out originally because it didn't seem like "spring cleaning", but after you mentioned it I think its fine, it should have been done when those respective PRs landed in tink so I can see this being "dirty" in need of cleaning ... if you squint :D. So I've fixed this now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@micahhausler the kubernetes backend pr (#250) isn't merged yet.
rules.mk
Outdated
packet/mock_cacher/cacher_mock.go: packet/models_cacher.go | ||
packet/mock_workflow/workflow_mock.go: packet/models_tinkerbell.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These paths need updating
packet/mock_cacher/cacher_mock.go: packet/models_cacher.go | |
packet/mock_workflow/workflow_mock.go: packet/models_tinkerbell.go | |
client/cacher/mock_cacher/cacher_mock.go: client/cacher/discovery.go | |
client/tinkerbell/mock_workflow/workflow_mock.go: client/tinkerbell/discovery.go | |
client/tinkerbell/mock_hardware/hardware_mock.go: client/tinkerbell/discovery.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, good catch.
I changed the range because I'm tired of seeing red. Lets get to green more positively. Also no longer need the vendor or ipxe ignores because they no longer exist. Removed fields that the codecov validator complained about as unknown. Signed-off-by: Manuel Mendez <[email protected]>
488e22c
to
3b8ab08
Compare
No need to test/verify combinations that do not influence the outcome. Signed-off-by: Manuel Mendez <[email protected]>
EM no longer supports coreos provisions and coreos is long EOL and gone. This is the first of a series of commits that will drop mentions of coreos in favor of flatcar. Signed-off-by: Manuel Mendez <[email protected]>
Flatcar does not fetch oem.tgz, it doesn't even have code that mentions oem_url. I came to realize this when I noticed in the last commit that we set oem_url=.../flatcar/oem.tgz but only ever serve .../coreos/oem.tgz in cmd/boots/http.go which should have caused flatcar to fail if it needed it. I've verified that flatcar doesn't even try to fetch the oem tarball. Drop files/tarball because it was only used in oem.go file. Signed-off-by: Manuel Mendez <[email protected]>
Its all flatcar now, woop! Signed-off-by: Manuel Mendez <[email protected]>
No need to test 2 plans that just run `Exec`. Also update the names to the current plan name schemes. Change s1.large special handling to s3.xlarge as flatcar only needs work arounds for that the s3.xlarge. Signed-off-by: Manuel Mendez <[email protected]>
These packages are only used by coreso (aka flatcar) so move them there. Signed-off-by: Manuel Mendez <[email protected]>
Signed-off-by: Manuel Mendez <[email protected]>
Signed-off-by: Manuel Mendez <[email protected]>
At the top of the script too. Signed-off-by: Manuel Mendez <[email protected]>
This way the tests better reflect what is expected to happen in real world. Signed-off-by: Manuel Mendez <[email protected]>
There's only one actual case where returning the Script was nice (the `Set("iface",...).Or("shell")`) but its not worth keeping around. Its confusing seeing the script being modified in place within a function body but having to copy and return within and after passing to a function. Now we know the script is always modified in place. Signed-off-by: Manuel Mendez <[email protected]>
This interface will be how main gets the func to use from the installers. Signed-off-by: Manuel Mendez <[email protected]>
This way cmd/boots doesn't need to violate any layers/boundaries by setting up structs and calling internal functions. This way we avoid tight coupling of installers to main's needs. Signed-off-by: Manuel Mendez <[email protected]>
Previously the tinkerbell connection params were being checked for each request unnecessarily. We'd also fail late, not early, if anything was invalid. This now fails early at start up and doesn't waste time/cycles getting the vaules and then throwing them away. Now that the env is being read only once there's not a whole lot of reason for having mirror.go around for just one function that is called only twice. Signed-off-by: Manuel Mendez <[email protected]>
… args These values are static once boots starts up so we can precalculate a partial slice of args and avoid a bunch of string allocation/concatenation. I don't think this is premature optimization as I prefer doing this for readability aspect over the optimization. Signed-off-by: Manuel Mendez <[email protected]>
But only if false because we want to preserve the default of true as default. Signed-off-by: Manuel Mendez <[email protected]>
This is no longer a thing so no need to propogate. Signed-off-by: Manuel Mendez <[email protected]>
3b8ab08
to
3b28614
Compare
installers/osie/main.go
Outdated
ExtraKernelArgs string | ||
type installer struct { | ||
osieURL string | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove extra space
installers/osie/main.go
Outdated
} | ||
s.Args("grpc_authority=" + grpcAuthority) | ||
s.Args("grpc_cert_url=" + grpcCertURL) | ||
s.Args(i.tinkParams) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my tests this appears to add a single space if i.tinkParams == ""
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tinkParams will never be empty since its initialized with grpc_authority
and packet_base_url
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if dataModelVersion != "1"
then i.tinkParams == ""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm good point, this is still guarded by CanWorkflow
which doesn't make any sense when dataModelVersion != 1. 🤔 ideally CanWorkflow returns false if dataModelVersion != 1 always, let me try that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to make sure we're in tink mode as a prereq for the CanWorkflow checks. Will also open up an issue so that we drop CanWorkflow all together as boots doesn't really support a mixed-mode operation we're either in cacher, tink, standalone and the hw has no real say in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this has been fixed now, can you make sure please?
cmd/boots/main.go
Outdated
dataModelVersion := env.Get("DATA_MODEL_VERSION") | ||
auth := env.Get("TINKERBELL_GRPC_AUTHORITY") | ||
if dataModelVersion == "1" && auth == "" { | ||
mainlog.Fatal(errors.New("TINKERBELL_GRPC_AUTHORITY is required when in tinkerbell mode")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this panic be moved to func main
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
installers/osie/main.go
Outdated
if registry != "" { | ||
tinkParams = append(tinkParams, "docker_registry="+registry) | ||
} | ||
if registryUsername != "" { | ||
tinkParams = append(tinkParams, "registry_username="+registryUsername) | ||
} | ||
if registryPassword != "" { | ||
tinkParams = append(tinkParams, "registry_password="+registryPassword) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these would still be needed even if dataModelVersion != "1"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats not how the code is today: https://github.com/tinkerbell/boots/blob/main/installers/osie/main.go#L123-L139. This is behind CanWorkflow
but that only ever happens when dataModelVersion == 1 anyway. We shouldn't have 2 ways to do this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats not my experience. i can use the DATA_MODEL_VERSION=standalone
and still use CanWorkflow
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm this seems very accidental and confusing, if you're in dmv=standalone and canworkflow=true then why would tink connection params matter? dmv is actually doing 2 different jobs and causing confusion (surprise, surprise... 😄). Should probably be something like DATA_SOURCE=cacher|tink|standalone|something-in-the-future/pluggable
and DATA_MODEL=cacher|tink
. But oh well, not going to try and do that now. I'll fix it so tinkArgs isn't dependent on DMV=1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Lets make `Environment variables should endeavor to be read in func main` that much closer to being reality. This does that by getting rid of all the direct lookups into the environment, instead getting the values via the call to `Installer()`. This commit also makes use of the arguments by building up the space separated string that gets passed to script.Args only once instead of storing each value and building up the same substring over and over and over again. Signed-off-by: Manuel Mendez <[email protected]>
3b28614
to
05cfeab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mmlb !
Description
I was getting ready to PR my branch that is updated to work in /cert-less tink (now that tinkerbell/tink#584 is merged) and it was basically a situation where pulling one thread unraveled a bunch of other things. Dropping /cert begot some refactors (started by dropping the
buildWorkerParams
silliness) which begot some test fixes which begot some other refactors which was also dumb to do for rancher, nixos, and centos. So here we are.Why is this needed
Makes updating to post tinkerbell/tink#584 easier/nicer.
How Has This Been Tested?
Ran unit tests.
How are existing users impacted? What migration steps/scripts do we need?
Less EM specific junk is always good. Less duplicate/unclear tests too. This PR does introduce a change wrt sandbox, where MIRROR_HOST is dropped in favor of MIRROR_BASE_URL, I'll follow up with a PR there once this merges.
Checklist:
I have: