-
Notifications
You must be signed in to change notification settings - Fork 0
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
Autodocumentation of core/orchestrator_core.go #2
base: master
Are you sure you want to change the base?
Conversation
core/orchestrator_core.go
Outdated
// Bootstrap initializes the orchestrator. | ||
// It returns an error if the orchestrator is already bootstrapped. | ||
// Returns: | ||
// - utils.BootstrapError if the orchestrator is already bootstrapped |
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.
I'm leery of these specific errors being described here. The meaning of BootstrapError is wrong, and the other two don't exist.
core/orchestrator_core.go
Outdated
@@ -283,6 +346,16 @@ func (o *TridentOrchestrator) bootstrapStorageClasses(ctx context.Context) error | |||
|
|||
// Updates the o.volumes cache with the latest backend data. This function should only edit o.volumes in place to avoid | |||
// briefly losing track of volumes that do exist. | |||
// bootstrapVolumes adds existing volumes to the orchestrator |
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 generator ignored the non-conforming comment here. A better approach might be to preserve the human-created content, not add the generated description, but add the other sections.
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.
Would the existing comments have been recognized as function documentation and formatted as such by godoc? In my code I assumed that if the comment block didn't start with "// function_name" then it was just comments rather than actual doc. I can change that and assume the opposite (and expand with parameters, returns, example)
core/orchestrator_core.go
Outdated
// Parameters: | ||
// ctx - context for the operation | ||
// Returns: | ||
// error - any error encountered |
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.
"any error encountered" ... kinda obvious!
@@ -1884,6 +2244,18 @@ func (o *TridentOrchestrator) CloneVolume( | |||
return o.cloneVolumeInitial(ctx, volumeConfig) | |||
} | |||
|
|||
// cloneVolumeInitial creates a new volume by cloning an existing volume. |
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 AI fails to distinguish the separate roles of cloneVolumeInitial()
and cloneVolumeRetry
, which are similar to the human-commented addVolumeInitial()
and addVolumeRetry()
. Deeper insight is needed to get these right, and this is a case where I would overwrite the AI content to add more color.
core/orchestrator_core.go
Outdated
@@ -2454,6 +2893,17 @@ func (o *TridentOrchestrator) GetVolumeCreatingTransaction( | |||
} | |||
} | |||
|
|||
// GetVolumeTransaction returns a volume transaction from the backend |
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.
This is simply wrong. The transaction records are kept in the persistent store, not the backends. In fact, the code here and in the called method contains no mention of a backend, so the AI is really off in the weeds here.
core/orchestrator_core.go
Outdated
@@ -3653,6 +4326,17 @@ func (o *TridentOrchestrator) ListSnapshotsForVolume( | |||
return snapshots, nil | |||
} | |||
|
|||
// ReadSnapshotsForVolume returns a list of snapshots for the specified volume |
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.
Here is another case where deeper insight would help. The previous method ListSnapshotsForVolume()
returns all snapshots cached here in the orchestrator core, while ReadSnapshotsForVolume()
invokes storage APIs to get the list of snapshots directly from a storage backend. The comment here isn't wrong, but it could be much more helpful.
core/orchestrator_core.go
Outdated
// Parameters: | ||
// backendUUID - backend to check | ||
// Returns: | ||
// (capable, error) |
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.
Odd that it has 2 on one line with no documentation.
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.
That I think I can address in my script. I am going to verify that openAi generates the expected number of lines under "// Returns"
@@ -4487,6 +5380,17 @@ func (o *TridentOrchestrator) updateBackendOnPersistentStore( | |||
return nil | |||
} | |||
|
|||
// updateVolumeOnPersistentStore updates the volume information in persistent store |
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's some inconsistency in how it generates this. Sometimes it generates "in the persistent store" and sometimes it leaves off the article "the" and just generates "persistent store".
core/orchestrator_core.go
Outdated
// Parameters: | ||
// nodeName: name of the node to get the list of VolumePublications for | ||
// Returns: | ||
// []*utils.VolumePublication: list of VolumePublications for the given node |
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.
Seems to have gotten confused and listed the type of the return []*utils.VolumePublication
, rather than the name publications
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.
Is it possible here that the name is less interesting than the type for the user? The model returned the type quite a few times in autogenerated docs elsewhere in this file.
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.
Whichever, as long as it's consistent
@@ -41,6 +41,17 @@ const ( | |||
// recordTiming is used to record in Prometheus the total time taken for an operation as follows: | |||
// defer recordTiming("backend_add")() | |||
// see also: https://play.golang.org/p/6xRXlhFdqBd | |||
// It returns an error if the backend update is invalid. |
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.
I like that the script can enhance an existing comment. How does that work with subsequent comment regeneration? Can the script still distinguish between manual and autogenerated content?
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.
Currently the whole doc for that function would be detected as "fair play" and possibly rewritten when the hash changes.
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.
Does that mean a regeneration would overwrite the original manually-generated content? That would seem problematic. I wondered if your It returns
language was a cue that anything before that was to be preserved, but I see that is frequently used by the AI. What else might work?
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.
It might overwrite the original manual content yes. But possibly that content became obsolete with the code change yes? The human writing the new code would decide whether the generated doc is acceptable. If it isn't they would updated it manually and remove the autogenerated tag?
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 hash line starts with // --
. If the script placed another delimiter line between preexisting & generated content, it could preserve the former during an update. Thoughts, @ntap-rippy?
@@ -4294,6 +5542,18 @@ func (o *TridentOrchestrator) DeleteNode(ctx context.Context, nodeName string) ( | |||
return nil | |||
} | |||
|
|||
// deleteNode deletes a node from the backend. |
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.
This is a bit misleading. As with the previous function, this one deletes a node from Trident, and it removes access to that node from all backends. We may have to push a commit atop the AI generated content to fix those things it doesn't quite grok.
Change description
Smaller PR for autodocumentation