-
Notifications
You must be signed in to change notification settings - Fork 86
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
feat: generate an instanceID #4238
base: main
Are you sure you want to change the base?
Conversation
frrist
commented
Jul 16, 2024
- The ID is based on the host running the bacalhau node, and is deterministic across re-installs and node initalization. There is no guarantee setting the ID will succeed, its a best effort.
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
8ed6d0f
to
61f27f9
Compare
8988c5f
to
f6b86c5
Compare
e0bf832
to
c1ec55c
Compare
2d2f0de
to
393ff56
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.
The diff is mixed with metadata changes, but I reviewed the instanceID commit. Looks good overall, but left a comment to fallback to uuid
// GenerateInstanceID creates a unique, anonymous identifier for the instance of bacalhau. | ||
// It combines the machine ID and MAC address to ensure uniqueness across different | ||
// environments, including virtual machines and cloud instances. |
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.
Maybe worth clarifying in the comment:
We only attempt to generate an instance id if no id was found the system_metadata
, which can happen during new node initialization or if the DataDir was wiped. We attempt to generate deterministic id for analytics purposes and track the usage of the instance.
--
Now since it is best effort, rather than failing because of errors when trying to extract the machine id or mac address, why don't we fallback to hash(uuid)
? This will be sufficient 99.999% of the time since we do persist it in the system_metadata
My other question is, if the user is running a node or a client against different networks with different DataDir
, we will assign them the same InstanceID. Maybe this is the desired behaviour, but worth thinking about
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.
There are several clarifying comments related to when we generate the instanceID, and how we persist it in the repo Open and Init methods. I think usage is well covered there. (It should be easier to grok now that I've fixed the mixed commits 😀)
Now since it is best effort, rather than failing because of errors when trying to extract the machine id or mac address, why don't we fallback to hash(uuid)?
What value would including this random string (UUID) add?
The purpose of the instanceID is to identify (anomalously) unique instances of bacalhau. I'd much prefer an empty value - which implies a value couldn't be derived - than a random string with no relationship to the actual instance. My preference is to leave the field empty if it couldn't be derived.
This will be sufficient 99.999% of the time since we do persist it in the system_metadata
I've made a small change since your last review: We now generate and persist an instanceID when the repo is first initialized and also each time the repo is opened. This ensures the instanceID is associated with the machine running bacalhau, even if the repo is copied to a different machine. In this sense we are treating the system_metadata.yaml
file a bit like a cache. In work to follow this, we can read the instanceID from the system_metadata.yaml
file and include it in the job metadata and/or HTTP headers when an instance interacts with the network.
My other question is, if the user is running a node or a client against different networks with different DataDir, we will assign them the same InstanceID. Maybe this is the desired behaviour, but worth thinking about
Right, I think this behavior makes sense. The same instance of bacalhau is free to interact with many networks. A measure of this interaction could be derived be counting the number of different networks an instance has interactions with.
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.
What value would including this random string (UUID) add?
The purpose of the instanceID is to identify (anomalously) unique instances of bacalhau. I'd much prefer an empty value - which implies a value couldn't be derived - than a random string with no relationship to the actual instance. My preference is to leave the field empty if it couldn't be derived.
How a persisted UUID doesn't provide a relationship to the instance? Our goal is to identify the instance the jobs are submitted from (client) or executing the job (node). Assigning and persisting a UUID when you first initialize the client/node is more than enough and fulfils this purpose. What you are trying to do here with generating idempotent IDs is just to handle the edge cases where the repo is deleted and we still want to tag jobs with the same instance, which is great, but lets treat it as best effort and fallback to UUID instead of not tracking at all
Keep in mind this means we only attempt to generate an ID if no ID was found in the system_metadata.yaml, and don't attempt to override the value
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.
Can you address these comments so we can close the PR?
82a1b40
to
a8a86b1
Compare
c1ec55c
to
6d31889
Compare
a8a86b1
to
2a747d7
Compare
6d31889
to
6bdfde4
Compare
- The ID is based on the host running the bacalhau node, and is deterministic across re-installs and node initalization. There is no guarantee setting the ID will succeed, its a best effort.
675a410
to
951c8ad
Compare
Lets avoid having PRs open for too long. It gets more difficult to review things again after weeks, and I am sure it gets difficult for you as well |
I will close this and re-open when there is a strong need for it. |
@frrist there is a strong need for having a persisted InstanceID in the job spec as we've removed the ClientID, and not persisting the InstallationID anymore |