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

Check if node is virtualized #521

Merged
merged 9 commits into from
Feb 13, 2020
Merged

Check if node is virtualized #521

merged 9 commits into from
Feb 13, 2020

Conversation

maximevanhees
Copy link
Contributor

@maximevanhees maximevanhees commented Feb 12, 2020

Checks if the 3Node is a virtual machine or not using virt-what

Thanks to @muhamadazmy for the help!

@codecov
Copy link

codecov bot commented Feb 12, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@6c12261). Click here to learn what that means.
The diff coverage is 27.27%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #521   +/-   ##
=========================================
  Coverage          ?   36.26%           
=========================================
  Files             ?       75           
  Lines             ?     5066           
  Branches          ?        0           
=========================================
  Hits              ?     1837           
  Misses            ?     2963           
  Partials          ?      266
Impacted Files Coverage Δ
pkg/zinit/service.go 26.66% <ø> (ø)
pkg/storage/filesystem/btrfs.go 8.08% <ø> (ø)
pkg/container/opts.go 14.66% <ø> (ø)
pkg/provision/zdb.go 44.16% <ø> (ø)
pkg/identity/store.go 0% <ø> (ø)
pkg/schema/types.go 63.2% <ø> (ø)
pkg/gedis/commands_provision.go 42.57% <0%> (ø)
...ypes/provision/tfgrid_workloads_reservation_k8s.go 0% <0%> (ø)
pkg/upgrade/upgrade.go 0% <0%> (ø)
pkg/capacity/dmi/dmi.go 80.53% <100%> (ø)
... and 2 more

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 6c12261...e2d992a. Read the comment docs.

pkg/capacity/capacity.go Outdated Show resolved Hide resolved
qemu/overlay/bin/virt-what Outdated Show resolved Hide resolved
pkg/capacity/store.go Outdated Show resolved Hide resolved
pkg/capacity/capacity.go Outdated Show resolved Hide resolved
pkg/capacity/store.go Outdated Show resolved Hide resolved
pkg/capacity/store.go Outdated Show resolved Hide resolved
pkg/gedis/commands_capacity.go Outdated Show resolved Hide resolved
pkg/gedis/types/directory/tfgrid_node_2.go Outdated Show resolved Hide resolved
tools/bcdb_mock/nodes_store.go Outdated Show resolved Hide resolved
@zaibon zaibon added this to the 0.2.1 milestone Feb 13, 2020
@zaibon zaibon linked an issue Feb 13, 2020 that may be closed by this pull request
5 tasks
@@ -140,14 +140,15 @@ func (s *nodeStore) updateUptime(nodeID string, uptime int64) error {
return nil
}

func (s *nodeStore) StoreProof(nodeID string, dmi dmi.DMI, disks capacity.Disks) error {
func (s *nodeStore) StoreProof(nodeID string, dmi dmi.DMI, disks capacity.Disks, hypervisor string) error {
Copy link
Member

Choose a reason for hiding this comment

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

@zaibon this method signature is becoming too long, shouldn't we create (or reuse) one of the structures that already have these attributes? (same applies for other methods regarding capacity registration)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep I was thinking the same.

pkg/capacity/capacity.go Outdated Show resolved Hide resolved
node, err := s.Get(nodeID)
if err != nil {
return err
}

proof := directory.TfgridNodeProof1{
Created: schema.Date{Time: time.Now()},
Created: schema.Date{Time: time.Now()},
Hypervisor: hypervisor,
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually this is not enough. You will see in the code down, that it is possible that we do not store the proof variable:

for _, p := range node.Proofs {
if proof.Equal(p) {
return nil
}
}

I would replace this block with

// don't save the proof if we already have one with the same
	// hash/content
	for i := range node.Proofs {
		if proof.Equal(node.Proofs[i]) {
			// always update hypervisor content
			node.Proofs[i].Hypervisor = hypervisor
			return nil
		}
	}

So we ensure that we always update the content of hypervisor even if the proof is already known and we do not store a new one.

out = bytes.TrimSpace(out)
return s, nil
str := strings.TrimSpace(string(out))
if len(str) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@zaibon zaibon merged commit 2e54093 into master Feb 13, 2020
@zaibon zaibon deleted the virt-what_implementation branch February 13, 2020 10:12
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.

Detect if 3Node is physical hardware or virtual machine
3 participants