Skip to content

better versioning#546

Merged
gmmeyer merged 7 commits into
masterfrom
greg/meaningful-version
Sep 11, 2017
Merged

better versioning#546
gmmeyer merged 7 commits into
masterfrom
greg/meaningful-version

Conversation

@gmmeyer

@gmmeyer gmmeyer commented Sep 8, 2017

Copy link
Copy Markdown
Contributor

What does this PR do?

This is not a very complex change, it takes some of the logic we use in omnibus, translates it to python, and then sets the version

Motivation

We needed a more meaningful version for the agent

Additional Notes

Anything else we should know when reviewing?

@masci masci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A couple of nits, overall I think we should add more comments/docs about how the version is composed

Comment thread pkg/version/base.go
const AgentVersion = "6.0.0+Χελωνη"
var AgentVersion string

var agentVersionDefault = "6.0.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we change 6.0.0 to something that works in case the agent is custom built? Something like 0.0.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There are a lot of places in the agent where it is assumed to be 6.0.0. If you look in the tests, you'll see this:

--- FAIL: TestGetMultipleEndpoints (0.00s)
	Error Trace:	config_test.go:59
	Error:		Not equal: map[string][]string{"https://foo.datadoghq.com":[]string{"someapikey"}, "https://6-0-0-app.agent.datadoghq.com":[]string{"fakeapikey", "fakeapikey2", "fakeapikey3"}} (expected)
			        != map[string][]string{"https://0-0-0-app.agent.datadoghq.com":[]string{"fakeapikey", "fakeapikey2", "fakeapikey3"}, "https://foo.datadoghq.com":[]string{"someapikey"}} (actual)

Are you sure you want that as the default?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't hardcode the version number, hopefully this agent won't be 6 for a long time. I can address this in a separate PR though.

Comment thread pkg/version/base.go Outdated

func init() {
if AgentVersion == "" {
AgentVersion = "6.0.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should be = agentVersionDefault

Comment thread tasks/utils.py
described_version = check_output(["git", "describe", "--tags"], stderr=subprocess.STDOUT).strip()
except:
described_version = ""
version_match = re.findall(r"^v?(\d+\.\d+\.\d+)", described_version)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you add an example string the regex would match as a comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes

Comment thread tasks/utils.py
else:
version = "6.0.0"

commits_since_version_match = re.findall(r"^.*-(\d+)\-g[0-9a-f]+$", described_version)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what are commits_since_version_match? Can you add a comment and an example string we'd match?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup

Comment thread tasks/utils.py

pre_regex = ""
if commits_since_version == 0:
pre_regex = r"^v?\d+\.\d+\.\d+(?:-|\.)([0-9A-Za-z.-]+)$"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup

@gmmeyer

gmmeyer commented Sep 11, 2017

Copy link
Copy Markdown
Contributor Author

@masci I made the changes you asked for!

masci
masci previously approved these changes Sep 11, 2017
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