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

Change FindTaskById function #298

Closed
wants to merge 7 commits into from

Conversation

JurrianFahner
Copy link

This change will fix issue: #296

It makes the FindTaskById function to match also on the first part of an id, so marathon-consul will be compatible with version 1.9 of marathon.

To avoid matching on too little information, also the requirement of at least a length of an id with 36 chars.

Change FindTaskByID so that Marathon-Consul can be used with marathon version > 1.9, this change will fix issue: allegro#296

Refactor test so the output resembles marathon v1.9
Also added 3 tests to test the find tasks method.

This change should be backwards compatible
apps/task.go Outdated Show resolved Hide resolved
apps/task_test.go Show resolved Hide resolved
@JurrianFahner
Copy link
Author

JurrianFahner commented Nov 14, 2019

@ojagodzinski The build is failing, how can it fixed? See below output of Travis. The package build succeeds now.

$ goveralls -coverprofile=coverage/gover.coverprofile -service travis-ci
Error parsing coverage: open coverage/gover.coverprofile: no such file or directory
The command "goveralls -coverprofile=coverage/gover.coverprofile -service travis-ci" exited with 1.
Done. Your build exited with 1.

@ojagodzinski
Copy link
Member

@ojagodzinski The build is failing, how can it fixed? See below output of Travis. The package build succeeds now.

$ goveralls -coverprofile=coverage/gover.coverprofile -service travis-ci
Error parsing coverage: open coverage/gover.coverprofile: no such file or directory
The command "goveralls -coverprofile=coverage/gover.coverprofile -service travis-ci" exited with 1.
Done. Your build exited with 1.

I enabled tests and removed one that was failing. Running some of them is still better than not running anything ;)

@JurrianFahner
Copy link
Author

I don't understand why the test is failing, it works on my computer (after pulling the latest changes). There is no setup needed, I think.

@ojagodzinski Do you understand what is happening, based on your experience?

@ojagodzinski
Copy link
Member

ojagodzinski commented Nov 15, 2019

I don't understand why the test is failing, it works on my computer (after pulling the latest changes). There is no setup needed, I think.

There is a problem with len(id.String() > 36 condition, test cases have much shorter ids

@JurrianFahner
Copy link
Author

JurrianFahner commented Nov 16, 2019

I don't understand why the test is failing, it works on my computer (after pulling the latest changes). There is no setup needed, I think.

There is a problem with len(id.String() > 36 condition, test cases have much shorter ids

That explains a lot indeed! The reason I added the len(id.String() > 36 is to add some safety to avoid problems when an ID is not resolved and becomes an empty string (it would match, which is not desirable). Before my change it wouldn't be a problem, since the method matched on equality. Now we are matching on the start of the strings, because the last part can't be predicted. I've chosen for 36, because it is the length of an uuid (which is an arbritary choice).

In my opinion we have two solutions:

  1. Refactor all other tests for ids, to make sure that each id has more than 36 characters. But that is only reasonable when we are sure there is no use-case for this software where the ids are smaller. This might be also the safest option.

  2. Lower the length of the minimal id in a way that all tests would succeed, which is definitely faster to change and least invasive. But might add some insecurity, when the id of an event might match more than one task.

@ojagodzinski What would you like me to do? I'll pick up the task on monday.

@ojagodzinski
Copy link
Member

ojagodzinski commented Nov 19, 2019

Refactor all other tests for ids, to make sure that each id has more than 36 characters. But that is only reasonable when we are sure there is no use-case for this software where the ids are smaller.

It is the most dangerous one. We cannot force apps to use names with some arbitrary length.

is to add some safety to avoid problems when an ID is not resolved and becomes an empty string

so it should fail if ID is not resolved.

Lower the length of the minimal id in a way that all tests would succeed, which is definitely faster to change and least invasive. But might add some insecurity, when the id of an event might match more than one task.

divide this case into two separate ones and check id via regex not via HasPrefix in marathon >1.9

There should be also test case with two apps of lenght =1 that should not match in this condition.

Jurrian Fahner added 2 commits November 19, 2019 13:11
The minimal length requirement must be 1. 
If an id might match more than 1 task, it should fail and give a warning. Because there is an inconsistency with what could have been expected.
@JurrianFahner
Copy link
Author

I changed the code a bit, to make it possible to match on ids which are of length 1.
Also the case when there is a search on an empty string is covered, by the code.

Downside of this approach that for each search the whole array of tasks needs to be searched, to add more safety. Before this change the search was stopped when a task was found.

@JurrianFahner
Copy link
Author

JurrianFahner commented Dec 1, 2019

make release check works on my machine. I don't know why it fails on travis, since I can't reproduce the failed build.

@ojagodzinski What can I do to solve that problem?

@JurrianFahner
Copy link
Author

@ojagodzinski How can we resolve the issues in the pull request? I can't reproduce the issues on the travis build.

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.

2 participants