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

Gauravgahlot/new data model #27

Merged
merged 16 commits into from
Jun 22, 2020
Merged

Gauravgahlot/new data model #27

merged 16 commits into from
Jun 22, 2020

Conversation

kqdeng
Copy link
Contributor

@kqdeng kqdeng commented May 8, 2020

Ref: RFC #2 New Hardware data model

Abstracting type Discovery into an interface to settle the differences between the new and old hardware data models.

Changes:

  • Added an envvar DATA_MODEL_VERSION to switch between the old cacher model and the new tinkerbell model
    • if envvar is unset/empty/anything other than 1, it will default to using the old cacher data model
  • Abstracted Discovery and Hardware among others to take into account new data model

TODO:

  • remove the replace in go.mod pointing to my fork
  • squash some of the commits

Related PRs:
hegel: tinkerbell/hegel#13
tink: tinkerbell/tink#64

@kqdeng kqdeng force-pushed the gauravgahlot/new-data-model branch 2 times, most recently from c096453 to 66f0887 Compare May 26, 2020 23:43
@kqdeng kqdeng force-pushed the gauravgahlot/new-data-model branch from 1094d2f to fb349de Compare May 28, 2020 16:15
@kqdeng kqdeng force-pushed the gauravgahlot/new-data-model branch from a085553 to 8ecd0d6 Compare June 2, 2020 19:08
@kqdeng kqdeng requested a review from yetang-equinix June 10, 2020 19:09
func (j *Job) setup(d *packet.Discovery) error {
mode, netConfig := d.Mode(j.mac), d.NetConfig(j.mac)
j.Logger = joblog.With("mac", j.mac, "hardware.id", d.Hardware.ID)
func (j *Job) setup(dp *packet.Discovery) error {
Copy link

@yetang-equinix yetang-equinix Jun 11, 2020

Choose a reason for hiding this comment

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

It will be nice to have a comments for this function, what will it do? processing dhcp discovery packet? not looks like it .
Same comment goes to all other files and function in tinkerbell suite, too little comment.

baseURL *url.URL
consumerToken string
authToken string
hardwareClient hardwareGetter
}

func NewClient(consumerToken, authToken string, baseURL *url.URL) (*Client, error) {

Choose a reason for hiding this comment

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

Is this for DHCP client? wondering why we need client functions here in boots

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 hardwareClient refers to the tink/cacher clients responsible for getting the hardware data, see the usage here: https://github.com/tinkerbell/boots/blob/8ecd0d6d08f11d4d6e4bdb9c6b4893815e060ac9/packet/client.go#L46

Choose a reason for hiding this comment

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

as discussed move to workflow

Copy link

@yetang-equinix yetang-equinix left a comment

Choose a reason for hiding this comment

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

have several comments not directly related to your change set. I could not quite follow boots software flow here, hope can have 20 min walk through

@@ -0,0 +1,160 @@
package packet

Choose a reason for hiding this comment

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

We have models.go, models_cacher.go, models_tinkerbell.go. As we discussed, it will nice to have file header comments to briefly describe which is for what.

@kqdeng kqdeng force-pushed the gauravgahlot/new-data-model branch 3 times, most recently from f2e2f27 to a75fa92 Compare June 16, 2020 19:14
yetang-equinix
yetang-equinix previously approved these changes Jun 17, 2020
Copy link

@yetang-equinix yetang-equinix left a comment

Choose a reason for hiding this comment

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

went through the new changes, can see changes according to our discussion.
For some style related comments, like more informational file header and function header comments, we can do that later. But every time we touch a file or a function is an opportunity to add those.

yetang-equinix
yetang-equinix previously approved these changes Jun 22, 2020
@kqdeng kqdeng merged commit 6c77348 into master Jun 22, 2020
@kqdeng kqdeng deleted the gauravgahlot/new-data-model branch June 22, 2020 18:31
@mmlb mmlb mentioned this pull request Jul 8, 2020
3 tasks
mergify bot added a commit that referenced this pull request Jul 9, 2020
## Description

<!--- Please describe what this PR is going to change -->

Change from pointers to interface to just an interface for the recent data model split. Took the opportunity to clean up some of the related tests so they would be more correct (when setting env vars) / easier to follow (making TestNewDiscoveryMismatch not panic). 

## Why is this needed

<!--- Link to issue you have raised -->

I think #27 was merged prematurely. Lots of commented out code that should have been deleted, oddness in the pointer-to-interface and some hard to follow tests. This is me polishing some of that up.

Fixes: #

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

`go test ./...`


## How are existing users impacted? What migration steps/scripts do we need?

<!--- Fixes a bug, unblocks installation, removes a component of the stack etc -->
<!--- Requires a DB migration script, etc. -->

No anticipated impact.

## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [x] added unit or e2e tests
- [ ] provided instructions on how to upgrade
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