Skip to content

Conversation

@mpeck
Copy link
Contributor

@mpeck mpeck commented Sep 29, 2016

Was having a hard time explaining what I was thinking so I thought I would just do it. This adds an extra config that causes bundle installation to overwrite the existing version if it already exists.

resolves #969

@mpeck mpeck added the review label Sep 29, 2016
@mpeck mpeck force-pushed the peck/update-config branch 2 times, most recently from bb5db67 to 5469e69 Compare September 30, 2016 13:43
|> Repo.preload(:templates)

Enum.each(new_version.commands, &Repo.delete!/1)
Enum.each(new_version.templates, &Repo.delete!/1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are you deleting the commands and templates of the thing you just installed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The old commands and templates are removed here and they are reinstalled later in the transaction. We could go through and update all of the associations instead of just reinstalling, but that is a lot more logic and seemed more likely to introduce bugs. With this method bundle installation continues just as it did normally with the exception that we reference the old bundle version instead of a newly created one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's not clear from this... you're calling delete on the commands and templates from new_version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, the functionality should be more like "delete the existing bundle at version X, and then install this new "version" of version X". We already handle the associations properly that way.

However, for it to be truly transparent, you're also going to have to deal with enabled / disabled status.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hrm, that would be cleaner. I did it like this to preserve the id of the bundle version. That way we wouldn't have to go through and clean up references to it. But as I'm looking again you're right. The only one to worry about is the enabled version. Everything else references the bundle id.

Let me try that and see how if everything works like I'm thinking.


Application.put_env(:cog, :enforce_bundle_version, true)
end

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm concerned that there are a lot of edge cases in overall behavior that we're not addressing with this test. I'm thinking in particular of the rules and permissions associated with the old and new bundles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I agree. I just did a quick smoke test to validate it was working. If you think my general approach is reasonable, I'll add some more tests to make sure everything is working as expected.

@kevsmith
Copy link
Member

Hmmm. I envisioned this feature working per-bundle not a global switch for the Cog install.

Something like:

cogctl bundle install --force-overwrite path/to/config.yaml

@mpeck
Copy link
Contributor Author

mpeck commented Sep 30, 2016

@kevsmith I can do that. In that case would it be a feature that's always available, or should we require a setting in Cog to enable it?

@kevsmith
Copy link
Member

Always available. Think of it like git push --force.

@mpeck mpeck force-pushed the peck/update-config branch 2 times, most recently from dd79417 to 9fb59c5 Compare September 30, 2016 19:57
@mpeck
Copy link
Contributor Author

mpeck commented Sep 30, 2016

@kevsmith @christophermaier how does this look?

and as a sister PR, cogctl support operable/cogctl#93

@mpeck mpeck force-pushed the peck/update-config branch from 9fb59c5 to c230729 Compare October 4, 2016 17:26
@christophermaier
Copy link
Collaborator

Looks good. Squash the commits down and :shipit:

@mpeck mpeck force-pushed the peck/update-config branch from c230729 to 152c270 Compare October 4, 2016 18:05
@mpeck
Copy link
Contributor Author

mpeck commented Oct 4, 2016

@kevsmith new_version!/3 is called inside a transaction so I didn't think it was necessary. That's the only place we call it.

@kevsmith
Copy link
Member

kevsmith commented Oct 4, 2016

@mpeck Disregard. I missed the enclosing transaction on my first read thru.

@kevsmith
Copy link
Member

kevsmith commented Oct 4, 2016

One other question -- what does the error look like if a forced install fails?

@mpeck
Copy link
Contributor Author

mpeck commented Oct 4, 2016

@kevsmith The installation path is basically identical as normal. The only difference being that we delete the old version before installing the new one. I tried to keep everything as similar as I could. So installation errors are the same regardless.

@kevsmith
Copy link
Member

kevsmith commented Oct 4, 2016

Ok. The reason I ask is because we had issues in the past with errors inside a function running in a transaction (I think in rules ingestion) generating pretty cryptic error messages.

I agree w/ @christophermaier

@mpeck mpeck merged commit 152c270 into master Oct 4, 2016
@mpeck mpeck removed the review label Oct 4, 2016
@mpeck mpeck deleted the peck/update-config branch October 4, 2016 18:22
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.

Support updating config.yaml in place

4 participants