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

Remove deleted pipelines from global active pipeline list #34

Merged
merged 5 commits into from
Jul 16, 2018

Conversation

bidhan-a
Copy link
Contributor

Fixes #29

Let me know your thoughts @michelvocks

Thanks!

@codecov-io
Copy link

codecov-io commented Jul 14, 2018

Codecov Report

Merging #34 into master will increase coverage by 2.76%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #34      +/-   ##
==========================================
+ Coverage    33.5%   36.26%   +2.76%     
==========================================
  Files          13       13              
  Lines         991     1012      +21     
==========================================
+ Hits          332      367      +35     
+ Misses        622      608      -14     
  Partials       37       37
Impacted Files Coverage Δ
pipeline/ticker.go 0% <0%> (ø) ⬆️
pipeline/pipeline.go 52.85% <100%> (+49.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bbf228e...a19711a. Read the comment docs.

@michelvocks
Copy link
Member

Thanks a lot @bidhan-a for your contribution. 🤗
I know we are lacking tests anyway but it would be really helpful if you could add tests for the functions you have new introduced. That would help us a lot! 😄

// RemoveDeletedPipelines removes the pipelines whose names are NOT
// present in `existingPipelineNames` from the given ActivePipelines instance.
func (ap *ActivePipelines) RemoveDeletedPipelines(existingPipelineNames []string) {
for i, pipeline := range ap.Pipelines {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@bidhan-a bidhan-a Jul 15, 2018

Choose a reason for hiding this comment

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

@michelvocks The iter function doesn't provide a counter so we'd have to introduce a counter variable to get the pipeline index. Would that be okay?

Copy link
Member

Choose a reason for hiding this comment

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

@bidhan-a Yes that is fine. 😄

Copy link
Contributor Author

@bidhan-a bidhan-a Jul 16, 2018

Choose a reason for hiding this comment

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

@michelvocks Cool! I'll implement that and let you know.

@bidhan-a
Copy link
Contributor Author

Hey @michelvocks

I have encountered an issue.

We're using an RLock inside the Iter() function: https://github.com/gaia-pipeline/gaia/blob/master/pipeline/pipeline.go#L136

Similarly, I have added a Lock inside the Remove() function: https://github.com/bidhan-a/gaia/blob/issue-29/pipeline/pipeline.go#L92

If we try to remove pipelines while Iter() is running (https://github.com/bidhan-a/gaia/blob/issue-29/pipeline/pipeline.go#L181), then Remove will try to lock an already locked resource and the code will not move further.

Any way we can circumvent this?

Thanks

@michelvocks
Copy link
Member

Good point @bidhan-a. I think the only viable way to work around this is to copy all elements which you want to delete into an intermediate slice. After you have left the Iter() loop you can loop through the intermediate slice and safely remove the items. What do you think? 🤗

@bidhan-a
Copy link
Contributor Author

Sounds good to me @michelvocks !

@bidhan-a
Copy link
Contributor Author

All done @michelvocks. I've also included tests for the functions which I've added.

Thanks!

Copy link
Member

@michelvocks michelvocks left a comment

Choose a reason for hiding this comment

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

LGTM 🤗 Thanks a lot! 👍 ❤️

@michelvocks michelvocks merged commit 22375b5 into gaia-pipeline:master Jul 16, 2018
@bidhan-a bidhan-a deleted the issue-29 branch July 16, 2018 06:49
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