Skip to content

Autodocumentation of core/orchestrator_core.go#2

Open
jeromeroussin wants to merge 3 commits into
masterfrom
autodoc_mini
Open

Autodocumentation of core/orchestrator_core.go#2
jeromeroussin wants to merge 3 commits into
masterfrom
autodoc_mini

Conversation

@jeromeroussin

Copy link
Copy Markdown
Owner

Change description

Smaller PR for autodocumentation

Comment thread core/orchestrator_core.go Outdated
Comment thread 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

Copy link
Copy Markdown

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.

Comment thread core/orchestrator_core.go Outdated

// 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

Copy link
Copy Markdown

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.

@jeromeroussin jeromeroussin Jun 9, 2022

Copy link
Copy Markdown
Owner Author

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)

Comment thread core/orchestrator_core.go Outdated
// Parameters:
// ctx - context for the operation
// Returns:
// error - any error encountered

Copy link
Copy Markdown

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!

Comment thread core/orchestrator_core.go Outdated
Comment thread core/orchestrator_core.go
return o.cloneVolumeInitial(ctx, volumeConfig)
}

// cloneVolumeInitial creates a new volume by cloning an existing volume.

Copy link
Copy Markdown

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.

Comment thread core/orchestrator_core.go Outdated
}
}

// GetVolumeTransaction returns a volume transaction from the backend

Copy link
Copy Markdown

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.

Comment thread core/orchestrator_core.go Outdated
Comment thread core/orchestrator_core.go
Comment thread core/orchestrator_core.go Outdated
return snapshots, nil
}

// ReadSnapshotsForVolume returns a list of snapshots for the specified volume

Copy link
Copy Markdown

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.

Comment thread core/orchestrator_core.go
Comment thread core/orchestrator_core.go Outdated
Comment thread core/orchestrator_core.go Outdated
// Parameters:
// backendUUID - backend to check
// Returns:
// (capable, error)

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Owner Author

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"

Comment thread core/orchestrator_core.go
return nil
}

// updateVolumeOnPersistentStore updates the volume information in persistent store

Copy link
Copy Markdown

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".

Comment thread 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

@ntap-rippy ntap-rippy Jun 9, 2022

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Owner Author

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.

Copy link
Copy Markdown

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

Comment thread core/orchestrator_core.go Outdated
Comment thread core/orchestrator_core.go
// 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.

Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Owner Author

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.

@clintonk clintonk Jul 11, 2022

Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Owner Author

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?

Copy link
Copy Markdown

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?

Comment thread core/orchestrator_core.go
Comment thread core/orchestrator_core.go
Comment thread core/orchestrator_core.go
return nil
}

// deleteNode deletes a node from the backend.

Copy link
Copy Markdown

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.

Comment thread core/orchestrator_core.go
Comment thread core/orchestrator_core.go
Comment thread core/orchestrator_core.go
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