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

maintain: change makefile to update local dev versions #3293

Closed
wants to merge 2 commits into from

Conversation

pdevine
Copy link
Contributor

@pdevine pdevine commented Sep 22, 2022

Summary

The version cli/server when you're building with the dev build with the makefile is pegged at 0.14.4. This can be misleading and confusing if you're expecting the actual version (e.g. right now we're currently on 0.15.2).

This change snags the current appVersion from the helm chart (although we can snag it from somewhere else if/when we move the helm chart) and patches our binary with the updated version (instead of 0.14.4).

Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

I believe the underlying problem here is that release-please used to take care of updating internal/version.go to the latest released version. Now that we've removed that automation the file has the old versions in it.

I'm not sure the Makefile fix will work in the future. Our tests will need the correct internal.Version as soon as we add another API migration. Longer term I think we will need to restore the post-release automation to update this version automatically.

I think we should at least set the version in internal/version.go to something like 0.0.0. Even better would be to set set it to our released version. If we set it to the released version we wouldn't need to look it up in the Makefile, but I'm fine to keep the lookup. With that change this LGTM.

@@ -1,5 +1,4 @@
v ?= $(shell git describe --tags --abbrev=0)
IMAGEVERSION ?= $(v:v%=%)
BUILDVERSION := $(shell grep "appVersion" helm/charts/infra/Chart.yaml | sed -e "s/.*: //")
Copy link
Contributor

Choose a reason for hiding this comment

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

Not something we can change right now, but this is a great example of why Makefiles are such a bad fit for this use case of "automating development tasks" (despite them being super widely used for that purpose).

Every single invocation of make will have to run this grep, even though most won't make use of it. I don't think there's any way around that for make.

Over time the number of variables builds up, and we end up with a very slow make because it's a bad fit for the job.

An equivalent bash script would be able to calculate this only for the task that requires it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

While this is true, there are method to delay execution until the value is needed. In this case, using $$(...) instead of $(shell ...) assigns BUILDVERSION to the command itself rather than the output. When the line referencing BUILDVERSION is executed, it will create a subshell and run the grep.

This is actually used later on in make dev where the image SHA is evaluated after the image is built rather than when make is called which is what $(shell ...) will. In that case, using $(shell ...) will not have the right output, the annotation is unlikely to change, and the pod will not automatically restart

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, I did not know about this feature of make! I still think that an equivalent bash script is going to be easier for most people to figure out, but good to know that there are ways to defer execution with make.

@pdevine
Copy link
Contributor Author

pdevine commented Sep 23, 2022

I went ahead and set the version to 0.0.0. Setting the version to the current version is just going to go out of date the second we release another version of the product, so this should work "for now", although we definitely need a more permanent fix.

@mxyng
Copy link
Collaborator

mxyng commented Sep 23, 2022

Instead of these changes, I would rather see internal.Version set to a dummy value like 99.99.99999 to indicate a development version. This has a few benefits, the primary one being simplicity. Since the real version is injected during image and artifact builds, this value does nothing.

The only time this value has any effect is when image or artifacts are build locally, or during tests. By setting such a ridiculous value, it should be obvious to the user this is not a real version string. This version in particular should ensure all migrations are always run since it's (almost) always a higher semantic version.

The simplicity of this allows us to not mess with the Makefile, not mess with the Version in the code, and not worry about API migrations not being applied. We can actually remove code if the default Version is something like 99.99.99999.

I put the change I have in mind into #3294

@dnephin
Copy link
Contributor

dnephin commented Sep 23, 2022

I really like the approach in #3294

When combined with go version -m ./infra (which gives us the git commit that was used to compile the binary) that seems like it should address the problem. We no longer have a misleading version when combined with go build, and we still have a way to check what version of the binary we are running.

@mxyng
Copy link
Collaborator

mxyng commented Sep 26, 2022

No longer necessary after #3294

@mxyng mxyng closed this Sep 26, 2022
@mxyng mxyng deleted the set-dev-version branch September 26, 2022 20:18
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.

3 participants