-
Notifications
You must be signed in to change notification settings - Fork 656
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
ERB template rendering code review: rename old bosh v1 names to v2 #2479
Conversation
src/bosh-director-core/lib/bosh/director/core/templates/job_instance_renderer.rb
Show resolved
Hide resolved
src/bosh-director/lib/bosh/director/deployment_plan/instance_group.rb
Outdated
Show resolved
Hide resolved
src/bosh-director/lib/bosh/director/deployment_plan/instance_group.rb
Outdated
Show resolved
Hide resolved
src/bosh-director-core/spec/bosh/director/core/templates/job_template_loader_spec.rb
Outdated
Show resolved
Hide resolved
src/bosh-director-core/spec/bosh/director/core/templates/job_template_loader_spec.rb
Outdated
Show resolved
Hide resolved
src/bosh-director-core/spec/bosh/director/core/templates/job_template_loader_spec.rb
Outdated
Show resolved
Hide resolved
@bgandon did you get a change yet to look at the changes requested by Aram? |
Sorry for the delay @rkoster, I’ve answered the comments indeed. Thank you @aramprice for the very valuable review. You’ve pointed out choices that definitely needed some details indeed 👍 I’ve updated the typos, modified the names for fake jobs, and rebased the code on top of the Please tell me what you think of the choices that I’ve detailed in my answers to your comments, thank you! |
653f007
to
7d8218d
Compare
- Rename job_template(s) [Bosh v1] -> instance_job(s) [Bosh v2] - Rename spec [ambiguous] -> spec_object [clarified: related to ERB-templates] - Rename remove_unused_properties [double-negative] -> pick_job_properties [affirmative] - Rename hash [imprecise] -> renderers_hash [clarified contents] - Ensure that (job_name_from_manifest == instance_job.name) while we re-read the job manifest (though there is actually no reason to re-read it) - Reword "Cannot unpack job template" [incorrect] -> "Cannot unpack job blob" [correct] - Rename @name [imprecise] -> @job_name [precised] - Remove duplicate @template_name [Bosh v1] identical to @job_name [Bosh v2] - Rename template_name [Bosh v1] -> job_name [Bosh v2] - Rename template_spec_properties [incorrect] -> instance_group_properties [correct] - Rename instance_name [incorrect] -> instance_group_name [correct] - Rename acc [accessory?] -> accu [accumulator!] - Alias instance_plan.templates [Bosh v1] -> instance_jobs [Bosh v2] - Don't rename fields in the 'template' model (don't touch models) - Favor using spec['name'] over spec['job']['name'] (Bosh v1 naming) for obtaining the instance group name.
…g ERBs Indeed we already know the job name and template list, as these data are persisted when a release is uploaded to the director. This makes unnecessary to verify that the job name is consistent at ERB rendering time. And this consistency check is more relevant when done at the time a release job is uploaded to the director.
7d8218d
to
ce48af2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the improvements!
Due to the large diff, we are waiting for a second review, thanks for anyone that can do it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
A lot of changes, but functionally seems to be the same. A lot of great cleanup though.
Thanks!
Thanks! @bgandon |
This change appears to have exposed a problem with src/spec/assets/valid_release.tgz. Integration tests which attempt to deploy this release using a command similar to:
Fail with the following error:
This is being run from spec/integration/release/export_release_spec.rb:222 |
I didn't have time to get to the bottom of this but it looks like there is a new validation now bosh/src/bosh-director/lib/bosh/director/jobs/release/release_job.rb Lines 79 to 84 in dcb90ac
Actually this change shouldn't have any behaviour changes. @bgandon why that check was added? |
@beyhan - nice find! No need to dig in I only figured this out at the end of my yesterday. It's likely that |
The pr #2479 introduced a validation which asserts that the `name` key in `job.MF` must match the Job's name. The test fixture `valid_release.tgz` did not have an `name` key it any of the `job.MF` files. This commit updates the contents of `valid_release.tgz` so that the `name` key is present in `job.MF`. In addition to the required elements, the `.tgz` contians the un-archived job directories with the contents of the various $JOB.tgz files which are included in the release. Without these fixes on is likely to see the following error when running the integration suite: ``` Task 6 | 04:43:18 | Creating new jobs: cacher/1a (00:00:00) L Error: Inconsistent name for job 'cacher'(exptected: 'cacher', got: '') Task 6 | 04:43:18 | Error: Inconsistent name for job 'cacher'(exptected: 'cacher', got: '') ``` See #2479 (comment) for more context.
Hopefully fixed with e42f767 |
@aramprice thanks for the heads-up. I also saw that the last update of that release was way back in 2015 and had an old structure. Is the support for "bosh v1" removed with this refactoring or it was already the case and the validation here just shows it? If it is with this pr I would suggest to have this in the release notes. FYI @rkoster, @jpalermo |
I think v1 manifests should still work, I don't think release job spec file structure changed much between v1 and v2, and I would have thought it was "required" that jobs in v1 also had a name that matched their actual name. I kinda bet something blows up at some point if this isn't true, so I don't think this is really a change in behavior, probably just surfaces the error sooner. (could be wrong about all of this though) |
What is this change about?
Here, I’ve reviewed the ERB template rendering code in order to document it in the cloudfoundry/docs-bosh#813 PR.
In that part of the Director’s code, I’ve noticed many misleading use of the term “template”, used instead of “job”. And this makes the code very confusing because “template” could also refer to “ERB template”.
So, I’ve started chasing these names that had not been migrated back in 2017 (when Bosh v1→v2 refactoring effort had been conducted), and I’ve looked for more suitable names. Don’t hesitate to challenge these, by the way.
Then I’ve updated the unit tests. Here also I’ve tried to clarify some ambiguous namings.
In that process, I’ve noticed that when rendering ERB templates, the job name was read from
job.MF
, freshly extracted from the job blob, whereas the name already persisted in database. I’ve removed the unnecessary unmarshalling ofjob.MF
and added a name verification at release-upload time.The modifications in this PR are quite large overall, but I’ve paid great attention in separating this into smaller chunks of work in to the individual commits.
Please provide contextual information.
This work was done in order to gather information for authoring cloudfoundry/docs-bosh#813.
What tests have you run against this PR?
Successful run of these test suites:
How should this change be described in bosh release notes?
This change brings no new feature, and only more clarity in the ERB rendering code.
Does this PR introduce a breaking change?
Definitely not.
Tag your pair, your PM, and/or team!
I’m a poor lonesome cowboy 😄