From acc653f90b6e8b86cbefbd87a15c10a38dd561de Mon Sep 17 00:00:00 2001 From: "Roussin, Jerome" Date: Thu, 26 May 2022 21:59:25 -0400 Subject: [PATCH 1/3] Autodocumentation of core/orchestrator_core.go --- core/orchestrator_core.go | 1003 +++++++++++++++++++++++++++++++++++++ 1 file changed, 1003 insertions(+) diff --git a/core/orchestrator_core.go b/core/orchestrator_core.go index 378d92fd4..c855a8790 100644 --- a/core/orchestrator_core.go +++ b/core/orchestrator_core.go @@ -54,6 +54,17 @@ func recordTiming(operation string, err *error) func() { } } +// recordTransactionTiming records the duration of a transaction +// Parameters: +// txn: the transaction to record +// err: the error from the transaction +// Returns: +// nothing +// Example: +// recordTransactionTiming(txn, err) +// +// -- Doc autogenerated on 2022-05-26 19:15:06. Function hash: d39f7d63300a6cea90e7402ac7280126 -- + func recordTransactionTiming(txn *storage.VolumeTransaction, err *error) { if txn == nil || txn.VolumeCreatingConfig == nil { // for unit tests, there will be no txn to record @@ -108,6 +119,21 @@ func NewTridentOrchestrator(client persistentstore.Client) *TridentOrchestrator } } +// transformPersistentState transforms the Trident API objects on the persistent store to the +// current version. +// It returns an error if the transformation fails. +// Parameters: +// ctx - context for the operation +// Returns: +// error - error if the operation fails +// Example: +// err := o.transformPersistentState(ctx) +// if err != nil { +// return fmt.Errorf("couldn't transform persistent state: %v", err) +// } +// +// -- Doc autogenerated on 2022-05-26 19:15:25. Function hash: c9019c1c63e1407926e156160bcba2b4 -- + func (o *TridentOrchestrator) transformPersistentState(ctx context.Context) error { version, err := o.storeClient.GetVersion(ctx) if err != nil && persistentstore.MatchKeyNotFoundErr(err) { @@ -141,6 +167,26 @@ func (o *TridentOrchestrator) transformPersistentState(ctx context.Context) erro return nil } +// Bootstrap is called to initialize the orchestrator. +// It returns an error if the orchestrator cannot be initialized. +// Returns: +// - nil if the orchestrator is initialized successfully +// - utils.BootstrapError if the orchestrator cannot be initialized +// Example: +// o := &Orchestrator{} +// err := o.Bootstrap() +// if err != nil { +// if utils.IsBootstrapError(err) { +// // The orchestrator is not initialized successfully +// } else { +// // Some other error occurred +// } +// } else { +// // The orchestrator is initialized successfully +// } +// +// -- Doc autogenerated on 2022-05-26 19:16:18. Function hash: 04dcb5d2d9ba6669a7ec6f5734590b4e -- + func (o *TridentOrchestrator) Bootstrap() error { ctx := GenerateRequestContext(context.Background(), "", ContextSourceInternal) var err error @@ -170,6 +216,18 @@ func (o *TridentOrchestrator) Bootstrap() error { return nil } +// bootstrapBackends is called during startup to load backends from the persistent store +// and add them to the orchestrator. +// It returns an error if any backends fail to initialize. +// Parameters: +// ctx - context +// Returns: +// error - if any backends fail to initialize +// Example: +// err := o.bootstrapBackends(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:16:38. Function hash: ace19e963152e034bd3e2ad4e44efd2a -- + func (o *TridentOrchestrator) bootstrapBackends(ctx context.Context) error { persistentBackends, err := o.storeClient.GetBackends(ctx) if err != nil { @@ -261,6 +319,21 @@ func (o *TridentOrchestrator) bootstrapBackends(ctx context.Context) error { return nil } +// bootstrapStorageClasses loads the existing storage classes from the backend +// and adds them to the orchestrator. +// It returns an error if the storage classes cannot be retrieved. +// Parameters: +// ctx - context for the operation +// Returns: +// error - if the storage classes cannot be retrieved +// Example: +// err := o.bootstrapStorageClasses(ctx) +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:17:04. Function hash: 21a98ba2c9aed0a70ca745011194074a -- + func (o *TridentOrchestrator) bootstrapStorageClasses(ctx context.Context) error { persistentStorageClasses, err := o.storeClient.GetStorageClasses(ctx) if err != nil { @@ -283,6 +356,20 @@ 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 is called during startup to load the volumes from the backend store. +// It returns a map of volumes keyed by the volume name. +// Parameters: +// ctx - the context for the current operation +// Returns: +// error - if any errors occurred +// Example: +// volumes, err := o.bootstrapVolumes(ctx) +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:17:24. Function hash: 713a6e9aafc3998ba2508038c533087d -- + func (o *TridentOrchestrator) bootstrapVolumes(ctx context.Context) error { volumes, err := o.storeClient.GetVolumes(ctx) if err != nil { @@ -335,6 +422,17 @@ func (o *TridentOrchestrator) bootstrapVolumes(ctx context.Context) error { return nil } +// bootstrapSnapshots loads all existing snapshots from the backend and adds them to the orchestrator's snapshot map. +// It returns an error if the snapshot cannot be added to the map. +// Parameters: +// ctx - context +// Returns: +// error - error if the snapshot cannot be added to the map +// Example: +// err := o.bootstrapSnapshots(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:17:44. Function hash: 7cc86ef066af5a6d4d4cccf2aaacc362 -- + func (o *TridentOrchestrator) bootstrapSnapshots(ctx context.Context) error { snapshots, err := o.storeClient.GetSnapshots(ctx) if err != nil { @@ -369,6 +467,18 @@ func (o *TridentOrchestrator) bootstrapSnapshots(ctx context.Context) error { return nil } +// bootstrapVolTxns retrieves volume transaction logs from the persistent store and +// attempts to replay them. +// It returns an error if any of the transactions fail to replay. +// Parameters: +// ctx - context +// Returns: +// error - error +// Example: +// err := bootstrapVolTxns(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:18:10. Function hash: e33c0ea45aaa4a9d8262fd4f04ac4667 -- + func (o *TridentOrchestrator) bootstrapVolTxns(ctx context.Context) error { volTxns, err := o.storeClient.GetVolumeTransactions(ctx) if err != nil && !persistentstore.MatchKeyNotFoundErr(err) { @@ -385,6 +495,17 @@ func (o *TridentOrchestrator) bootstrapVolTxns(ctx context.Context) error { return nil } +// bootstrapNodes bootstraps the orchestrator with existing nodes. +// It returns an error if any node fails to bootstrap. +// Parameters: +// ctx - context +// Returns: +// error - error if any node fails to bootstrap +// Example: +// err := o.bootstrapNodes(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:18:36. Function hash: 7cfe94c5ecbb68533b741378eaa5ee46 -- + func (o *TridentOrchestrator) bootstrapNodes(ctx context.Context) error { // Don't bootstrap nodes if we're not CSI if config.CurrentDriverContext != config.ContextCSI { @@ -409,6 +530,17 @@ func (o *TridentOrchestrator) bootstrapNodes(ctx context.Context) error { return nil } +// bootstrapVolumePublications bootstraps the volume publications from the store +// It returns an error if the store is unavailable. +// Parameters: +// ctx - context for logging +// Returns: +// error - nil if successful +// Example: +// err := o.bootstrapVolumePublications(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:19:01. Function hash: feea1b84b5d4a911d16860d0c211b775 -- + func (o *TridentOrchestrator) bootstrapVolumePublications(ctx context.Context) error { // Don't bootstrap volume publications if we're not CSI if config.CurrentDriverContext != config.ContextCSI { @@ -430,6 +562,16 @@ func (o *TridentOrchestrator) bootstrapVolumePublications(ctx context.Context) e return nil } +// addVolumePublicationToCache adds a volume publication to the cache +// Parameters: +// vp - volume publication to be added +// Returns: +// none +// Example: +// o.addVolumePublicationToCache(vp) +// +// -- Doc autogenerated on 2022-05-26 19:19:21. Function hash: 6831b1fc734710c782e9132682016e51 -- + func (o *TridentOrchestrator) addVolumePublicationToCache(vp *utils.VolumePublication) { // If the volume has no entry we need to initialize the inner map if o.volumePublications[vp.VolumeName] == nil { @@ -438,6 +580,18 @@ func (o *TridentOrchestrator) addVolumePublicationToCache(vp *utils.VolumePublic o.volumePublications[vp.VolumeName][vp.NodeName] = vp } +// bootstrap loads the persistent store and initializes the orchestrator +// state. +// It returns an error if the bootstrap fails. +// Parameters: +// ctx - context for the bootstrap +// Returns: +// error - error if the bootstrap fails +// Example: +// err := o.bootstrap(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:19:55. Function hash: bcd99e963177e37d4f93a0ee26ad9890 -- + func (o *TridentOrchestrator) bootstrap(ctx context.Context) error { // Fetching backend information @@ -548,6 +702,23 @@ func (o *TridentOrchestrator) updateMetrics() { } } +// handleFailedTransaction attempts to clean up after a failed transaction. +// This is called when we bootstrap and find a transaction in the persistent +// store that has not been marked as completed. +// It returns an error if it is unable to clean up the transaction. +// Parameters: +// ctx - context.Context object +// v - volume transaction object +// Returns: +// error - error object +// Example: +// err := o.handleFailedTransaction(ctx, v) +// if err != nil { +// return fmt.Errorf("failed to clean up failed transaction: %v", err) +// } +// +// -- Doc autogenerated on 2022-05-26 19:20:18. Function hash: 39541d951f05903909338f9e59963947 -- + func (o *TridentOrchestrator) handleFailedTransaction(ctx context.Context, v *storage.VolumeTransaction) error { switch v.Op { case storage.AddVolume, storage.DeleteVolume, @@ -785,6 +956,19 @@ func (o *TridentOrchestrator) handleFailedTransaction(ctx context.Context, v *st return nil } +// resetImportedVolumeName attempts to rename a volume to its original name. +// This is used when a volume is imported and the user wants to rename it. +// It returns an error if the volume could not be found. +// Parameters: +// ctx - context +// volume - volume to rename +// Returns: +// error - error if the volume could not be found +// Example: +// err := o.resetImportedVolumeName(ctx, volume) +// +// -- Doc autogenerated on 2022-05-26 19:20:47. Function hash: 1033950f7f2014fd8a87dbfb93781f51 -- + func (o *TridentOrchestrator) resetImportedVolumeName(ctx context.Context, volume *storage.VolumeConfig) error { // The volume could be renamed (notManaged = false) without being persisted. // If the volume wasn't added to the persistent store, we attempt to rename @@ -801,6 +985,17 @@ func (o *TridentOrchestrator) resetImportedVolumeName(ctx context.Context, volum return nil } +// AddFrontend adds a frontend plugin to the orchestrator +// Parameters: +// f - frontend plugin +// Returns: +// none +// Example: +// o := NewTridentOrchestrator() +// o.AddFrontend(rest.NewTridentREST()) +// +// -- Doc autogenerated on 2022-05-26 19:21:08. Function hash: be80e16a539796ac4231803c9351df2d -- + func (o *TridentOrchestrator) AddFrontend(f frontend.Plugin) { name := f.GetName() if _, ok := o.frontends[name]; ok { @@ -811,6 +1006,18 @@ func (o *TridentOrchestrator) AddFrontend(f frontend.Plugin) { o.frontends[name] = f } +// GetFrontend returns a frontend plugin by name +// Parameters: +// ctx - context +// name - name of the frontend to get +// Returns: +// frontend.Plugin - the requested frontend plugin +// error - an error if one occurs +// Example: +// fe, err := o.GetFrontend(ctx, "iscsi") +// +// -- Doc autogenerated on 2022-05-26 19:21:25. Function hash: 68c5aa2cdd27528e7d82eb37fe73b601 -- + func (o *TridentOrchestrator) GetFrontend(ctx context.Context, name string) (frontend.Plugin, error) { if fe, ok := o.frontends[name]; !ok { err := fmt.Errorf("requested frontend %s does not exist", name) @@ -821,6 +1028,21 @@ func (o *TridentOrchestrator) GetFrontend(ctx context.Context, name string) (fro } } +// validateBackendUpdate validates that a backend update is allowed. +// It returns an error if the update is not allowed. +// Parameters: +// oldBackend - the old backend object +// newBackend - the new backend object +// Returns: +// error - if the update is not allowed +// Example: +// err := o.validateBackendUpdate(oldBackend, newBackend) +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:22:18. Function hash: 80555ddd7f23803234d84705cd8e72e3 -- + func (o *TridentOrchestrator) validateBackendUpdate(oldBackend, newBackend storage.Backend) error { // Validate that backend type isn't being changed as backend type has // implications for the internal volume names. @@ -833,6 +1055,20 @@ func (o *TridentOrchestrator) validateBackendUpdate(oldBackend, newBackend stora return nil } +// GetVersion returns the version of the orchestrator +// Parameters: +// context - context for the request +// Returns: +// version - version of the orchestrator +// error - any error encountered +// Example: +// version, err := orchestrator.GetVersion(context) +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:22:34. Function hash: b3ff28ff24fcdaca9fca3da6aa509290 -- + func (o *TridentOrchestrator) GetVersion(context.Context) (string, error) { return config.OrchestratorVersion.String(), o.bootstrapError } @@ -1363,6 +1599,20 @@ func (o *TridentOrchestrator) updateBackendState( return backend.ConstructExternal(ctx), o.storeClient.UpdateBackend(ctx, backend) } +// getBackendUUIDByBackendName returns the backend UUID for the given backend name +// Parameters: +// backendName - the name of the backend +// Returns: +// backendUUID - the UUID of the backend +// error - if an error occurred +// Example: +// backendUUID, err := o.getBackendUUIDByBackendName("trident") +// if err != nil { +// log.Errorf("Could not get backend UUID for 'trident': %v", err) +// } +// +// -- Doc autogenerated on 2022-05-26 19:22:52. Function hash: 3432223f3c321828475a38387539f630 -- + func (o *TridentOrchestrator) getBackendUUIDByBackendName(backendName string) (string, error) { backendUUID := "" for _, b := range o.backends { @@ -1374,6 +1624,17 @@ func (o *TridentOrchestrator) getBackendUUIDByBackendName(backendName string) (s return "", utils.NotFoundError(fmt.Sprintf("backend %v was not found", backendName)) } +// getBackendByBackendName returns the backend with the given backendName +// Parameters: +// backendName - the name of the backend to return +// Returns: +// storage.Backend - the backend object +// error - nil if the backend was found, error if not +// Example: +// backend, err := o.getBackendByBackendName(backendName) +// +// -- Doc autogenerated on 2022-05-26 19:23:11. Function hash: 5359cbb6a4e1cb6e05469580d3214563 -- + func (o *TridentOrchestrator) getBackendByBackendName(backendName string) (storage.Backend, error) { for _, b := range o.backends { if b.Name() == backendName { @@ -1383,6 +1644,17 @@ func (o *TridentOrchestrator) getBackendByBackendName(backendName string) (stora return nil, utils.NotFoundError(fmt.Sprintf("backend %v was not found", backendName)) } +// getBackendByConfigRef returns a backend based on the configRef +// Parameters: +// configRef - the configRef of the backend to return +// Returns: +// storage.Backend - the backend based on the configRef +// error - non-nil if an error occurs +// Example: +// b, err := o.getBackendByConfigRef("trident-config") +// +// -- Doc autogenerated on 2022-05-26 19:23:28. Function hash: 37e7727af627a51a35149814c5e420af -- + func (o *TridentOrchestrator) getBackendByConfigRef(configRef string) (storage.Backend, error) { for _, b := range o.backends { if b.ConfigRef() == configRef { @@ -1392,6 +1664,17 @@ func (o *TridentOrchestrator) getBackendByConfigRef(configRef string) (storage.B return nil, utils.NotFoundError(fmt.Sprintf("backend based on configRef '%v' was not found", configRef)) } +// getBackendByBackendUUID returns the backend with the specified UUID +// Parameters: +// backendUUID - the UUID of the backend +// Returns: +// storage.Backend - the backend with the specified UUID +// error - any error encountered +// Example: +// backend, err := o.getBackendByBackendUUID("6b1f6af3-6d1d-43b9-b2e0-a0d8f8e8a5e7") +// +// -- Doc autogenerated on 2022-05-26 19:24:23. Function hash: 5b6c42a570cd7be7efb047a76057cbdd -- + func (o *TridentOrchestrator) getBackendByBackendUUID(backendUUID string) (storage.Backend, error) { backend := o.backends[backendUUID] if backend != nil { @@ -1400,6 +1683,18 @@ func (o *TridentOrchestrator) getBackendByBackendUUID(backendUUID string) (stora return nil, utils.NotFoundError(fmt.Sprintf("backend uuid %v was not found", backendUUID)) } +// GetBackend returns the backend object for the given backend name. +// Parameters: +// ctx - context for logging +// backendName - name of the backend +// Returns: +// backendExternal - backend object +// err - error if any +// Example: +// backendExternal, err := orchestrator.GetBackend(ctx, backendName) +// +// -- Doc autogenerated on 2022-05-26 19:24:40. Function hash: 97ea7edf0258bdf4ee62e165318ef219 -- + func (o *TridentOrchestrator) GetBackend( ctx context.Context, backendName string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1431,6 +1726,18 @@ func (o *TridentOrchestrator) GetBackend( return backendExternal, nil } +// GetBackendByBackendUUID returns a backend by its UUID. +// Parameters: +// ctx - context +// backendUUID - UUID of the backend to retrieve +// Returns: +// *storage.BackendExternal - the backend +// error - any error encountered +// Example: +// backend, err := orchestrator.GetBackendByBackendUUID(ctx, "f0c4d4a4-4dac-4a1b-b5a0-e53d9c827e3a") +// +// -- Doc autogenerated on 2022-05-26 19:25:07. Function hash: 81d8fa64dc1b3803acd28fbacf4b0287 -- + func (o *TridentOrchestrator) GetBackendByBackendUUID( ctx context.Context, backendUUID string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1459,6 +1766,17 @@ func (o *TridentOrchestrator) GetBackendByBackendUUID( return backendExternal, nil } +// ListBackends returns a list of all backends known to the orchestrator. +// Parameters: +// ctx - The context for the current request +// Returns: +// List of backends +// Any errors encountered +// Example: +// backends, err := orchestrator.ListBackends(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:25:25. Function hash: 2d98525f51bd5d6b7df26ff8693141e9 -- + func (o *TridentOrchestrator) ListBackends( ctx context.Context, ) (backendExternals []*storage.BackendExternal, err error) { @@ -1482,6 +1800,18 @@ func (o *TridentOrchestrator) ListBackends( return backends, nil } +// DeleteBackend deletes a backend from the orchestrator +// It returns an error if the backend does not exist +// Parameters: +// ctx - logging context +// backendName - name of the backend to delete +// Returns: +// error - any error encountered +// Example: +// err := o.DeleteBackend(ctx, "backend-01") +// +// -- Doc autogenerated on 2022-05-26 19:25:46. Function hash: dac0943d6e46a81a0f9787f5f6ef64f3 -- + func (o *TridentOrchestrator) DeleteBackend(ctx context.Context, backendName string) (err error) { if o.bootstrapError != nil { Logc(ctx).WithFields(log.Fields{ @@ -1503,6 +1833,19 @@ func (o *TridentOrchestrator) DeleteBackend(ctx context.Context, backendName str return o.deleteBackendByBackendUUID(ctx, backendName, backendUUID) } +// DeleteBackendByBackendUUID deletes a backend by backend UUID +// It returns an error if the backend does not exist +// Parameters: +// ctx - context +// backendName - name of backend +// backendUUID - UUID of backend +// Returns: +// error - error if any +// Example: +// err := o.DeleteBackendByBackendUUID(ctx, "myBackend", "myBackendUUID") +// +// -- Doc autogenerated on 2022-05-26 19:26:10. Function hash: ade56985c915048a2ff8350f698c0690 -- + func (o *TridentOrchestrator) DeleteBackendByBackendUUID( ctx context.Context, backendName, backendUUID string, ) (err error) { @@ -1522,6 +1865,19 @@ func (o *TridentOrchestrator) DeleteBackendByBackendUUID( return o.deleteBackendByBackendUUID(ctx, backendName, backendUUID) } +// deleteBackendByBackendUUID deletes a backend by backendUUID +// It returns an error if the backend was not found +// Parameters: +// ctx - context +// backendName - name of backend +// backendUUID - UUID of backend +// Returns: +// error - error if backend was not found +// Example: +// err := deleteBackendByBackendUUID(ctx, "myBackend", "myBackendUUID") +// +// -- Doc autogenerated on 2022-05-26 19:26:35. Function hash: 2568753d63d7e3305bdc4b1ea5d422de -- + func (o *TridentOrchestrator) deleteBackendByBackendUUID(ctx context.Context, backendName, backendUUID string) error { Logc(ctx).WithFields(log.Fields{ "backendName": backendName, @@ -1600,6 +1956,19 @@ func (o *TridentOrchestrator) RemoveBackendConfigRef(ctx context.Context, backen return o.storeClient.UpdateBackend(ctx, b) } +// AddVolume creates a new volume +// It returns the volume and an error if any +// Parameters: +// ctx - context for the operation +// volumeConfig - volume config +// Returns: +// volume - volume created +// error - error if any +// Example: +// volume, err := o.AddVolume(ctx, volumeConfig) +// +// -- Doc autogenerated on 2022-05-26 19:26:54. Function hash: 6b3abc4db9d4558bf39248381f6e73e6 -- + func (o *TridentOrchestrator) AddVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -1853,6 +2222,19 @@ func (o *TridentOrchestrator) addVolumeFinish( return externalVol, nil } +// CloneVolume clones a volume from an existing volume +// It returns the volume config and a boolean indicating if the volume was created +// Parameters: +// ctx - context +// volumeConfig - volume config +// Returns: +// externalVol - volume external +// err - error +// Example: +// cloneVolume, err := o.CloneVolume(ctx, volumeConfig) +// +// -- Doc autogenerated on 2022-05-26 19:27:16. Function hash: 3b05245cf8d531e1b7e704f1d7673887 -- + func (o *TridentOrchestrator) CloneVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -1884,6 +2266,22 @@ func (o *TridentOrchestrator) CloneVolume( return o.cloneVolumeInitial(ctx, volumeConfig) } +// cloneVolumeInitial creates a clone of an existing volume. +// It returns the new volume and an error if one occurred. +// Parameters: +// ctx - the context +// volumeConfig - the configuration of the new volume +// Returns: +// externalVol - the new volume +// err - any error encountered +// Example: +// vol, err := orchestrator.cloneVolumeInitial(ctx, volumeConfig) +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:27:43. Function hash: 3f83112418a823bdafb4b150c3214f8e -- + func (o *TridentOrchestrator) cloneVolumeInitial( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2025,6 +2423,19 @@ func (o *TridentOrchestrator) cloneVolumeInitial( return o.addVolumeFinish(ctx, txn, vol, backend, pool) } +// cloneVolumeRetry attempts to clone a volume on a backend. +// It returns the volume and backend if successful, or an error. +// Parameters: +// ctx - context +// txn - volume transaction +// Returns: +// externalVol - volume +// err - error +// Example: +// externalVol, err := cloneVolumeRetry(ctx, txn) +// +// -- Doc autogenerated on 2022-05-26 19:28:03. Function hash: d3195084da6ca49594299f21956d774c -- + func (o *TridentOrchestrator) cloneVolumeRetry( ctx context.Context, txn *storage.VolumeTransaction, ) (externalVol *storage.VolumeExternal, err error) { @@ -2154,6 +2565,18 @@ func (o *TridentOrchestrator) GetVolumeByInternalName( return "", utils.NotFoundError(fmt.Sprintf("volume %s not found", volumeInternal)) } +// validateImportVolume validates the volume +// It returns an error if the volume is not valid +// Parameters: +// volumeConfig - volume config +// backend - backend +// Returns: +// error - error +// Example: +// err := validateImportVolume(volumeConfig, backend) +// +// -- Doc autogenerated on 2022-05-26 19:28:28. Function hash: 0b239a8ef621ed2e08adbc4c80a11281 -- + func (o *TridentOrchestrator) validateImportVolume(ctx context.Context, volumeConfig *storage.VolumeConfig) error { backend, err := o.getBackendByBackendUUID(volumeConfig.ImportBackendUUID) if err != nil { @@ -2215,6 +2638,20 @@ func (o *TridentOrchestrator) validateImportVolume(ctx context.Context, volumeCo return nil } +// LegacyImportVolume imports a volume into Trident. +// It returns the volume's external representation. +// Parameters: +// volumeConfig - volume configuration +// backendName - name of backend where volume should be imported +// notManaged - true if Trident should not manage the volume +// Returns: +// *storage.VolumeExternal - volume's external representation +// error - error, if any +// Example: +// volumeExternal, err := orchestrator.LegacyImportVolume(ctx, volumeConfig, backendName, notManaged) +// +// -- Doc autogenerated on 2022-05-26 19:28:57. Function hash: f8c072d23374263c1a818a13bc96fac1 -- + func (o *TridentOrchestrator) LegacyImportVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, backendName string, notManaged bool, createPVandPVC VolumeCallback, @@ -2305,6 +2742,19 @@ func (o *TridentOrchestrator) LegacyImportVolume( return volExternal, nil } +// ImportVolume imports a volume from a backend +// It returns the volume's external representation +// Parameters: +// volumeConfig - configuration for the volume to be imported +// backendUUID - UUID of the backend where the volume is located +// Returns: +// externalVol - external representation of the volume +// err - error if any +// Example: +// externalVol, err := orchestrator.ImportVolume(ctx, volumeConfig, backendUUID) +// +// -- Doc autogenerated on 2022-05-26 19:29:24. Function hash: caf9bc105080edc2f7b86c15a43a3f1e -- + func (o *TridentOrchestrator) ImportVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2435,6 +2885,18 @@ func (o *TridentOrchestrator) AddVolumeTransaction(ctx context.Context, volTxn * return o.storeClient.AddVolumeTransaction(ctx, volTxn) } +// GetVolumeCreatingTransaction returns the volume transaction for the given volume config. +// Parameters: +// ctx - context for the operation +// config - volume config +// Returns: +// *storage.VolumeTransaction - volume transaction +// error - error, if any +// Example: +// txn, err := orchestrator.GetVolumeCreatingTransaction(ctx, config) +// +// -- Doc autogenerated on 2022-05-26 19:29:49. Function hash: 4025deb561dc0aba9e0fa596740664b8 -- + func (o *TridentOrchestrator) GetVolumeCreatingTransaction( ctx context.Context, config *storage.VolumeConfig, ) (*storage.VolumeTransaction, error) { @@ -2454,6 +2916,18 @@ func (o *TridentOrchestrator) GetVolumeCreatingTransaction( } } +// GetVolumeTransaction returns a volume transaction from the store +// Parameters: +// ctx - context for the request +// volTxn - volume transaction to return +// Returns: +// *storage.VolumeTransaction - volume transaction from the store +// error - error if one occurred +// Example: +// volTxn, err := o.GetVolumeTransaction(ctx, volTxn) +// +// -- Doc autogenerated on 2022-05-26 19:30:03. Function hash: d8a638429c4b2c3043bb0281d5c34490 -- + func (o *TridentOrchestrator) GetVolumeTransaction( ctx context.Context, volTxn *storage.VolumeTransaction, ) (*storage.VolumeTransaction, error) { @@ -2578,6 +3052,24 @@ func (o *TridentOrchestrator) addVolumeRetryCleanup( return err } +// importVolumeCleanup is called when an error occurs during volume import. +// It attempts to clean up any artifacts of the +// It returns an error if it was unable to clean up. +// Parameters: +// ctx - context +// err - error that occurred during import +// volumeConfig - the volume config +// volTxn - the volume transaction +// Returns: +// error - error if it was unable to clean up +// Example: +// err := importVolumeCleanup(ctx, err, volumeConfig, volTxn) +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:30:32. Function hash: f5e220ffc92fbb12521834e8dbc438aa -- + func (o *TridentOrchestrator) importVolumeCleanup( ctx context.Context, err error, volumeConfig *storage.VolumeConfig, volTxn *storage.VolumeTransaction, ) error { @@ -2632,6 +3124,18 @@ func (o *TridentOrchestrator) importVolumeCleanup( return err } +// GetVolume returns a volume by name +// Parameters: +// ctx - context for logging +// volume - volume name +// Returns: +// *storage.VolumeExternal - volume object +// error - error object +// Example: +// volume, err := orchestrator.GetVolume(ctx, "volume1") +// +// -- Doc autogenerated on 2022-05-26 19:30:48. Function hash: 7b809028c4c2d34e481ebd4d9ceadcdf -- + func (o *TridentOrchestrator) GetVolume( ctx context.Context, volume string, ) (volExternal *storage.VolumeExternal, err error) { @@ -2647,6 +3151,18 @@ func (o *TridentOrchestrator) GetVolume( return o.getVolume(ctx, volume) } +// getVolume returns a volume +// Parameters: +// ctx - context (for logging) +// volume - name of the volume +// Returns: +// *storage.VolumeExternal - the volume +// error - error, if any +// Example: +// volume, err := o.getVolume(ctx, "volume1") +// +// -- Doc autogenerated on 2022-05-26 19:31:02. Function hash: a3180f3812fb8b86173ca5c119bc52db -- + func (o *TridentOrchestrator) getVolume( _ context.Context, volume string, ) (volExternal *storage.VolumeExternal, err error) { @@ -2657,6 +3173,17 @@ func (o *TridentOrchestrator) getVolume( return vol.ConstructExternal(), nil } +// GetDriverTypeForVolume returns the driver +// Parameters: +// vol *storage.VolumeExternal +// Returns: +// string +// error +// Example: +// driverType, err := orchestrator.GetDriverTypeForVolume(vol) +// +// -- Doc autogenerated on 2022-05-26 19:31:17. Function hash: fa6bc896c59ce9a936c5679fd5c658b9 -- + func (o *TridentOrchestrator) GetDriverTypeForVolume(_ context.Context, vol *storage.VolumeExternal) (string, error) { if o.bootstrapError != nil { return config.UnknownDriver, o.bootstrapError @@ -2679,6 +3206,18 @@ func (o *TridentOrchestrator) getDriverTypeForVolume(backendUUID string) (string return config.UnknownDriver, nil } +// GetVolumeType returns the volume +// Parameters: +// vol *storage.VolumeExternal +// Returns volumeType config.VolumeType, err error +// Returns: +// volumeType config.VolumeType +// err error +// Example: +// volumeType, err := o.GetVolumeType(vol) +// +// -- Doc autogenerated on 2022-05-26 19:31:54. Function hash: 38bae4a9a9ca7f54bb863b2c10a6fe6e -- + func (o *TridentOrchestrator) GetVolumeType( _ context.Context, vol *storage.VolumeExternal, ) (volumeType config.VolumeType, err error) { @@ -2712,6 +3251,17 @@ func (o *TridentOrchestrator) GetVolumeType( return } +// ListVolumes returns a list of volumes +// Parameters: +// context - context for logging +// Return: +// []*storage.VolumeExternal - list of volumes +// error - error, if any +// Example: +// volumes, err := orchestrator.ListVolumes(context.Background()) +// +// -- Doc autogenerated on 2022-05-26 19:32:09. Function hash: 85d4a8042740926b2d85a28566cb3403 -- + func (o *TridentOrchestrator) ListVolumes(context.Context) (volumes []*storage.VolumeExternal, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -2829,6 +3379,19 @@ func (o *TridentOrchestrator) deleteVolume(ctx context.Context, volumeName strin return nil } +// deleteVolumeFromPersistentStoreIgnoreError deletes the volume from the persistent store, +// ignoring any errors if the volume is not found. +// It returns an error if the volume is found but cannot be deleted. +// Parameters: +// ctx - context for logging +// volume - the volume to be deleted +// Returns: +// error - any error encountered +// Example: +// err := o.deleteVolumeFromPersistentStoreIgnoreError(ctx, volume) +// +// -- Doc autogenerated on 2022-05-26 19:32:28. Function hash: c2bcad7a430c67f70288fd3b95d63886 -- + func (o *TridentOrchestrator) deleteVolumeFromPersistentStoreIgnoreError( ctx context.Context, volume *storage.Volume, ) error { @@ -2902,6 +3465,19 @@ func (o *TridentOrchestrator) DeleteVolume(ctx context.Context, volumeName strin return o.deleteVolume(ctx, volumeName) } +// ListVolumesByPlugin lists all volumes for a given plugin +// It returns a list of volumes and an error +// Parameters: +// ctx - the context for the operation +// pluginName - the name of the plugin +// Returns: +// volumes - a list of volumes +// error - any error encountered +// Example: +// volumes, err := o.ListVolumesByPlugin(ctx, pluginName) +// +// -- Doc autogenerated on 2022-05-26 19:33:06. Function hash: 60b8076f3180c5e202ffbeeef30d97b0 -- + func (o *TridentOrchestrator) ListVolumesByPlugin( _ context.Context, pluginName string, ) (volumes []*storage.VolumeExternal, err error) { @@ -2926,6 +3502,19 @@ func (o *TridentOrchestrator) ListVolumesByPlugin( return volumes, nil } +// PublishVolume publishes a volume to a node +// It returns an error if the volume is not found or is being deleted +// Parameters: +// ctx - context +// volumeName - name of the volume to publish +// publishInfo - information about the nodes to publish to +// Returns: +// error - error if there was a problem publishing the volume +// Example: +// err := o.PublishVolume(ctx, volumeName, publishInfo) +// +// -- Doc autogenerated on 2022-05-26 19:33:29. Function hash: b7313803948e3a02c08b72fd07dd08d0 -- + func (o *TridentOrchestrator) PublishVolume( ctx context.Context, volumeName string, publishInfo *utils.VolumePublishInfo, ) (err error) { @@ -2977,6 +3566,19 @@ func (o *TridentOrchestrator) PublishVolume( return nil } +// UnpublishVolume unpublishes a volume from a node. +// It returns an error if the volume is not published to the node. +// Parameters: +// ctx - context +// volumeName - name of the volume +// nodeName - name of the node +// Returns: +// error - any error encountered +// Example: +// err := orchestrator.UnpublishVolume(ctx, "volume1", "node1") +// +// -- Doc autogenerated on 2022-05-26 19:33:59. Function hash: 8051f44dc4b6fa47e354a66dd188ad29 -- + func (o *TridentOrchestrator) UnpublishVolume(ctx context.Context, volumeName, nodeName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -3341,6 +3943,19 @@ func (o *TridentOrchestrator) addSnapshotCleanup( return err } +// GetSnapshot returns a snapshot object +// Parameters: +// ctx - context for the request +// volumeName - name of the volume +// snapshotName - name of the snapshot +// Returns: +// SnapshotExternal object +// error - error object if operation failed or nil if operation succeeds +// Example: +// snapshotExternal, err := orchestrator.GetSnapshot(ctx, "MyVolume", "MySnapshot") +// +// -- Doc autogenerated on 2022-05-26 19:35:04. Function hash: e989ccf35cebc85380ef65b188fb3054 -- + func (o *TridentOrchestrator) GetSnapshot( ctx context.Context, volumeName, snapshotName string, ) (snapshotExternal *storage.SnapshotExternal, err error) { @@ -3356,6 +3971,24 @@ func (o *TridentOrchestrator) GetSnapshot( return o.getSnapshot(ctx, volumeName, snapshotName) } +// getSnapshot returns the snapshot with the specified name. +// Parameters: +// ctx - context for the request +// volumeName - name of the volume containing the snapshot +// snapshotName - name of the snapshot to return +// Returns: +// *storage.SnapshotExternal - the snapshot with the specified name +// error - any error encountered while retrieving the snapshot +// Example: +// snapshot, err := o.getSnapshot(ctx, "vol1", "snap1") +// if err != nil { +// log.Errorf("Could not get snapshot %v: %v", "snap1", err) +// } else { +// log.Infof("Snapshot %v found: %v", "snap1", snapshot) +// } +// +// -- Doc autogenerated on 2022-05-26 19:35:24. Function hash: b64251745b9e500e060496470970c425 -- + func (o *TridentOrchestrator) getSnapshot( ctx context.Context, volumeName, snapshotName string, ) (*storage.SnapshotExternal, error) { @@ -3374,6 +4007,19 @@ func (o *TridentOrchestrator) getSnapshot( } } +// updateSnapshot updates the snapshot state in the orchestrator and persistent store +// It returns the snapshot and an error if one occurred +// Parameters: +// ctx - context for the request +// snapshot - the snapshot to update +// Return: +// *storage.Snapshot - the updated snapshot +// error - error if one occurred +// Example: +// updatedSnapshot, err := o.updateSnapshot(ctx, snapshot) +// +// -- Doc autogenerated on 2022-05-26 19:35:40. Function hash: 325d46cbf1273d5ada4aee5aad9d18fc -- + func (o *TridentOrchestrator) updateSnapshot( ctx context.Context, snapshot *storage.Snapshot, ) (*storage.Snapshot, error) { @@ -3471,6 +4117,22 @@ func (o *TridentOrchestrator) deleteSnapshot(ctx context.Context, snapshotConfig return nil } +// deleteSnapshotFromPersistentStoreIgnoreError deletes a snapshot from the persistent store, ignoring any errors +// that may occur if the snapshot is not present in the store. +// It returns an error if the snapshot is present in the store but cannot be deleted. +// Parameters: +// ctx - context +// snapshot - snapshot to delete +// Return: +// error - if the snapshot is present in the store but cannot be deleted +// Example: +// err := deleteSnapshotFromPersistentStoreIgnoreError(ctx, snapshot) +// if err != nil { +// // Unable to delete snapshot from persistent store. +// } +// +// -- Doc autogenerated on 2022-05-26 19:36:01. Function hash: 3d9299843d219334e59de17ceccabde9 -- + func (o *TridentOrchestrator) deleteSnapshotFromPersistentStoreIgnoreError( ctx context.Context, snapshot *storage.Snapshot, ) error { @@ -3587,6 +4249,17 @@ func (o *TridentOrchestrator) DeleteSnapshot(ctx context.Context, volumeName, sn return o.deleteSnapshot(ctx, snapshot.Config) } +// ListSnapshots returns a list of all snapshots +// Parameters: +// context - The context of the request +// Returns: +// []*storage.SnapshotExternal - A list of snapshots +// error - Any error encountered +// Example: +// snapshots, err := orchestrator.ListSnapshots(context.Background()) +// +// -- Doc autogenerated on 2022-05-26 19:36:26. Function hash: d08dffcc2af9a6d1f09139abdd3c8e33 -- + func (o *TridentOrchestrator) ListSnapshots(context.Context) (snapshots []*storage.SnapshotExternal, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -3605,6 +4278,18 @@ func (o *TridentOrchestrator) ListSnapshots(context.Context) (snapshots []*stora return snapshots, nil } +// ListSnapshotsByName returns a list of snapshots with the given name +// Parameters: +// ctx - context.Context object for the API call +// snapshotName - name of the snapshot to list +// Returns: +// list of snapshots with the given name +// error - if there was an error listing the snapshots +// Example: +// snapshots, err := orchestrator.ListSnapshotsByName(ctx, "mySnapshot") +// +// -- Doc autogenerated on 2022-05-26 19:36:47. Function hash: 053cf2d47c2f1434c21a089a0fbeb072 -- + func (o *TridentOrchestrator) ListSnapshotsByName( _ context.Context, snapshotName string, ) (snapshots []*storage.SnapshotExternal, err error) { @@ -3627,6 +4312,19 @@ func (o *TridentOrchestrator) ListSnapshotsByName( return snapshots, nil } +// ListSnapshotsForVolume lists all snapshots for a given volume +// It returns a list of SnapshotExternal objects +// Parameters: +// ctx - context +// volumeName - name of the volume +// Returns: +// []*storage.SnapshotExternal - list of SnapshotExternal objects +// error - error object +// Example: +// snapshots, err := c.ListSnapshotsForVolume(ctx, "vol1") +// +// -- Doc autogenerated on 2022-05-26 19:37:11. Function hash: 623db3c5dd57eabbdc24f51e0e61b3a0 -- + func (o *TridentOrchestrator) ListSnapshotsForVolume( _ context.Context, volumeName string, ) (snapshots []*storage.SnapshotExternal, err error) { @@ -3653,6 +4351,18 @@ func (o *TridentOrchestrator) ListSnapshotsForVolume( return snapshots, nil } +// ReadSnapshotsForVolume returns a list of snapshots for the given volume. +// Parameters: +// ctx - context for logging +// volumeName - name of the volume to query +// Returns: +// []*storage.SnapshotExternal - a list of snapshots for the given volume +// error - error, if any +// Example: +// externalSnapshots, err := tridentOrchestrator.ReadSnapshotsForVolume(ctx, volumeName) +// +// -- Doc autogenerated on 2022-05-26 19:37:28. Function hash: ccd4d329e169484695ad148c14dfbf12 -- + func (o *TridentOrchestrator) ReadSnapshotsForVolume( ctx context.Context, volumeName string, ) (externalSnapshots []*storage.SnapshotExternal, err error) { @@ -3680,6 +4390,17 @@ func (o *TridentOrchestrator) ReadSnapshotsForVolume( return externalSnapshots, nil } +// ReloadVolumes is called when the volumes have changed. +// It returns an error if the reload failed. +// Parameters: +// ctx - context for logging +// Returns: +// error - any error encountered +// Example: +// err := o.ReloadVolumes(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:37:58. Function hash: 5f5aebb4e5d30c072efd3c62cb1564b0 -- + func (o *TridentOrchestrator) ReloadVolumes(ctx context.Context) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -3938,6 +4659,19 @@ func (o *TridentOrchestrator) getProtocol( return res.protocol, res.err } +// AddStorageClass adds a storage class to the orchestrator. +// It returns the storage class, or an error if the storage class already exists. +// Parameters: +// ctx - context (for logging) +// scConfig - the storage class configuration +// Return: +// *storageclass.External - the storage class +// error - error, if any +// Example: +// sc, err := o.AddStorageClass(ctx, &storageclass.Config{Name: "sc1"}) +// +// -- Doc autogenerated on 2022-05-26 19:38:27. Function hash: 7dd9fefe2646ed78b243a4d6e24b7079 -- + func (o *TridentOrchestrator) AddStorageClass( ctx context.Context, scConfig *storageclass.Config, ) (scExternal *storageclass.External, err error) { @@ -3976,6 +4710,21 @@ func (o *TridentOrchestrator) AddStorageClass( return sc.ConstructExternal(ctx), nil } +// GetStorageClass returns the storage class with the specified name +// Parameters: +// ctx - Context for the request +// scName - Name of the storage class to retrieve +// Returns: +// *storageclass.External - Storage class object +// error - Any errors encountered +// Example: +// sc, err := orchestrator.GetStorageClass(ctx, "scName") +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:38:44. Function hash: 8ea7a3398086c800c66845416db5fef0 -- + func (o *TridentOrchestrator) GetStorageClass( ctx context.Context, scName string, ) (scExternal *storageclass.External, err error) { @@ -3997,6 +4746,17 @@ func (o *TridentOrchestrator) GetStorageClass( return sc.ConstructExternal(ctx), nil } +// ListStorageClasses returns a list of storage classes +// Parameters: +// ctx - context for the operation +// Returns: +// a list of storage class objects +// an error or nil if successful +// Example: +// storageClasses, err := orchestrator.ListStorageClasses(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:39:02. Function hash: 1d060e4f98ef90c4e6fd57ca995cef7d -- + func (o *TridentOrchestrator) ListStorageClasses(ctx context.Context) ( scExternals []*storageclass.External, err error, ) { @@ -4016,6 +4776,21 @@ func (o *TridentOrchestrator) ListStorageClasses(ctx context.Context) ( return storageClasses, nil } +// DeleteStorageClass deletes a storage class +// It returns an error if the storage class does not exist +// Parameters: +// ctx - context for logging +// scName - name of the storage class to delete +// Returns: +// error - error if the storage class could not be deleted +// Example: +// err := orchestrator.DeleteStorageClass(ctx, "scName") +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:39:40. Function hash: 7a09523cfb169968ae4a2c6a92941083 -- + func (o *TridentOrchestrator) DeleteStorageClass(ctx context.Context, scName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -4047,6 +4822,20 @@ func (o *TridentOrchestrator) DeleteStorageClass(ctx context.Context, scName str return nil } +// reconcileNodeAccessOnAllBackends reconciles node access on all backends. +// It returns an error if any backend fails to reconcile. +// Parameters: +// ctx - context for logging +// Return: +// error - error if any backend fails to reconcile +// Example: +// err := o.reconcileNodeAccessOnAllBackends(ctx) +// if err != nil { +// log.Error("Error during node access reconciliation") +// } +// +// -- Doc autogenerated on 2022-05-26 19:39:59. Function hash: 05c9e184edcad2ea38d16deda4378f81 -- + func (o *TridentOrchestrator) reconcileNodeAccessOnAllBackends(ctx context.Context) error { if config.CurrentDriverContext != config.ContextCSI { return nil @@ -4067,6 +4856,21 @@ func (o *TridentOrchestrator) reconcileNodeAccessOnAllBackends(ctx context.Conte return nil } +// reconcileNodeAccessOnBackend reconciles node access for a backend +// It returns an error if the operation fails +// Parameters: +// ctx - context +// b - backend +// Returns: +// error - error if the operation fails +// Example: +// err := o.reconcileNodeAccessOnBackend(ctx, b) +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:40:37. Function hash: 32894d9e525f95bbcc5fd8c4512369cf -- + func (o *TridentOrchestrator) reconcileNodeAccessOnBackend(ctx context.Context, b storage.Backend) error { if config.CurrentDriverContext != config.ContextCSI { return nil @@ -4124,6 +4928,22 @@ func (o *TridentOrchestrator) PeriodicallyReconcileNodeAccessOnBackends() { } } +// AddNode adds a node to the orchestrator +// It returns an error if the node already exists +// Parameters: +// ctx +// node - the node to add +// nodeEventCallback - callback function to call when a node event occurs +// Returns: +// error - any error encountered +// Example: +// err := o.AddNode(ctx, node, nodeEventCallback) +// if err != nil { +// log.Errorf("Could not add node %v: %v", node.Name, err) +// } +// +// -- Doc autogenerated on 2022-05-26 19:41:13. Function hash: cd542a37d4abbbf6ed9a5b48b6c67621 -- + func (o *TridentOrchestrator) AddNode( ctx context.Context, node *utils.Node, nodeEventCallback NodeEventCallback, ) (err error) { @@ -4166,12 +4986,33 @@ func (o *TridentOrchestrator) AddNode( return nil } +// invalidateAllBackendNodeAccess invalidates the node access for all backends +// Returns: +// None +// Example: +// orchestrator.invalidateAllBackendNodeAccess() +// +// -- Doc autogenerated on 2022-05-26 19:41:26. Function hash: 217366d8152ca1accdb52538ef405299 -- + func (o *TridentOrchestrator) invalidateAllBackendNodeAccess() { for _, backend := range o.backends { backend.InvalidateNodeAccess() } } +// handleUpdatedNodePrep handles node prep status updates +// Parameters: +// ctx - context +// protocol - protocol for which node prep is being reported +// node - node for which node prep is being reported +// nodeEventCallback - callback to invoke to report node prep status +// Returns: +// none +// Example: +// o.handleUpdatedNodePrep(ctx, "NFS", node, nodeEventCallback) +// +// -- Doc autogenerated on 2022-05-26 19:42:06. Function hash: a834161b9eb4a27bfbb289d967a44a23 -- + func (o *TridentOrchestrator) handleUpdatedNodePrep( ctx context.Context, protocol string, node *utils.Node, nodeEventCallback NodeEventCallback, ) { @@ -4213,6 +5054,22 @@ func (o *TridentOrchestrator) handleUpdatedNodePrep( } } +// GetNode returns the node object from the orchestrator +// Parameters: +// ctx - context for logging +// nName - name of the node to retrieve +// Returns: +// node - the node object from the orchestrator +// err - any error encountered +// Example: +// node, err := o.GetNode(ctx, "node1") +// if err != nil { +// return err +// } +// fmt.Println(node.Name) +// +// -- Doc autogenerated on 2022-05-26 19:42:35. Function hash: 8adb5cc590b1e328ec136e1d38883212 -- + func (o *TridentOrchestrator) GetNode(ctx context.Context, nName string) (node *utils.Node, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -4233,6 +5090,17 @@ func (o *TridentOrchestrator) GetNode(ctx context.Context, nName string) (node * return node, nil } +// ListNodes returns a list of all nodes in the cluster +// Parameters: +// context - context for the call +// Returns: +// nodes - a list of all nodes in the cluster +// err - error, if any +// Example: +// nodes, err := tridentOrchestrator.ListNodes(context) +// +// -- Doc autogenerated on 2022-05-26 19:42:59. Function hash: 9bdd3a6d45b81df549bbe35f26aeeb85 -- + func (o *TridentOrchestrator) ListNodes(context.Context) (nodes []*utils.Node, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -4250,6 +5118,18 @@ func (o *TridentOrchestrator) ListNodes(context.Context) (nodes []*utils.Node, e return nodes, nil } +// DeleteNode removes the node from the orchestrator. +// It returns an error if the node is not found. +// Parameters: +// ctx - context (for cancellation) +// nodeName - name of the node +// Returns: +// error - any error encountered +// Example: +// err := orchestrator.DeleteNode(ctx, "node1") +// +// -- Doc autogenerated on 2022-05-26 19:43:18. Function hash: f40063d78d89136a99089e4c9c2b95a7 -- + func (o *TridentOrchestrator) DeleteNode(ctx context.Context, nodeName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -4294,6 +5174,18 @@ func (o *TridentOrchestrator) DeleteNode(ctx context.Context, nodeName string) ( return nil } +// deleteNode deletes a node from the orchestrator +// It returns an error if the node does not exist +// Parameters: +// ctx - context +// nodeName - name of the node to delete +// Returns: +// error - error if the node does not exist +// Example: +// err := o.deleteNode(ctx, nodeName) +// +// -- Doc autogenerated on 2022-05-26 19:43:41. Function hash: 06e53486e08860cbb879e4101d6a9c68 -- + func (o *TridentOrchestrator) deleteNode(ctx context.Context, nodeName string) (err error) { node, found := o.nodes[nodeName] if !found { @@ -4391,6 +5283,16 @@ func (o *TridentOrchestrator) ListVolumePublicationsForVolume( return } +// listVolumePublicationsForVolume returns all publications for a volume +// Parameters: +// volumeName: name of the volume +// Returns: +// []*utils.VolumePublication: list of publications for the volume +// Example: +// publications := o.listVolumePublicationsForVolume(ctx, volumeName) +// +// -- Doc autogenerated on 2022-05-26 19:43:56. Function hash: 44ca89b928a2986ee3de364f14767cb3 -- + func (o *TridentOrchestrator) listVolumePublicationsForVolume( _ context.Context, volumeName string, ) (publications []*utils.VolumePublication) { @@ -4418,6 +5320,16 @@ func (o *TridentOrchestrator) ListVolumePublicationsForNode( return } +// listVolumePublicationsForNode returns a list of volume publications for the given node +// Parameters: +// nodeName - the name of the node +// Return: +// a list of volume publications for the given node +// Example: +// publications, err := o.listVolumePublicationsForNode(nodeName) +// +// -- Doc autogenerated on 2022-05-26 19:44:12. Function hash: 8341522491607108df10aca16d8bc332 -- + func (o *TridentOrchestrator) listVolumePublicationsForNode( _ context.Context, nodeName string, ) (publications []*utils.VolumePublication) { @@ -4456,6 +5368,17 @@ func (o *TridentOrchestrator) DeleteVolumePublication(ctx context.Context, volum return nil } +// removeVolumePublicationFromCache removes the volume publication from the cache +// Parameters: +// volumeID - the volume's unique ID +// nodeID - the node's unique ID +// Returns: +// None +// Example: +// o.removeVolumePublicationFromCache("volume-123", "node-123") +// +// -- Doc autogenerated on 2022-05-26 19:44:35. Function hash: 0edde50e382bbe37edba87d678249a5a -- + func (o *TridentOrchestrator) removeVolumePublicationFromCache(volumeID, nodeID string) { delete(o.volumePublications[volumeID], nodeID) // If there are no more nodes for this volume, remove the volume's entry @@ -4464,6 +5387,21 @@ func (o *TridentOrchestrator) removeVolumePublicationFromCache(volumeID, nodeID } } +// updateBackendOnPersistentStore updates the backend on the persistent store +// It returns an error if the backend could not be updated +// Parameters: +// ctx - context for logging +// backend - the backend to update +// newBackend - whether this is a new backend or an existing one +// Returns: +// error - error if the backend could not be updated +// Example: +// if err := o.updateBackendOnPersistentStore(ctx, backend, newBackend); err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:45:16. Function hash: 0b8bff03ea76c0c057f27c6fad87a4db -- + func (o *TridentOrchestrator) updateBackendOnPersistentStore( ctx context.Context, backend storage.Backend, newBackend bool, ) error { @@ -4487,6 +5425,21 @@ func (o *TridentOrchestrator) updateBackendOnPersistentStore( return nil } +// updateVolumeOnPersistentStore updates the volume information in persistent store +// It returns an error if the volume is not found in persistent store +// Parameters: +// ctx - context for logging +// vol - volume to be updated +// Returns: +// error - error if any +// Example: +// err := o.updateVolumeOnPersistentStore(ctx, vol) +// if err != nil { +// return err +// } +// +// -- Doc autogenerated on 2022-05-26 19:45:40. Function hash: c4edd3c8428fe8edb94d43e360c1775a -- + func (o *TridentOrchestrator) updateVolumeOnPersistentStore(ctx context.Context, vol *storage.Volume) error { // Update the volume information in persistent store Logc(ctx).WithFields(log.Fields{ @@ -4498,6 +5451,19 @@ func (o *TridentOrchestrator) updateVolumeOnPersistentStore(ctx context.Context, return o.storeClient.UpdateVolume(ctx, vol) } +// replaceBackendAndUpdateVolumesOnPersistentStore updates the backend and volume information in persistent store +// It returns an error if the backend or volume information could not be updated. +// Parameters: +// ctx - context +// origBackend - original backend +// newBackend - new backend +// Return: +// error - error if the backend or volume information could not be updated +// Example: +// err := o.replaceBackendAndUpdateVolumesOnPersistentStore(ctx, origBackend, newBackend) +// +// -- Doc autogenerated on 2022-05-26 19:46:10. Function hash: a493110fffae19fac507baac4b3502e7 -- + func (o *TridentOrchestrator) replaceBackendAndUpdateVolumesOnPersistentStore( ctx context.Context, origBackend, newBackend storage.Backend, ) error { @@ -4509,6 +5475,17 @@ func (o *TridentOrchestrator) replaceBackendAndUpdateVolumesOnPersistentStore( return o.storeClient.ReplaceBackendAndUpdateVolumes(ctx, origBackend, newBackend) } +// isCRDContext returns true if the context is from a CRD request +// Parameters: +// ctx - the context +// Returns: +// bool - true if the context is from a CRD request +// Example: +// ctx := context.WithValue(context.Background(), ContextKeyRequestSource, ContextSourceCRD) +// isCRD := o.isCRDContext(ctx) +// +// -- Doc autogenerated on 2022-05-26 19:47:01. Function hash: fac4a506fe93e8407310464685f2985d -- + func (o *TridentOrchestrator) isCRDContext(ctx context.Context) bool { ctxSource := ctx.Value(ContextKeyRequestSource) return ctxSource != nil && ctxSource == ContextSourceCRD @@ -4606,6 +5583,18 @@ func (o *TridentOrchestrator) GetMirrorStatus( return mirrorBackend.GetMirrorStatus(ctx, localVolumeHandle, remoteVolumeHandle) } +// CanBackendMirror returns whether the backend is capable of mirroring +// Parameters: +// context - The context +// backendUUID - The backend UUID +// Returns: +// capable - Whether the backend is mirror capable +// err - Any errors +// Example: +// capable, err := trident.CanBackendMirror(ctx, backendUUID) +// +// -- Doc autogenerated on 2022-05-26 19:47:24. Function hash: bc1b19ddd30247a2154212e70860764d -- + func (o *TridentOrchestrator) CanBackendMirror(_ context.Context, backendUUID string) (capable bool, err error) { if o.bootstrapError != nil { return false, o.bootstrapError @@ -4645,6 +5634,20 @@ func (o *TridentOrchestrator) ReleaseMirror( return mirrorBackend.ReleaseMirror(ctx, localVolumeHandle) } +// GetCHAP retrieves the CHAP information for a volume +// It returns the CHAP information for the volume, or an error if the volume does not exist +// Parameters: +// ctx - context +// volumeName - name of the volume +// nodeName - name of the node +// Returns: +// chapInfo - CHAP information for the volume +// err - error if any +// Example: +// chapInfo, err := orchestrator.GetCHAP(ctx, "vol01", "node01") +// +// -- Doc autogenerated on 2022-05-26 19:47:55. Function hash: 235deca5df832ab0568e48718d1e814c -- + func (o *TridentOrchestrator) GetCHAP( ctx context.Context, volumeName, nodeName string, ) (chapInfo *utils.IscsiChapInfo, err error) { From 1bd27a14116a534506682982442a6e7f60686600 Mon Sep 17 00:00:00 2001 From: "Roussin, Jerome" Date: Fri, 27 May 2022 08:50:53 -0400 Subject: [PATCH 2/3] Fixed bug around handling of 'type' and extraneous line after doc --- core/orchestrator_core.go | 1193 ++++++++++++++++++------------------- 1 file changed, 569 insertions(+), 624 deletions(-) diff --git a/core/orchestrator_core.go b/core/orchestrator_core.go index c855a8790..8ec6b5ae8 100644 --- a/core/orchestrator_core.go +++ b/core/orchestrator_core.go @@ -54,17 +54,21 @@ func recordTiming(operation string, err *error) func() { } } -// recordTransactionTiming records the duration of a transaction +// recordTransactionTiming records the duration of a transaction in milliseconds +// and whether it was successful or not. // Parameters: // txn: the transaction to record -// err: the error from the transaction +// err: the error that occurred, or nil if no error occurred // Returns: // nothing // Example: -// recordTransactionTiming(txn, err) +// err := c.transaction(func(txn *storage.VolumeTransaction) error { +// // do something +// return nil +// }) +// recordTransactionTiming(txn, &err) // -// -- Doc autogenerated on 2022-05-26 19:15:06. Function hash: d39f7d63300a6cea90e7402ac7280126 -- - +// -- Doc autogenerated on 2022-05-26 22:14:22. Function hash: d39f7d63300a6cea90e7402ac7280126 -- func recordTransactionTiming(txn *storage.VolumeTransaction, err *error) { if txn == nil || txn.VolumeCreatingConfig == nil { // for unit tests, there will be no txn to record @@ -119,21 +123,20 @@ func NewTridentOrchestrator(client persistentstore.Client) *TridentOrchestrator } } -// transformPersistentState transforms the Trident API objects on the persistent store to the -// current version. +// transformPersistentState transforms the persistent state from previous versions to the current +// version. // It returns an error if the transformation fails. // Parameters: -// ctx - context for the operation +// ctx - context for logging // Returns: -// error - error if the operation fails +// error - error if the transformation fails // Example: // err := o.transformPersistentState(ctx) // if err != nil { -// return fmt.Errorf("couldn't transform persistent state: %v", err) +// return err // } // -// -- Doc autogenerated on 2022-05-26 19:15:25. Function hash: c9019c1c63e1407926e156160bcba2b4 -- - +// -- Doc autogenerated on 2022-05-26 22:14:49. Function hash: c9019c1c63e1407926e156160bcba2b4 -- func (o *TridentOrchestrator) transformPersistentState(ctx context.Context) error { version, err := o.storeClient.GetVersion(ctx) if err != nil && persistentstore.MatchKeyNotFoundErr(err) { @@ -167,26 +170,16 @@ func (o *TridentOrchestrator) transformPersistentState(ctx context.Context) erro return nil } -// Bootstrap is called to initialize the orchestrator. -// It returns an error if the orchestrator cannot be initialized. +// Bootstrap initializes the orchestrator. +// It returns an error if the orchestrator is already bootstrapped. // Returns: -// - nil if the orchestrator is initialized successfully -// - utils.BootstrapError if the orchestrator cannot be initialized +// - utils.BootstrapError if the orchestrator is already bootstrapped +// - utils.PersistentStoreError if there is an error reading from the persistent store +// - utils.OrchestratorError if there is an error bootstrapping the orchestrator // Example: -// o := &Orchestrator{} // err := o.Bootstrap() -// if err != nil { -// if utils.IsBootstrapError(err) { -// // The orchestrator is not initialized successfully -// } else { -// // Some other error occurred -// } -// } else { -// // The orchestrator is initialized successfully -// } // -// -- Doc autogenerated on 2022-05-26 19:16:18. Function hash: 04dcb5d2d9ba6669a7ec6f5734590b4e -- - +// -- Doc autogenerated on 2022-05-26 22:15:25. Function hash: 04dcb5d2d9ba6669a7ec6f5734590b4e -- func (o *TridentOrchestrator) Bootstrap() error { ctx := GenerateRequestContext(context.Background(), "", ContextSourceInternal) var err error @@ -216,18 +209,19 @@ func (o *TridentOrchestrator) Bootstrap() error { return nil } -// bootstrapBackends is called during startup to load backends from the persistent store -// and add them to the orchestrator. -// It returns an error if any backends fail to initialize. +// bootstrapBackends is used to initialize the backends from the persistent store. +// It returns an error if there is a problem reading the backends from the persistent store. // Parameters: -// ctx - context +// ctx - context // Returns: -// error - if any backends fail to initialize +// error - error if there is a problem reading the backends from the persistent store. // Example: -// err := o.bootstrapBackends(ctx) +// err := bootstrapBackends(ctx) +// if err != nil { +// log.Errorf("Could not bootstrap backends: %v", err) +// } // -// -- Doc autogenerated on 2022-05-26 19:16:38. Function hash: ace19e963152e034bd3e2ad4e44efd2a -- - +// -- Doc autogenerated on 2022-05-26 22:16:21. Function hash: ace19e963152e034bd3e2ad4e44efd2a -- func (o *TridentOrchestrator) bootstrapBackends(ctx context.Context) error { persistentBackends, err := o.storeClient.GetBackends(ctx) if err != nil { @@ -319,21 +313,17 @@ func (o *TridentOrchestrator) bootstrapBackends(ctx context.Context) error { return nil } -// bootstrapStorageClasses loads the existing storage classes from the backend -// and adds them to the orchestrator. -// It returns an error if the storage classes cannot be retrieved. +// bootstrapStorageClasses adds storage classes from the persistent store to the orchestrator's +// in-memory storage class map. +// It returns an error if the persistent store cannot be accessed. // Parameters: -// ctx - context for the operation +// ctx - context for logging // Returns: -// error - if the storage classes cannot be retrieved +// error - if the persistent store cannot be accessed // Example: // err := o.bootstrapStorageClasses(ctx) -// if err != nil { -// return err -// } // -// -- Doc autogenerated on 2022-05-26 19:17:04. Function hash: 21a98ba2c9aed0a70ca745011194074a -- - +// -- Doc autogenerated on 2022-05-26 22:16:42. Function hash: 21a98ba2c9aed0a70ca745011194074a -- func (o *TridentOrchestrator) bootstrapStorageClasses(ctx context.Context) error { persistentStorageClasses, err := o.storeClient.GetStorageClasses(ctx) if err != nil { @@ -356,20 +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 is called during startup to load the volumes from the backend store. -// It returns a map of volumes keyed by the volume name. +// bootstrapVolumes adds existing volumes to the orchestrator +// It returns an error if it fails to get the volumes from the store // Parameters: -// ctx - the context for the current operation +// ctx - context for logging // Returns: -// error - if any errors occurred +// error - error if any // Example: -// volumes, err := o.bootstrapVolumes(ctx) -// if err != nil { -// return err -// } +// err := o.bootstrapVolumes(ctx) // -// -- Doc autogenerated on 2022-05-26 19:17:24. Function hash: 713a6e9aafc3998ba2508038c533087d -- - +// -- Doc autogenerated on 2022-05-26 22:17:01. Function hash: 713a6e9aafc3998ba2508038c533087d -- func (o *TridentOrchestrator) bootstrapVolumes(ctx context.Context) error { volumes, err := o.storeClient.GetVolumes(ctx) if err != nil { @@ -422,17 +408,16 @@ func (o *TridentOrchestrator) bootstrapVolumes(ctx context.Context) error { return nil } -// bootstrapSnapshots loads all existing snapshots from the backend and adds them to the orchestrator's snapshot map. -// It returns an error if the snapshot cannot be added to the map. +// bootstrapSnapshots loads existing snapshots from the backend store. +// It returns an error if the store is unavailable. // Parameters: -// ctx - context +// ctx - context for the operation // Returns: -// error - error if the snapshot cannot be added to the map +// error - any error encountered // Example: // err := o.bootstrapSnapshots(ctx) // -// -- Doc autogenerated on 2022-05-26 19:17:44. Function hash: 7cc86ef066af5a6d4d4cccf2aaacc362 -- - +// -- Doc autogenerated on 2022-05-26 22:17:27. Function hash: 7cc86ef066af5a6d4d4cccf2aaacc362 -- func (o *TridentOrchestrator) bootstrapSnapshots(ctx context.Context) error { snapshots, err := o.storeClient.GetSnapshots(ctx) if err != nil { @@ -467,18 +452,20 @@ func (o *TridentOrchestrator) bootstrapSnapshots(ctx context.Context) error { return nil } -// bootstrapVolTxns retrieves volume transaction logs from the persistent store and -// attempts to replay them. -// It returns an error if any of the transactions fail to replay. +// bootstrapVolTxns retrieves any volume transaction logs from the persistent store and attempts to +// complete them. +// It returns an error if any of the transactions fail to complete. // Parameters: -// ctx - context +// ctx - context // Returns: -// error - error +// error - an error if any of the transactions fail to complete // Example: -// err := bootstrapVolTxns(ctx) +// err := o.bootstrapVolTxns(ctx) +// if err != nil { +// return err +// } // -// -- Doc autogenerated on 2022-05-26 19:18:10. Function hash: e33c0ea45aaa4a9d8262fd4f04ac4667 -- - +// -- Doc autogenerated on 2022-05-26 22:18:03. Function hash: e33c0ea45aaa4a9d8262fd4f04ac4667 -- func (o *TridentOrchestrator) bootstrapVolTxns(ctx context.Context) error { volTxns, err := o.storeClient.GetVolumeTransactions(ctx) if err != nil && !persistentstore.MatchKeyNotFoundErr(err) { @@ -495,17 +482,16 @@ func (o *TridentOrchestrator) bootstrapVolTxns(ctx context.Context) error { return nil } -// bootstrapNodes bootstraps the orchestrator with existing nodes. -// It returns an error if any node fails to bootstrap. +// bootstrapNodes initializes the nodes map with existing nodes +// It returns an error if there was a problem getting the nodes // Parameters: // ctx - context // Returns: -// error - error if any node fails to bootstrap +// error - error if there was a problem getting the nodes // Example: // err := o.bootstrapNodes(ctx) // -// -- Doc autogenerated on 2022-05-26 19:18:36. Function hash: 7cfe94c5ecbb68533b741378eaa5ee46 -- - +// -- Doc autogenerated on 2022-05-26 22:18:32. Function hash: 7cfe94c5ecbb68533b741378eaa5ee46 -- func (o *TridentOrchestrator) bootstrapNodes(ctx context.Context) error { // Don't bootstrap nodes if we're not CSI if config.CurrentDriverContext != config.ContextCSI { @@ -530,17 +516,16 @@ func (o *TridentOrchestrator) bootstrapNodes(ctx context.Context) error { return nil } -// bootstrapVolumePublications bootstraps the volume publications from the store -// It returns an error if the store is unavailable. +// bootstrapVolumePublications adds any existing volume publications to the cache +// It returns an error if the volume publications cannot be retrieved from the store // Parameters: // ctx - context for logging // Returns: -// error - nil if successful +// error - nil if the volume publications were successfully added to the cache // Example: // err := o.bootstrapVolumePublications(ctx) // -// -- Doc autogenerated on 2022-05-26 19:19:01. Function hash: feea1b84b5d4a911d16860d0c211b775 -- - +// -- Doc autogenerated on 2022-05-26 22:18:54. Function hash: feea1b84b5d4a911d16860d0c211b775 -- func (o *TridentOrchestrator) bootstrapVolumePublications(ctx context.Context) error { // Don't bootstrap volume publications if we're not CSI if config.CurrentDriverContext != config.ContextCSI { @@ -562,16 +547,15 @@ func (o *TridentOrchestrator) bootstrapVolumePublications(ctx context.Context) e return nil } -// addVolumePublicationToCache adds a volume publication to the cache +// addVolumePublicationToCache adds the volume publication to the orchestrator's cache // Parameters: -// vp - volume publication to be added +// vp: Volume publication to add to the cache // Returns: // none // Example: -// o.addVolumePublicationToCache(vp) +// o.addVolumePublicationToCache(&vp) // -// -- Doc autogenerated on 2022-05-26 19:19:21. Function hash: 6831b1fc734710c782e9132682016e51 -- - +// -- Doc autogenerated on 2022-05-26 22:19:15. Function hash: 6831b1fc734710c782e9132682016e51 -- func (o *TridentOrchestrator) addVolumePublicationToCache(vp *utils.VolumePublication) { // If the volume has no entry we need to initialize the inner map if o.volumePublications[vp.VolumeName] == nil { @@ -580,18 +564,20 @@ func (o *TridentOrchestrator) addVolumePublicationToCache(vp *utils.VolumePublic o.volumePublications[vp.VolumeName][vp.NodeName] = vp } -// bootstrap loads the persistent store and initializes the orchestrator -// state. +// bootstrap loads all persistent objects from the store and initializes the +// orchestrator state. // It returns an error if the bootstrap fails. // Parameters: -// ctx - context for the bootstrap +// ctx - context // Returns: -// error - error if the bootstrap fails +// error - bootstrap error if any // Example: -// err := o.bootstrap(ctx) +// err := o.bootstrap(ctx) +// if err != nil { +// return err +// } // -// -- Doc autogenerated on 2022-05-26 19:19:55. Function hash: bcd99e963177e37d4f93a0ee26ad9890 -- - +// -- Doc autogenerated on 2022-05-26 22:19:32. Function hash: bcd99e963177e37d4f93a0ee26ad9890 -- func (o *TridentOrchestrator) bootstrap(ctx context.Context) error { // Fetching backend information @@ -702,23 +688,24 @@ func (o *TridentOrchestrator) updateMetrics() { } } -// handleFailedTransaction attempts to clean up after a failed transaction. -// This is called when we bootstrap and find a transaction in the persistent -// store that has not been marked as completed. +// handleFailedTransaction attempts to clean up a failed transaction. +// +// This function is called when a transaction fails to complete, and the +// orchestrator is restarted. It is responsible for cleaning up any +// resources that were created as part of the transaction, and for removing +// the transaction from persistent store. // It returns an error if it is unable to clean up the transaction. // Parameters: -// ctx - context.Context object -// v - volume transaction object +// v - the volume transaction to clean up // Returns: -// error - error object +// error - any error encountered while cleaning up the transaction // Example: -// err := o.handleFailedTransaction(ctx, v) -// if err != nil { -// return fmt.Errorf("failed to clean up failed transaction: %v", err) -// } +// err := handleFailedTransaction(v) +// if err != nil { +// return err +// } // -// -- Doc autogenerated on 2022-05-26 19:20:18. Function hash: 39541d951f05903909338f9e59963947 -- - +// -- Doc autogenerated on 2022-05-26 22:19:55. Function hash: 39541d951f05903909338f9e59963947 -- func (o *TridentOrchestrator) handleFailedTransaction(ctx context.Context, v *storage.VolumeTransaction) error { switch v.Op { case storage.AddVolume, storage.DeleteVolume, @@ -956,19 +943,22 @@ func (o *TridentOrchestrator) handleFailedTransaction(ctx context.Context, v *st return nil } -// resetImportedVolumeName attempts to rename a volume to its original name. -// This is used when a volume is imported and the user wants to rename it. -// It returns an error if the volume could not be found. +// resetImportedVolumeName attempts to rename the volume back to its original name. +// It returns an error if the volume is not found. // Parameters: -// ctx - context // volume - volume to rename // Returns: -// error - error if the volume could not be found +// error - error if the volume is not found // Example: -// err := o.resetImportedVolumeName(ctx, volume) +// volume := &storage.VolumeConfig{ +// Name: "volume1", +// InternalName: "volume1-internal", +// ImportOriginalName: "volume1-original", +// ImportNotManaged: false, +// } +// error := orchestrator.resetImportedVolumeName(ctx, volume) // -// -- Doc autogenerated on 2022-05-26 19:20:47. Function hash: 1033950f7f2014fd8a87dbfb93781f51 -- - +// -- Doc autogenerated on 2022-05-26 22:20:21. Function hash: 1033950f7f2014fd8a87dbfb93781f51 -- func (o *TridentOrchestrator) resetImportedVolumeName(ctx context.Context, volume *storage.VolumeConfig) error { // The volume could be renamed (notManaged = false) without being persisted. // If the volume wasn't added to the persistent store, we attempt to rename @@ -985,17 +975,15 @@ func (o *TridentOrchestrator) resetImportedVolumeName(ctx context.Context, volum return nil } -// AddFrontend adds a frontend plugin to the orchestrator +// AddFrontend adds a frontend to the orchestrator. // Parameters: -// f - frontend plugin +// f - frontend to add // Returns: // none // Example: -// o := NewTridentOrchestrator() -// o.AddFrontend(rest.NewTridentREST()) +// o.AddFrontend(f) // -// -- Doc autogenerated on 2022-05-26 19:21:08. Function hash: be80e16a539796ac4231803c9351df2d -- - +// -- Doc autogenerated on 2022-05-26 22:20:34. Function hash: be80e16a539796ac4231803c9351df2d -- func (o *TridentOrchestrator) AddFrontend(f frontend.Plugin) { name := f.GetName() if _, ok := o.frontends[name]; ok { @@ -1006,18 +994,17 @@ func (o *TridentOrchestrator) AddFrontend(f frontend.Plugin) { o.frontends[name] = f } -// GetFrontend returns a frontend plugin by name +// GetFrontend returns the frontend plugin with the specified name. // Parameters: -// ctx - context -// name - name of the frontend to get +// ctx - context for logging +// name - name of the frontend plugin // Returns: -// frontend.Plugin - the requested frontend plugin -// error - an error if one occurs +// frontend plugin with the specified name +// error - error if frontend does not exist // Example: -// fe, err := o.GetFrontend(ctx, "iscsi") +// fe, err := GetFrontend(ctx, "nfs") // -// -- Doc autogenerated on 2022-05-26 19:21:25. Function hash: 68c5aa2cdd27528e7d82eb37fe73b601 -- - +// -- Doc autogenerated on 2022-05-26 22:20:49. Function hash: 68c5aa2cdd27528e7d82eb37fe73b601 -- func (o *TridentOrchestrator) GetFrontend(ctx context.Context, name string) (frontend.Plugin, error) { if fe, ok := o.frontends[name]; !ok { err := fmt.Errorf("requested frontend %s does not exist", name) @@ -1028,21 +1015,17 @@ func (o *TridentOrchestrator) GetFrontend(ctx context.Context, name string) (fro } } -// validateBackendUpdate validates that a backend update is allowed. -// It returns an error if the update is not allowed. +// validateBackendUpdate validates that the backend update is valid. +// It returns an error if the backend update is invalid. // Parameters: -// oldBackend - the old backend object -// newBackend - the new backend object +// oldBackend - the old backend +// newBackend - the new backend // Returns: -// error - if the update is not allowed +// error - the error if the update is invalid, nil if the update is valid // Example: -// err := o.validateBackendUpdate(oldBackend, newBackend) -// if err != nil { -// return err -// } +// err := validateBackendUpdate(oldBackend, newBackend) // -// -- Doc autogenerated on 2022-05-26 19:22:18. Function hash: 80555ddd7f23803234d84705cd8e72e3 -- - +// -- Doc autogenerated on 2022-05-26 22:21:45. Function hash: 80555ddd7f23803234d84705cd8e72e3 -- func (o *TridentOrchestrator) validateBackendUpdate(oldBackend, newBackend storage.Backend) error { // Validate that backend type isn't being changed as backend type has // implications for the internal volume names. @@ -1057,18 +1040,14 @@ func (o *TridentOrchestrator) validateBackendUpdate(oldBackend, newBackend stora // GetVersion returns the version of the orchestrator // Parameters: -// context - context for the request +// ctx - context for the request // Returns: -// version - version of the orchestrator -// error - any error encountered +// version string +// error - if any // Example: -// version, err := orchestrator.GetVersion(context) -// if err != nil { -// return err -// } +// version, err := orchestrator.GetVersion(ctx) // -// -- Doc autogenerated on 2022-05-26 19:22:34. Function hash: b3ff28ff24fcdaca9fca3da6aa509290 -- - +// -- Doc autogenerated on 2022-05-26 22:22:01. Function hash: b3ff28ff24fcdaca9fca3da6aa509290 -- func (o *TridentOrchestrator) GetVersion(context.Context) (string, error) { return config.OrchestratorVersion.String(), o.bootstrapError } @@ -1603,16 +1582,12 @@ func (o *TridentOrchestrator) updateBackendState( // Parameters: // backendName - the name of the backend // Returns: -// backendUUID - the UUID of the backend -// error - if an error occurred +// backendUUID - the backend UUID +// error - any error encountered // Example: -// backendUUID, err := o.getBackendUUIDByBackendName("trident") -// if err != nil { -// log.Errorf("Could not get backend UUID for 'trident': %v", err) -// } +// backendUUID, _ := o.getBackendUUIDByBackendName("ontap-nas-1") // -// -- Doc autogenerated on 2022-05-26 19:22:52. Function hash: 3432223f3c321828475a38387539f630 -- - +// -- Doc autogenerated on 2022-05-26 22:22:21. Function hash: 3432223f3c321828475a38387539f630 -- func (o *TridentOrchestrator) getBackendUUIDByBackendName(backendName string) (string, error) { backendUUID := "" for _, b := range o.backends { @@ -1624,17 +1599,16 @@ func (o *TridentOrchestrator) getBackendUUIDByBackendName(backendName string) (s return "", utils.NotFoundError(fmt.Sprintf("backend %v was not found", backendName)) } -// getBackendByBackendName returns the backend with the given backendName +// getBackendByBackendName returns a backend by name // Parameters: -// backendName - the name of the backend to return +// backendName - the name of the backend // Returns: -// storage.Backend - the backend object -// error - nil if the backend was found, error if not +// storage.Backend - the backend +// error - error if there is any // Example: -// backend, err := o.getBackendByBackendName(backendName) +// backend, err := orchestrator.getBackendByBackendName("backend1") // -// -- Doc autogenerated on 2022-05-26 19:23:11. Function hash: 5359cbb6a4e1cb6e05469580d3214563 -- - +// -- Doc autogenerated on 2022-05-26 22:22:40. Function hash: 5359cbb6a4e1cb6e05469580d3214563 -- func (o *TridentOrchestrator) getBackendByBackendName(backendName string) (storage.Backend, error) { for _, b := range o.backends { if b.Name() == backendName { @@ -1644,17 +1618,20 @@ func (o *TridentOrchestrator) getBackendByBackendName(backendName string) (stora return nil, utils.NotFoundError(fmt.Sprintf("backend %v was not found", backendName)) } -// getBackendByConfigRef returns a backend based on the configRef +// getBackendByConfigRef returns a backend based on its configRef // Parameters: -// configRef - the configRef of the backend to return +// configRef - the configRef of the backend // Returns: -// storage.Backend - the backend based on the configRef -// error - non-nil if an error occurs +// storage.Backend - the backend +// error - any error encountered // Example: -// b, err := o.getBackendByConfigRef("trident-config") +// backend, err := o.getBackendByConfigRef("backend1") +// if err != nil { +// log.Error(err) +// return err +// } // -// -- Doc autogenerated on 2022-05-26 19:23:28. Function hash: 37e7727af627a51a35149814c5e420af -- - +// -- Doc autogenerated on 2022-05-26 22:23:05. Function hash: 37e7727af627a51a35149814c5e420af -- func (o *TridentOrchestrator) getBackendByConfigRef(configRef string) (storage.Backend, error) { for _, b := range o.backends { if b.ConfigRef() == configRef { @@ -1664,17 +1641,20 @@ func (o *TridentOrchestrator) getBackendByConfigRef(configRef string) (storage.B return nil, utils.NotFoundError(fmt.Sprintf("backend based on configRef '%v' was not found", configRef)) } -// getBackendByBackendUUID returns the backend with the specified UUID +// getBackendByBackendUUID returns the backend with the given backendUUID // Parameters: -// backendUUID - the UUID of the backend +// backendUUID - the backendUUID of the backend to return // Returns: -// storage.Backend - the backend with the specified UUID -// error - any error encountered +// storage.Backend - the backend with the given backendUUID +// error - nil if the backend was found, otherwise an error is returned // Example: -// backend, err := o.getBackendByBackendUUID("6b1f6af3-6d1d-43b9-b2e0-a0d8f8e8a5e7") +// backend, err := orchestrator.getBackendByBackendUUID(backendUUID) +// if err != nil { +// return err +// } +// // use the backend // -// -- Doc autogenerated on 2022-05-26 19:24:23. Function hash: 5b6c42a570cd7be7efb047a76057cbdd -- - +// -- Doc autogenerated on 2022-05-26 22:23:32. Function hash: 5b6c42a570cd7be7efb047a76057cbdd -- func (o *TridentOrchestrator) getBackendByBackendUUID(backendUUID string) (storage.Backend, error) { backend := o.backends[backendUUID] if backend != nil { @@ -1683,18 +1663,20 @@ func (o *TridentOrchestrator) getBackendByBackendUUID(backendUUID string) (stora return nil, utils.NotFoundError(fmt.Sprintf("backend uuid %v was not found", backendUUID)) } -// GetBackend returns the backend object for the given backend name. +// GetBackend returns the backend object for the specified backend name. // Parameters: // ctx - context for logging -// backendName - name of the backend +// backendName - name of the backend to get // Returns: -// backendExternal - backend object -// err - error if any +// *storage.BackendExternal - backend object +// error - an error if there was a problem getting the backend // Example: -// backendExternal, err := orchestrator.GetBackend(ctx, backendName) +// backend, err := orchestrator.GetBackend(ctx, "backend1") +// if err != nil { +// return fmt.Errorf("Error getting backend: %v", err) +// } // -// -- Doc autogenerated on 2022-05-26 19:24:40. Function hash: 97ea7edf0258bdf4ee62e165318ef219 -- - +// -- Doc autogenerated on 2022-05-26 22:23:58. Function hash: 97ea7edf0258bdf4ee62e165318ef219 -- func (o *TridentOrchestrator) GetBackend( ctx context.Context, backendName string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1726,18 +1708,17 @@ func (o *TridentOrchestrator) GetBackend( return backendExternal, nil } -// GetBackendByBackendUUID returns a backend by its UUID. +// GetBackendByBackendUUID returns a backend by backendUUID // Parameters: -// ctx - context -// backendUUID - UUID of the backend to retrieve +// ctx - context for logging +// backendUUID - the backend UUID // Returns: -// *storage.BackendExternal - the backend -// error - any error encountered +// *storage.BackendExternal - the backend +// error - any error encountered // Example: -// backend, err := orchestrator.GetBackendByBackendUUID(ctx, "f0c4d4a4-4dac-4a1b-b5a0-e53d9c827e3a") +// backend, err := orchestrator.GetBackendByBackendUUID(ctx, "1") // -// -- Doc autogenerated on 2022-05-26 19:25:07. Function hash: 81d8fa64dc1b3803acd28fbacf4b0287 -- - +// -- Doc autogenerated on 2022-05-26 22:24:28. Function hash: 81d8fa64dc1b3803acd28fbacf4b0287 -- func (o *TridentOrchestrator) GetBackendByBackendUUID( ctx context.Context, backendUUID string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1766,17 +1747,16 @@ func (o *TridentOrchestrator) GetBackendByBackendUUID( return backendExternal, nil } -// ListBackends returns a list of all backends known to the orchestrator. +// ListBackends lists the backends in the system +// It returns a list of backends and an error // Parameters: -// ctx - The context for the current request +// ctx - context (for cancellation) // Returns: -// List of backends -// Any errors encountered +// list of backends and an error // Example: -// backends, err := orchestrator.ListBackends(ctx) +// backends, err := ListBackends(ctx) // -// -- Doc autogenerated on 2022-05-26 19:25:25. Function hash: 2d98525f51bd5d6b7df26ff8693141e9 -- - +// -- Doc autogenerated on 2022-05-26 22:24:48. Function hash: 2d98525f51bd5d6b7df26ff8693141e9 -- func (o *TridentOrchestrator) ListBackends( ctx context.Context, ) (backendExternals []*storage.BackendExternal, err error) { @@ -1803,15 +1783,17 @@ func (o *TridentOrchestrator) ListBackends( // DeleteBackend deletes a backend from the orchestrator // It returns an error if the backend does not exist // Parameters: -// ctx - logging context -// backendName - name of the backend to delete +// ctx - context for logging +// backendName - the name of the backend to delete // Returns: -// error - any error encountered +// error - any error encountered // Example: -// err := o.DeleteBackend(ctx, "backend-01") +// err := orchestrator.DeleteBackend(ctx, backendName) +// if err != nil { +// log.Errorf("Could not delete backend %s: %v", backendName, err) +// } // -// -- Doc autogenerated on 2022-05-26 19:25:46. Function hash: dac0943d6e46a81a0f9787f5f6ef64f3 -- - +// -- Doc autogenerated on 2022-05-26 22:25:08. Function hash: dac0943d6e46a81a0f9787f5f6ef64f3 -- func (o *TridentOrchestrator) DeleteBackend(ctx context.Context, backendName string) (err error) { if o.bootstrapError != nil { Logc(ctx).WithFields(log.Fields{ @@ -1833,19 +1815,18 @@ func (o *TridentOrchestrator) DeleteBackend(ctx context.Context, backendName str return o.deleteBackendByBackendUUID(ctx, backendName, backendUUID) } -// DeleteBackendByBackendUUID deletes a backend by backend UUID -// It returns an error if the backend does not exist +// DeleteBackendByBackendUUID deletes a backend by backendUUID +// It returns an error if the backend is not found // Parameters: -// ctx - context -// backendName - name of backend -// backendUUID - UUID of backend +// ctx - context for logging +// backendName - name of the backend +// backendUUID - UUID of the backend // Returns: -// error - error if any +// error - any error encountered // Example: -// err := o.DeleteBackendByBackendUUID(ctx, "myBackend", "myBackendUUID") +// err := orchestrator.DeleteBackendByBackendUUID(ctx, "backend1", "b9e9d4c8-f0b4-4d13-a4a4-8bcfc1f7bd1e") // -// -- Doc autogenerated on 2022-05-26 19:26:10. Function hash: ade56985c915048a2ff8350f698c0690 -- - +// -- Doc autogenerated on 2022-05-26 22:25:31. Function hash: ade56985c915048a2ff8350f698c0690 -- func (o *TridentOrchestrator) DeleteBackendByBackendUUID( ctx context.Context, backendName, backendUUID string, ) (err error) { @@ -1866,18 +1847,17 @@ func (o *TridentOrchestrator) DeleteBackendByBackendUUID( } // deleteBackendByBackendUUID deletes a backend by backendUUID -// It returns an error if the backend was not found +// It returns an error if the backend is not found. // Parameters: -// ctx - context -// backendName - name of backend -// backendUUID - UUID of backend +// ctx - context for logging +// backendName - name of the backend +// backendUUID - UUID of the backend // Returns: -// error - error if backend was not found +// error - error if the backend is not found // Example: -// err := deleteBackendByBackendUUID(ctx, "myBackend", "myBackendUUID") +// err := deleteBackendByBackendUUID(ctx, backendName, backendUUID) // -// -- Doc autogenerated on 2022-05-26 19:26:35. Function hash: 2568753d63d7e3305bdc4b1ea5d422de -- - +// -- Doc autogenerated on 2022-05-26 22:26:14. Function hash: 2568753d63d7e3305bdc4b1ea5d422de -- func (o *TridentOrchestrator) deleteBackendByBackendUUID(ctx context.Context, backendName, backendUUID string) error { Logc(ctx).WithFields(log.Fields{ "backendName": backendName, @@ -1956,19 +1936,18 @@ func (o *TridentOrchestrator) RemoveBackendConfigRef(ctx context.Context, backen return o.storeClient.UpdateBackend(ctx, b) } -// AddVolume creates a new volume -// It returns the volume and an error if any +// AddVolume adds a volume to the orchestrator +// It returns the volume object and error // Parameters: -// ctx - context for the operation -// volumeConfig - volume config +// volumeConfig: VolumeConfig object +// ctx: context // Returns: -// volume - volume created -// error - error if any +// externalVol: VolumeExternal object +// err: error object // Example: -// volume, err := o.AddVolume(ctx, volumeConfig) +// vol, err := o.AddVolume(ctx, volumeConfig) // -// -- Doc autogenerated on 2022-05-26 19:26:54. Function hash: 6b3abc4db9d4558bf39248381f6e73e6 -- - +// -- Doc autogenerated on 2022-05-26 22:27:13. Function hash: 6b3abc4db9d4558bf39248381f6e73e6 -- func (o *TridentOrchestrator) AddVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2222,19 +2201,18 @@ func (o *TridentOrchestrator) addVolumeFinish( return externalVol, nil } -// CloneVolume clones a volume from an existing volume -// It returns the volume config and a boolean indicating if the volume was created +// CloneVolume clones a volume +// It returns the volume and an error // Parameters: -// ctx - context -// volumeConfig - volume config +// ctx - context +// volumeConfig - volume config // Returns: -// externalVol - volume external -// err - error +// *storage.VolumeExternal - volume +// error - error // Example: -// cloneVolume, err := o.CloneVolume(ctx, volumeConfig) +// volume, err := orchestrator.CloneVolume(ctx, volumeConfig) // -// -- Doc autogenerated on 2022-05-26 19:27:16. Function hash: 3b05245cf8d531e1b7e704f1d7673887 -- - +// -- Doc autogenerated on 2022-05-26 22:27:31. Function hash: 3b05245cf8d531e1b7e704f1d7673887 -- func (o *TridentOrchestrator) CloneVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2266,22 +2244,18 @@ func (o *TridentOrchestrator) CloneVolume( return o.cloneVolumeInitial(ctx, volumeConfig) } -// cloneVolumeInitial creates a clone of an existing volume. -// It returns the new volume and an error if one occurred. +// cloneVolumeInitial creates a new volume by cloning an existing volume. +// It returns the new volume and any error encountered. // Parameters: -// ctx - the context -// volumeConfig - the configuration of the new volume +// ctx - context +// volumeConfig - volume config of the new volume // Returns: // externalVol - the new volume // err - any error encountered // Example: -// vol, err := orchestrator.cloneVolumeInitial(ctx, volumeConfig) -// if err != nil { -// return err -// } +// externalVol, err := o.cloneVolumeInitial(ctx, volumeConfig) // -// -- Doc autogenerated on 2022-05-26 19:27:43. Function hash: 3f83112418a823bdafb4b150c3214f8e -- - +// -- Doc autogenerated on 2022-05-26 22:27:58. Function hash: 3f83112418a823bdafb4b150c3214f8e -- func (o *TridentOrchestrator) cloneVolumeInitial( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2423,19 +2397,18 @@ func (o *TridentOrchestrator) cloneVolumeInitial( return o.addVolumeFinish(ctx, txn, vol, backend, pool) } -// cloneVolumeRetry attempts to clone a volume on a backend. -// It returns the volume and backend if successful, or an error. +// cloneVolumeRetry attempts to create a clone of the specified volume. +// It returns the external volume representation if successful, or an error otherwise. // Parameters: // ctx - context -// txn - volume transaction -// Returns: -// externalVol - volume +// txn - transaction +// Return: +// externalVol - external volume representation // err - error // Example: -// externalVol, err := cloneVolumeRetry(ctx, txn) +// externalVol, err := o.cloneVolumeRetry(ctx, txn) // -// -- Doc autogenerated on 2022-05-26 19:28:03. Function hash: d3195084da6ca49594299f21956d774c -- - +// -- Doc autogenerated on 2022-05-26 22:28:18. Function hash: d3195084da6ca49594299f21956d774c -- func (o *TridentOrchestrator) cloneVolumeRetry( ctx context.Context, txn *storage.VolumeTransaction, ) (externalVol *storage.VolumeExternal, err error) { @@ -2565,18 +2538,17 @@ func (o *TridentOrchestrator) GetVolumeByInternalName( return "", utils.NotFoundError(fmt.Sprintf("volume %s not found", volumeInternal)) } -// validateImportVolume validates the volume -// It returns an error if the volume is not valid +// validateImportVolume validates the volume import request +// It returns error if the volume is already imported or if the volume does not exist on the backend // Parameters: -// volumeConfig - volume config -// backend - backend -// Returns: -// error - error +// ctx - context +// volumeConfig - volume config +// Return: +// error - error if any // Example: -// err := validateImportVolume(volumeConfig, backend) +// err := o.validateImportVolume(ctx, volumeConfig) // -// -- Doc autogenerated on 2022-05-26 19:28:28. Function hash: 0b239a8ef621ed2e08adbc4c80a11281 -- - +// -- Doc autogenerated on 2022-05-26 22:28:35. Function hash: 0b239a8ef621ed2e08adbc4c80a11281 -- func (o *TridentOrchestrator) validateImportVolume(ctx context.Context, volumeConfig *storage.VolumeConfig) error { backend, err := o.getBackendByBackendUUID(volumeConfig.ImportBackendUUID) if err != nil { @@ -2638,20 +2610,21 @@ func (o *TridentOrchestrator) validateImportVolume(ctx context.Context, volumeCo return nil } -// LegacyImportVolume imports a volume into Trident. -// It returns the volume's external representation. +// LegacyImportVolume imports a volume from an external storage system. +// It returns a VolumeExternal object that can be used to create a PV and PVC. // Parameters: -// volumeConfig - volume configuration -// backendName - name of backend where volume should be imported -// notManaged - true if Trident should not manage the volume +// ctx - context for logging +// volumeConfig - volume configuration +// backendName - name of the backend to import the volume to +// notManaged - true if the volume is not managed by Trident +// createPVandPVC - callback function to create a PV and PVC for the volume // Returns: -// *storage.VolumeExternal - volume's external representation -// error - error, if any +// VolumeExternal object +// error - if any // Example: -// volumeExternal, err := orchestrator.LegacyImportVolume(ctx, volumeConfig, backendName, notManaged) +// importVol, err := o.LegacyImportVolume(ctx, volumeConfig, backendName, notManaged, createPVandPVC) // -// -- Doc autogenerated on 2022-05-26 19:28:57. Function hash: f8c072d23374263c1a818a13bc96fac1 -- - +// -- Doc autogenerated on 2022-05-26 22:29:04. Function hash: f8c072d23374263c1a818a13bc96fac1 -- func (o *TridentOrchestrator) LegacyImportVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, backendName string, notManaged bool, createPVandPVC VolumeCallback, @@ -2745,16 +2718,15 @@ func (o *TridentOrchestrator) LegacyImportVolume( // ImportVolume imports a volume from a backend // It returns the volume's external representation // Parameters: -// volumeConfig - configuration for the volume to be imported -// backendUUID - UUID of the backend where the volume is located +// ctx - context +// volumeConfig - the volume to import // Returns: -// externalVol - external representation of the volume -// err - error if any +// *storage.VolumeExternal - the volume's external representation +// error - any error encountered // Example: -// externalVol, err := orchestrator.ImportVolume(ctx, volumeConfig, backendUUID) +// volumeExternal, err := core.ImportVolume(ctx, volumeConfig) // -// -- Doc autogenerated on 2022-05-26 19:29:24. Function hash: caf9bc105080edc2f7b86c15a43a3f1e -- - +// -- Doc autogenerated on 2022-05-26 22:29:32. Function hash: caf9bc105080edc2f7b86c15a43a3f1e -- func (o *TridentOrchestrator) ImportVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2885,18 +2857,23 @@ func (o *TridentOrchestrator) AddVolumeTransaction(ctx context.Context, volTxn * return o.storeClient.AddVolumeTransaction(ctx, volTxn) } -// GetVolumeCreatingTransaction returns the volume transaction for the given volume config. +// GetVolumeCreatingTransaction returns the volume transaction if it exists, or nil if it does not. // Parameters: -// ctx - context for the operation +// ctx - context // config - volume config // Returns: -// *storage.VolumeTransaction - volume transaction -// error - error, if any +// volume transaction +// error // Example: -// txn, err := orchestrator.GetVolumeCreatingTransaction(ctx, config) +// txn, err := o.GetVolumeCreatingTransaction(ctx, config) +// if err != nil { +// return err +// } +// if txn != nil { +// return fmt.Errorf("volume %v is already being created", config.InternalName) +// } // -// -- Doc autogenerated on 2022-05-26 19:29:49. Function hash: 4025deb561dc0aba9e0fa596740664b8 -- - +// -- Doc autogenerated on 2022-05-26 22:29:52. Function hash: 4025deb561dc0aba9e0fa596740664b8 -- func (o *TridentOrchestrator) GetVolumeCreatingTransaction( ctx context.Context, config *storage.VolumeConfig, ) (*storage.VolumeTransaction, error) { @@ -2916,18 +2893,17 @@ func (o *TridentOrchestrator) GetVolumeCreatingTransaction( } } -// GetVolumeTransaction returns a volume transaction from the store +// GetVolumeTransaction returns a volume transaction from the backend // Parameters: -// ctx - context for the request -// volTxn - volume transaction to return +// ctx - context for logging +// volTxn - the volume transaction to get // Returns: -// *storage.VolumeTransaction - volume transaction from the store -// error - error if one occurred +// *storage.VolumeTransaction - the volume transaction +// error - any error encountered // Example: -// volTxn, err := o.GetVolumeTransaction(ctx, volTxn) +// volTxn, err := tridentOrchestrator.GetVolumeTransaction(ctx, volTxn) // -// -- Doc autogenerated on 2022-05-26 19:30:03. Function hash: d8a638429c4b2c3043bb0281d5c34490 -- - +// -- Doc autogenerated on 2022-05-26 22:30:16. Function hash: d8a638429c4b2c3043bb0281d5c34490 -- func (o *TridentOrchestrator) GetVolumeTransaction( ctx context.Context, volTxn *storage.VolumeTransaction, ) (*storage.VolumeTransaction, error) { @@ -3052,24 +3028,20 @@ func (o *TridentOrchestrator) addVolumeRetryCleanup( return err } -// importVolumeCleanup is called when an error occurs during volume import. -// It attempts to clean up any artifacts of the -// It returns an error if it was unable to clean up. +// importVolumeCleanup is called when an error occurs during the import process. +// It attempts to clean up any artifacts created during the import process. +// It returns an error if any of the cleanup steps fail. // Parameters: -// ctx - context -// err - error that occurred during import -// volumeConfig - the volume config -// volTxn - the volume transaction +// ctx - context for logging +// err - the error that occurred during the import process. +// volumeConfig - the volume config of the volume being imported. +// volTxn - the volume transaction of the volume being imported. // Returns: -// error - error if it was unable to clean up +// error - an error if any of the cleanup steps fail. // Example: -// err := importVolumeCleanup(ctx, err, volumeConfig, volTxn) -// if err != nil { -// return err -// } +// err := o.importVolumeCleanup(ctx, err, volumeConfig, volTxn) // -// -- Doc autogenerated on 2022-05-26 19:30:32. Function hash: f5e220ffc92fbb12521834e8dbc438aa -- - +// -- Doc autogenerated on 2022-05-26 22:31:17. Function hash: f5e220ffc92fbb12521834e8dbc438aa -- func (o *TridentOrchestrator) importVolumeCleanup( ctx context.Context, err error, volumeConfig *storage.VolumeConfig, volTxn *storage.VolumeTransaction, ) error { @@ -3124,18 +3096,18 @@ func (o *TridentOrchestrator) importVolumeCleanup( return err } -// GetVolume returns a volume by name +// GetVolume retrieves a volume by name +// It returns the volume and any error encountered // Parameters: // ctx - context for logging -// volume - volume name +// volume - name of the volume // Returns: -// *storage.VolumeExternal - volume object -// error - error object +// VolumeExternal - volume object +// error - any error encountered // Example: -// volume, err := orchestrator.GetVolume(ctx, "volume1") +// vol, err := orchestrator.GetVolume(ctx, "volume1") // -// -- Doc autogenerated on 2022-05-26 19:30:48. Function hash: 7b809028c4c2d34e481ebd4d9ceadcdf -- - +// -- Doc autogenerated on 2022-05-26 22:31:37. Function hash: 7b809028c4c2d34e481ebd4d9ceadcdf -- func (o *TridentOrchestrator) GetVolume( ctx context.Context, volume string, ) (volExternal *storage.VolumeExternal, err error) { @@ -3151,18 +3123,19 @@ func (o *TridentOrchestrator) GetVolume( return o.getVolume(ctx, volume) } -// getVolume returns a volume +// getVolume returns the volume with the specified name // Parameters: -// ctx - context (for logging) -// volume - name of the volume +// volume - name of the volume to retrieve // Returns: -// *storage.VolumeExternal - the volume -// error - error, if any +// the volume object +// error if the volume was not found // Example: -// volume, err := o.getVolume(ctx, "volume1") +// vol, err := o.getVolume("myvol") +// if err != nil { +// log.Errorf("unable to retrieve volume %v: %v", vol, err) +// } // -// -- Doc autogenerated on 2022-05-26 19:31:02. Function hash: a3180f3812fb8b86173ca5c119bc52db -- - +// -- Doc autogenerated on 2022-05-26 22:31:55. Function hash: a3180f3812fb8b86173ca5c119bc52db -- func (o *TridentOrchestrator) getVolume( _ context.Context, volume string, ) (volExternal *storage.VolumeExternal, err error) { @@ -3173,17 +3146,19 @@ func (o *TridentOrchestrator) getVolume( return vol.ConstructExternal(), nil } -// GetDriverTypeForVolume returns the driver +// GetDriverTypeForVolume returns the driver type for a volume // Parameters: -// vol *storage.VolumeExternal +// vol - volume to get the driver type for // Returns: -// string -// error +// string - driver type +// error - any error that occurred // Example: -// driverType, err := orchestrator.GetDriverTypeForVolume(vol) +// driverType, err := orchestrator.GetDriverTypeForVolume(&storage.VolumeExternal{BackendUUID: "5f8a9b60-a4c4-4d83-8e35-7b8c6b2ecc1b"}) +// if err != nil { +// ... +// } // -// -- Doc autogenerated on 2022-05-26 19:31:17. Function hash: fa6bc896c59ce9a936c5679fd5c658b9 -- - +// -- Doc autogenerated on 2022-05-26 22:32:11. Function hash: fa6bc896c59ce9a936c5679fd5c658b9 -- func (o *TridentOrchestrator) GetDriverTypeForVolume(_ context.Context, vol *storage.VolumeExternal) (string, error) { if o.bootstrapError != nil { return config.UnknownDriver, o.bootstrapError @@ -3206,18 +3181,25 @@ func (o *TridentOrchestrator) getDriverTypeForVolume(backendUUID string) (string return config.UnknownDriver, nil } -// GetVolumeType returns the volume +// GetVolumeType returns the volume type for the given volume. // Parameters: // vol *storage.VolumeExternal -// Returns volumeType config.VolumeType, err error +// Volume to get the volume type for // Returns: // volumeType config.VolumeType +// Volume type for the given volume // err error +// Error, if any // Example: -// volumeType, err := o.GetVolumeType(vol) +// vt, err := tridentOrchestrator.GetVolumeType(ctx, vol) +// if err != nil { +// // Handle error +// } +// if vt == config.OntapNFS { +// // Handle NFS volume +// } // -// -- Doc autogenerated on 2022-05-26 19:31:54. Function hash: 38bae4a9a9ca7f54bb863b2c10a6fe6e -- - +// -- Doc autogenerated on 2022-05-26 22:32:28. Function hash: 38bae4a9a9ca7f54bb863b2c10a6fe6e -- func (o *TridentOrchestrator) GetVolumeType( _ context.Context, vol *storage.VolumeExternal, ) (volumeType config.VolumeType, err error) { @@ -3255,13 +3237,15 @@ func (o *TridentOrchestrator) GetVolumeType( // Parameters: // context - context for logging // Return: -// []*storage.VolumeExternal - list of volumes +// volumes - list of volumes // error - error, if any // Example: -// volumes, err := orchestrator.ListVolumes(context.Background()) +// volumes, err := o.ListVolumes(context) +// if err != nil { +// return err +// } // -// -- Doc autogenerated on 2022-05-26 19:32:09. Function hash: 85d4a8042740926b2d85a28566cb3403 -- - +// -- Doc autogenerated on 2022-05-26 22:32:42. Function hash: 85d4a8042740926b2d85a28566cb3403 -- func (o *TridentOrchestrator) ListVolumes(context.Context) (volumes []*storage.VolumeExternal, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -3379,19 +3363,18 @@ func (o *TridentOrchestrator) deleteVolume(ctx context.Context, volumeName strin return nil } -// deleteVolumeFromPersistentStoreIgnoreError deletes the volume from the persistent store, -// ignoring any errors if the volume is not found. -// It returns an error if the volume is found but cannot be deleted. +// deleteVolumeFromPersistentStoreIgnoreError deletes a volume from the persistent store, ignoring +// errors if the volume does not exist. +// It returns an error if the volume exists but could not be deleted. // Parameters: // ctx - context for logging -// volume - the volume to be deleted -// Returns: -// error - any error encountered +// volume - volume to delete +// Return: +// error - error if the volume could not be deleted, nil otherwise // Example: -// err := o.deleteVolumeFromPersistentStoreIgnoreError(ctx, volume) +// err := deleteVolumeFromPersistentStoreIgnoreError(ctx, volume) // -// -- Doc autogenerated on 2022-05-26 19:32:28. Function hash: c2bcad7a430c67f70288fd3b95d63886 -- - +// -- Doc autogenerated on 2022-05-26 22:33:10. Function hash: c2bcad7a430c67f70288fd3b95d63886 -- func (o *TridentOrchestrator) deleteVolumeFromPersistentStoreIgnoreError( ctx context.Context, volume *storage.Volume, ) error { @@ -3465,19 +3448,18 @@ func (o *TridentOrchestrator) DeleteVolume(ctx context.Context, volumeName strin return o.deleteVolume(ctx, volumeName) } -// ListVolumesByPlugin lists all volumes for a given plugin +// ListVolumesByPlugin lists all volumes managed by the specified plugin // It returns a list of volumes and an error // Parameters: -// ctx - the context for the operation -// pluginName - the name of the plugin +// pluginName - name of the plugin +// context - context // Returns: -// volumes - a list of volumes -// error - any error encountered +// volumes - list of volumes +// error - error // Example: -// volumes, err := o.ListVolumesByPlugin(ctx, pluginName) +// volumes, err := o.ListVolumesByPlugin(pluginName, context) // -// -- Doc autogenerated on 2022-05-26 19:33:06. Function hash: 60b8076f3180c5e202ffbeeef30d97b0 -- - +// -- Doc autogenerated on 2022-05-26 22:33:32. Function hash: 60b8076f3180c5e202ffbeeef30d97b0 -- func (o *TridentOrchestrator) ListVolumesByPlugin( _ context.Context, pluginName string, ) (volumes []*storage.VolumeExternal, err error) { @@ -3502,19 +3484,18 @@ func (o *TridentOrchestrator) ListVolumesByPlugin( return volumes, nil } -// PublishVolume publishes a volume to a node -// It returns an error if the volume is not found or is being deleted +// PublishVolume publishes the volume to the nodes. +// It returns an error if the volume is not found or is being deleted. // Parameters: -// ctx - context -// volumeName - name of the volume to publish -// publishInfo - information about the nodes to publish to -// Returns: -// error - error if there was a problem publishing the volume +// ctx - context for logging +// volumeName - name of the volume to publish +// publishInfo - information about the publish operation +// Return: +// error - error if any // Example: -// err := o.PublishVolume(ctx, volumeName, publishInfo) +// err := o.PublishVolume(ctx, volumeName, publishInfo) // -// -- Doc autogenerated on 2022-05-26 19:33:29. Function hash: b7313803948e3a02c08b72fd07dd08d0 -- - +// -- Doc autogenerated on 2022-05-26 22:33:55. Function hash: b7313803948e3a02c08b72fd07dd08d0 -- func (o *TridentOrchestrator) PublishVolume( ctx context.Context, volumeName string, publishInfo *utils.VolumePublishInfo, ) (err error) { @@ -3566,19 +3547,18 @@ func (o *TridentOrchestrator) PublishVolume( return nil } -// UnpublishVolume unpublishes a volume from a node. -// It returns an error if the volume is not published to the node. +// UnpublishVolume unpublishes a volume from a node +// It returns an error if the volume is not found or if the node is not found. // Parameters: -// ctx - context -// volumeName - name of the volume -// nodeName - name of the node +// ctx - context +// volumeName - name of volume to unpublish +// nodeName - name of node from which to unpublish the volume // Returns: -// error - any error encountered +// error - error if one occurred // Example: -// err := orchestrator.UnpublishVolume(ctx, "volume1", "node1") +// err := o.UnpublishVolume(ctx, "vol1", "node1") // -// -- Doc autogenerated on 2022-05-26 19:33:59. Function hash: 8051f44dc4b6fa47e354a66dd188ad29 -- - +// -- Doc autogenerated on 2022-05-26 22:34:18. Function hash: 8051f44dc4b6fa47e354a66dd188ad29 -- func (o *TridentOrchestrator) UnpublishVolume(ctx context.Context, volumeName, nodeName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -3943,19 +3923,19 @@ func (o *TridentOrchestrator) addSnapshotCleanup( return err } -// GetSnapshot returns a snapshot object +// GetSnapshot retrieves a snapshot from the backend. +// It returns the snapshot and a boolean indicating whether the snapshot exists. // Parameters: -// ctx - context for the request +// ctx - context // volumeName - name of the volume // snapshotName - name of the snapshot // Returns: -// SnapshotExternal object -// error - error object if operation failed or nil if operation succeeds +// snapshotExternal - snapshot +// err - error // Example: -// snapshotExternal, err := orchestrator.GetSnapshot(ctx, "MyVolume", "MySnapshot") +// snapshotExternal, err := o.GetSnapshot(ctx, "myVolume", "mySnapshot") // -// -- Doc autogenerated on 2022-05-26 19:35:04. Function hash: e989ccf35cebc85380ef65b188fb3054 -- - +// -- Doc autogenerated on 2022-05-26 22:34:41. Function hash: e989ccf35cebc85380ef65b188fb3054 -- func (o *TridentOrchestrator) GetSnapshot( ctx context.Context, volumeName, snapshotName string, ) (snapshotExternal *storage.SnapshotExternal, err error) { @@ -3971,24 +3951,18 @@ func (o *TridentOrchestrator) GetSnapshot( return o.getSnapshot(ctx, volumeName, snapshotName) } -// getSnapshot returns the snapshot with the specified name. +// getSnapshot returns the snapshot object for the given volume and snapshot name // Parameters: -// ctx - context for the request -// volumeName - name of the volume containing the snapshot -// snapshotName - name of the snapshot to return +// ctx - context for logging +// volumeName - name of the volume that contains the snapshot +// snapshotName - name of the snapshot to retrieve // Returns: -// *storage.SnapshotExternal - the snapshot with the specified name -// error - any error encountered while retrieving the snapshot +// *storage.SnapshotExternal - snapshot object +// error - error if one occurred, nil otherwise // Example: -// snapshot, err := o.getSnapshot(ctx, "vol1", "snap1") -// if err != nil { -// log.Errorf("Could not get snapshot %v: %v", "snap1", err) -// } else { -// log.Infof("Snapshot %v found: %v", "snap1", snapshot) -// } +// snapshot, err := o.getSnapshot(ctx, "volume1", "snapshot1") // -// -- Doc autogenerated on 2022-05-26 19:35:24. Function hash: b64251745b9e500e060496470970c425 -- - +// -- Doc autogenerated on 2022-05-26 22:35:00. Function hash: b64251745b9e500e060496470970c425 -- func (o *TridentOrchestrator) getSnapshot( ctx context.Context, volumeName, snapshotName string, ) (*storage.SnapshotExternal, error) { @@ -4007,19 +3981,21 @@ func (o *TridentOrchestrator) getSnapshot( } } -// updateSnapshot updates the snapshot state in the orchestrator and persistent store -// It returns the snapshot and an error if one occurred +// updateSnapshot updates the snapshot's state in the orchestrator. +// It returns the updated snapshot, or an error. // Parameters: -// ctx - context for the request -// snapshot - the snapshot to update +// ctx - context +// snapshot - the snapshot to update // Return: -// *storage.Snapshot - the updated snapshot -// error - error if one occurred +// updated snapshot +// error // Example: -// updatedSnapshot, err := o.updateSnapshot(ctx, snapshot) +// snapshot, err := o.updateSnapshot(ctx, snapshot) +// if err != nil { +// return nil, err +// } // -// -- Doc autogenerated on 2022-05-26 19:35:40. Function hash: 325d46cbf1273d5ada4aee5aad9d18fc -- - +// -- Doc autogenerated on 2022-05-26 22:35:20. Function hash: 325d46cbf1273d5ada4aee5aad9d18fc -- func (o *TridentOrchestrator) updateSnapshot( ctx context.Context, snapshot *storage.Snapshot, ) (*storage.Snapshot, error) { @@ -4117,22 +4093,17 @@ func (o *TridentOrchestrator) deleteSnapshot(ctx context.Context, snapshotConfig return nil } -// deleteSnapshotFromPersistentStoreIgnoreError deletes a snapshot from the persistent store, ignoring any errors -// that may occur if the snapshot is not present in the store. -// It returns an error if the snapshot is present in the store but cannot be deleted. +// deleteSnapshotFromPersistentStoreIgnoreError deletes a snapshot from the persistent store, ignoring any errors. +// It returns an error if the snapshot was not found in the persistent store. // Parameters: -// ctx - context -// snapshot - snapshot to delete -// Return: -// error - if the snapshot is present in the store but cannot be deleted +// ctx - context +// snapshot - the snapshot to delete +// Returns: +// error - if the snapshot was not found in the persistent store // Example: -// err := deleteSnapshotFromPersistentStoreIgnoreError(ctx, snapshot) -// if err != nil { -// // Unable to delete snapshot from persistent store. -// } +// snapshot, err := o.deleteSnapshotFromPersistentStoreIgnoreError(ctx, snapshot) // -// -- Doc autogenerated on 2022-05-26 19:36:01. Function hash: 3d9299843d219334e59de17ceccabde9 -- - +// -- Doc autogenerated on 2022-05-26 22:38:00. Function hash: 3d9299843d219334e59de17ceccabde9 -- func (o *TridentOrchestrator) deleteSnapshotFromPersistentStoreIgnoreError( ctx context.Context, snapshot *storage.Snapshot, ) error { @@ -4249,17 +4220,23 @@ func (o *TridentOrchestrator) DeleteSnapshot(ctx context.Context, volumeName, sn return o.deleteSnapshot(ctx, snapshot.Config) } -// ListSnapshots returns a list of all snapshots +// ListSnapshots returns a list of all snapshots in the system. // Parameters: -// context - The context of the request +// ctx - context (for cancellation) // Returns: -// []*storage.SnapshotExternal - A list of snapshots -// error - Any error encountered +// []*storage.SnapshotExternal - list of snapshots in the system +// error - any error encountered // Example: -// snapshots, err := orchestrator.ListSnapshots(context.Background()) +// snapshots, err := orchestrator.ListSnapshots(context) +// if err != nil { +// fmt.Printf("Error: %v\n", err) +// } else { +// for _, s := range snapshots { +// fmt.Printf("Snapshot: %v\n", s) +// } +// } // -// -- Doc autogenerated on 2022-05-26 19:36:26. Function hash: d08dffcc2af9a6d1f09139abdd3c8e33 -- - +// -- Doc autogenerated on 2022-05-26 22:38:18. Function hash: d08dffcc2af9a6d1f09139abdd3c8e33 -- func (o *TridentOrchestrator) ListSnapshots(context.Context) (snapshots []*storage.SnapshotExternal, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -4278,18 +4255,17 @@ func (o *TridentOrchestrator) ListSnapshots(context.Context) (snapshots []*stora return snapshots, nil } -// ListSnapshotsByName returns a list of snapshots with the given name +// ListSnapshotsByName returns a list of snapshots matching the specified name // Parameters: -// ctx - context.Context object for the API call -// snapshotName - name of the snapshot to list +// context - context for logging +// snapshotName - name of the snapshot to be returned // Returns: -// list of snapshots with the given name -// error - if there was an error listing the snapshots +// list of snapshots matching the specified name +// error - non-nil if there was an error retrieving the snapshot list // Example: -// snapshots, err := orchestrator.ListSnapshotsByName(ctx, "mySnapshot") +// snapshots, err := orchestrator.ListSnapshotsByName(context.Background(), "foo") // -// -- Doc autogenerated on 2022-05-26 19:36:47. Function hash: 053cf2d47c2f1434c21a089a0fbeb072 -- - +// -- Doc autogenerated on 2022-05-26 22:38:37. Function hash: 053cf2d47c2f1434c21a089a0fbeb072 -- func (o *TridentOrchestrator) ListSnapshotsByName( _ context.Context, snapshotName string, ) (snapshots []*storage.SnapshotExternal, err error) { @@ -4318,13 +4294,12 @@ func (o *TridentOrchestrator) ListSnapshotsByName( // ctx - context // volumeName - name of the volume // Returns: -// []*storage.SnapshotExternal - list of SnapshotExternal objects -// error - error object +// snapshots - a list of SnapshotExternal objects +// err - error, if any // Example: -// snapshots, err := c.ListSnapshotsForVolume(ctx, "vol1") +// snapshotExternal, err := tridentOrchestrator.ListSnapshotsForVolume(context.Background(), "volume1") // -// -- Doc autogenerated on 2022-05-26 19:37:11. Function hash: 623db3c5dd57eabbdc24f51e0e61b3a0 -- - +// -- Doc autogenerated on 2022-05-26 22:39:03. Function hash: 623db3c5dd57eabbdc24f51e0e61b3a0 -- func (o *TridentOrchestrator) ListSnapshotsForVolume( _ context.Context, volumeName string, ) (snapshots []*storage.SnapshotExternal, err error) { @@ -4351,18 +4326,17 @@ func (o *TridentOrchestrator) ListSnapshotsForVolume( return snapshots, nil } -// ReadSnapshotsForVolume returns a list of snapshots for the given volume. +// ReadSnapshotsForVolume returns a list of snapshots for the specified volume // Parameters: -// ctx - context for logging -// volumeName - name of the volume to query +// ctx - context for the request +// volumeName - name of the volume to read snapshots for // Returns: -// []*storage.SnapshotExternal - a list of snapshots for the given volume -// error - error, if any +// a list of snapshots for the specified volume +// an error if there was a problem reading the snapshots // Example: -// externalSnapshots, err := tridentOrchestrator.ReadSnapshotsForVolume(ctx, volumeName) +// snapshots, err := orchestrator.ReadSnapshotsForVolume(context.Background(), "vol1") // -// -- Doc autogenerated on 2022-05-26 19:37:28. Function hash: ccd4d329e169484695ad148c14dfbf12 -- - +// -- Doc autogenerated on 2022-05-26 22:39:21. Function hash: ccd4d329e169484695ad148c14dfbf12 -- func (o *TridentOrchestrator) ReadSnapshotsForVolume( ctx context.Context, volumeName string, ) (externalSnapshots []*storage.SnapshotExternal, err error) { @@ -4390,17 +4364,16 @@ func (o *TridentOrchestrator) ReadSnapshotsForVolume( return externalSnapshots, nil } -// ReloadVolumes is called when the volumes have changed. -// It returns an error if the reload failed. +// ReloadVolumes reloads the volumes from the backend +// It returns an error if the reload failed // Parameters: -// ctx - context for logging +// ctx - context // Returns: -// error - any error encountered +// error - error // Example: -// err := o.ReloadVolumes(ctx) +// err := orchestrator.ReloadVolumes(context.Background()) // -// -- Doc autogenerated on 2022-05-26 19:37:58. Function hash: 5f5aebb4e5d30c072efd3c62cb1564b0 -- - +// -- Doc autogenerated on 2022-05-26 22:39:39. Function hash: 5f5aebb4e5d30c072efd3c62cb1564b0 -- func (o *TridentOrchestrator) ReloadVolumes(ctx context.Context) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -4659,19 +4632,21 @@ func (o *TridentOrchestrator) getProtocol( return res.protocol, res.err } -// AddStorageClass adds a storage class to the orchestrator. -// It returns the storage class, or an error if the storage class already exists. +// AddStorageClass adds a storage class to the orchestrator +// It returns an error if the storage class already exists // Parameters: -// ctx - context (for logging) -// scConfig - the storage class configuration -// Return: -// *storageclass.External - the storage class -// error - error, if any +// ctx - context +// scConfig - storage class config +// Returns: +// *storageclass.External - the storage class +// error - error if one occurred // Example: -// sc, err := o.AddStorageClass(ctx, &storageclass.Config{Name: "sc1"}) +// sc, err := o.AddStorageClass(ctx, scConfig) +// if err != nil { +// return nil, err +// } // -// -- Doc autogenerated on 2022-05-26 19:38:27. Function hash: 7dd9fefe2646ed78b243a4d6e24b7079 -- - +// -- Doc autogenerated on 2022-05-26 22:40:01. Function hash: 7dd9fefe2646ed78b243a4d6e24b7079 -- func (o *TridentOrchestrator) AddStorageClass( ctx context.Context, scConfig *storageclass.Config, ) (scExternal *storageclass.External, err error) { @@ -4710,21 +4685,16 @@ func (o *TridentOrchestrator) AddStorageClass( return sc.ConstructExternal(ctx), nil } -// GetStorageClass returns the storage class with the specified name +// GetStorageClass returns the storage class with the given name // Parameters: -// ctx - Context for the request -// scName - Name of the storage class to retrieve +// scName - the name of the storage class to retrieve // Returns: -// *storageclass.External - Storage class object -// error - Any errors encountered +// scExternal - the storage class, if found +// err - an error, if any // Example: -// sc, err := orchestrator.GetStorageClass(ctx, "scName") -// if err != nil { -// return err -// } +// sc, err := o.GetStorageClass(ctx, scName) // -// -- Doc autogenerated on 2022-05-26 19:38:44. Function hash: 8ea7a3398086c800c66845416db5fef0 -- - +// -- Doc autogenerated on 2022-05-26 22:40:15. Function hash: 8ea7a3398086c800c66845416db5fef0 -- func (o *TridentOrchestrator) GetStorageClass( ctx context.Context, scName string, ) (scExternal *storageclass.External, err error) { @@ -4746,17 +4716,16 @@ func (o *TridentOrchestrator) GetStorageClass( return sc.ConstructExternal(ctx), nil } -// ListStorageClasses returns a list of storage classes +// ListStorageClasses returns a list of all storage classes // Parameters: -// ctx - context for the operation +// ctx - context for logging // Returns: -// a list of storage class objects -// an error or nil if successful +// []*storageclass.External - a list of storage classes +// error - any errors encountered // Example: -// storageClasses, err := orchestrator.ListStorageClasses(ctx) +// storageClasses, err := tridentOrchestrator.ListStorageClasses(ctx) // -// -- Doc autogenerated on 2022-05-26 19:39:02. Function hash: 1d060e4f98ef90c4e6fd57ca995cef7d -- - +// -- Doc autogenerated on 2022-05-26 22:40:32. Function hash: 1d060e4f98ef90c4e6fd57ca995cef7d -- func (o *TridentOrchestrator) ListStorageClasses(ctx context.Context) ( scExternals []*storageclass.External, err error, ) { @@ -4779,18 +4748,14 @@ func (o *TridentOrchestrator) ListStorageClasses(ctx context.Context) ( // DeleteStorageClass deletes a storage class // It returns an error if the storage class does not exist // Parameters: -// ctx - context for logging +// ctx - context // scName - name of the storage class to delete // Returns: -// error - error if the storage class could not be deleted +// error - result of the delete operation // Example: -// err := orchestrator.DeleteStorageClass(ctx, "scName") -// if err != nil { -// return err -// } +// err := o.DeleteStorageClass(ctx, "sc1") // -// -- Doc autogenerated on 2022-05-26 19:39:40. Function hash: 7a09523cfb169968ae4a2c6a92941083 -- - +// -- Doc autogenerated on 2022-05-26 22:40:54. Function hash: 7a09523cfb169968ae4a2c6a92941083 -- func (o *TridentOrchestrator) DeleteStorageClass(ctx context.Context, scName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -4825,17 +4790,16 @@ func (o *TridentOrchestrator) DeleteStorageClass(ctx context.Context, scName str // reconcileNodeAccessOnAllBackends reconciles node access on all backends. // It returns an error if any backend fails to reconcile. // Parameters: -// ctx - context for logging -// Return: -// error - error if any backend fails to reconcile +// ctx - context +// Returns: +// error - if any backend fails to reconcile // Example: // err := o.reconcileNodeAccessOnAllBackends(ctx) // if err != nil { -// log.Error("Error during node access reconciliation") +// log.Errorf("Error reconciling node access on backends: %v", err) // } // -// -- Doc autogenerated on 2022-05-26 19:39:59. Function hash: 05c9e184edcad2ea38d16deda4378f81 -- - +// -- Doc autogenerated on 2022-05-26 22:41:13. Function hash: 05c9e184edcad2ea38d16deda4378f81 -- func (o *TridentOrchestrator) reconcileNodeAccessOnAllBackends(ctx context.Context) error { if config.CurrentDriverContext != config.ContextCSI { return nil @@ -4856,21 +4820,20 @@ func (o *TridentOrchestrator) reconcileNodeAccessOnAllBackends(ctx context.Conte return nil } -// reconcileNodeAccessOnBackend reconciles node access for a backend +// reconcileNodeAccessOnBackend reconciles node access on a backend // It returns an error if the operation fails // Parameters: // ctx - context -// b - backend -// Returns: -// error - error if the operation fails +// b - backend +// Return: +// error - error if any // Example: -// err := o.reconcileNodeAccessOnBackend(ctx, b) +// err := o.reconcileNodeAccessOnBackend(ctx, backend) // if err != nil { -// return err +// return err // } // -// -- Doc autogenerated on 2022-05-26 19:40:37. Function hash: 32894d9e525f95bbcc5fd8c4512369cf -- - +// -- Doc autogenerated on 2022-05-26 22:41:32. Function hash: 32894d9e525f95bbcc5fd8c4512369cf -- func (o *TridentOrchestrator) reconcileNodeAccessOnBackend(ctx context.Context, b storage.Backend) error { if config.CurrentDriverContext != config.ContextCSI { return nil @@ -4928,22 +4891,18 @@ func (o *TridentOrchestrator) PeriodicallyReconcileNodeAccessOnBackends() { } } -// AddNode adds a node to the orchestrator +// AddNode adds a new node to the orchestrator // It returns an error if the node already exists // Parameters: // ctx // node - the node to add -// nodeEventCallback - callback function to call when a node event occurs +// nodeEventCallback - callback function to call when node status changes // Returns: // error - any error encountered // Example: -// err := o.AddNode(ctx, node, nodeEventCallback) -// if err != nil { -// log.Errorf("Could not add node %v: %v", node.Name, err) -// } +// err := o.AddNode(ctx, node, nil) // -// -- Doc autogenerated on 2022-05-26 19:41:13. Function hash: cd542a37d4abbbf6ed9a5b48b6c67621 -- - +// -- Doc autogenerated on 2022-05-26 22:41:57. Function hash: cd542a37d4abbbf6ed9a5b48b6c67621 -- func (o *TridentOrchestrator) AddNode( ctx context.Context, node *utils.Node, nodeEventCallback NodeEventCallback, ) (err error) { @@ -4986,33 +4945,31 @@ func (o *TridentOrchestrator) AddNode( return nil } -// invalidateAllBackendNodeAccess invalidates the node access for all backends +// invalidateAllBackendNodeAccess invalidates all backend node access // Returns: // None // Example: // orchestrator.invalidateAllBackendNodeAccess() // -// -- Doc autogenerated on 2022-05-26 19:41:26. Function hash: 217366d8152ca1accdb52538ef405299 -- - +// -- Doc autogenerated on 2022-05-26 22:42:10. Function hash: 217366d8152ca1accdb52538ef405299 -- func (o *TridentOrchestrator) invalidateAllBackendNodeAccess() { for _, backend := range o.backends { backend.InvalidateNodeAccess() } } -// handleUpdatedNodePrep handles node prep status updates +// handleUpdatedNodePrep handles the node prep status update. // Parameters: -// ctx - context -// protocol - protocol for which node prep is being reported -// node - node for which node prep is being reported -// nodeEventCallback - callback to invoke to report node prep status +// ctx - context for logging +// protocol - protocol for which the prep status is being reported +// node - node for which the prep status is being reported +// nodeEventCallback - callback function to report events // Returns: -// none +// None // Example: -// o.handleUpdatedNodePrep(ctx, "NFS", node, nodeEventCallback) +// handleUpdatedNodePrep(ctx, "NFS", node, nodeEventCallback) // -// -- Doc autogenerated on 2022-05-26 19:42:06. Function hash: a834161b9eb4a27bfbb289d967a44a23 -- - +// -- Doc autogenerated on 2022-05-26 22:42:34. Function hash: a834161b9eb4a27bfbb289d967a44a23 -- func (o *TridentOrchestrator) handleUpdatedNodePrep( ctx context.Context, protocol string, node *utils.Node, nodeEventCallback NodeEventCallback, ) { @@ -5054,22 +5011,21 @@ func (o *TridentOrchestrator) handleUpdatedNodePrep( } } -// GetNode returns the node object from the orchestrator +// GetNode retrieves a node from the orchestrator +// It returns a NotFoundError if the node is not found // Parameters: -// ctx - context for logging -// nName - name of the node to retrieve +// ctx - context +// nName - name of the node // Returns: -// node - the node object from the orchestrator -// err - any error encountered +// *utils.Node - a pointer to the node object +// error - any error encountered // Example: -// node, err := o.GetNode(ctx, "node1") +// node, err := orchestrator.GetNode(ctx, "node1") // if err != nil { -// return err +// t.Error(err) // } -// fmt.Println(node.Name) // -// -- Doc autogenerated on 2022-05-26 19:42:35. Function hash: 8adb5cc590b1e328ec136e1d38883212 -- - +// -- Doc autogenerated on 2022-05-26 22:42:57. Function hash: 8adb5cc590b1e328ec136e1d38883212 -- func (o *TridentOrchestrator) GetNode(ctx context.Context, nName string) (node *utils.Node, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -5090,17 +5046,21 @@ func (o *TridentOrchestrator) GetNode(ctx context.Context, nName string) (node * return node, nil } -// ListNodes returns a list of all nodes in the cluster +// ListNodes lists all nodes in the cluster +// It returns a list of Node objects // Parameters: -// context - context for the call +// ctx - context (for cancellation) // Returns: -// nodes - a list of all nodes in the cluster -// err - error, if any +// list of nodes in the cluster +// error - non-nil if an error occurred // Example: -// nodes, err := tridentOrchestrator.ListNodes(context) +// nodes, err := orchestrator.ListNodes(ctx) +// if err != nil { +// log.Error(err) +// return +// } // -// -- Doc autogenerated on 2022-05-26 19:42:59. Function hash: 9bdd3a6d45b81df549bbe35f26aeeb85 -- - +// -- Doc autogenerated on 2022-05-26 22:43:18. Function hash: 9bdd3a6d45b81df549bbe35f26aeeb85 -- func (o *TridentOrchestrator) ListNodes(context.Context) (nodes []*utils.Node, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -5121,15 +5081,14 @@ func (o *TridentOrchestrator) ListNodes(context.Context) (nodes []*utils.Node, e // DeleteNode removes the node from the orchestrator. // It returns an error if the node is not found. // Parameters: -// ctx - context (for cancellation) -// nodeName - name of the node +// nodeName - the name of the node to delete +// force - if true, delete the node even if volumes are published to it // Returns: -// error - any error encountered +// error - nil if the node was deleted successfully, or an error if the node was not found // Example: -// err := orchestrator.DeleteNode(ctx, "node1") +// err := orchestrator.DeleteNode("node1") // -// -- Doc autogenerated on 2022-05-26 19:43:18. Function hash: f40063d78d89136a99089e4c9c2b95a7 -- - +// -- Doc autogenerated on 2022-05-26 22:43:44. Function hash: f40063d78d89136a99089e4c9c2b95a7 -- func (o *TridentOrchestrator) DeleteNode(ctx context.Context, nodeName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -5174,18 +5133,20 @@ func (o *TridentOrchestrator) DeleteNode(ctx context.Context, nodeName string) ( return nil } -// deleteNode deletes a node from the orchestrator +// deleteNode removes the specified node from the orchestrator // It returns an error if the node does not exist // Parameters: // ctx - context -// nodeName - name of the node to delete -// Returns: -// error - error if the node does not exist +// nodeName - name of the node to be deleted +// Return: +// error - error if one occurred // Example: -// err := o.deleteNode(ctx, nodeName) +// err := o.deleteNode(ctx, "node1") +// if err != nil { +// return err +// } // -// -- Doc autogenerated on 2022-05-26 19:43:41. Function hash: 06e53486e08860cbb879e4101d6a9c68 -- - +// -- Doc autogenerated on 2022-05-26 22:44:08. Function hash: 06e53486e08860cbb879e4101d6a9c68 -- func (o *TridentOrchestrator) deleteNode(ctx context.Context, nodeName string) (err error) { node, found := o.nodes[nodeName] if !found { @@ -5283,16 +5244,15 @@ func (o *TridentOrchestrator) ListVolumePublicationsForVolume( return } -// listVolumePublicationsForVolume returns all publications for a volume +// listVolumePublicationsForVolume returns the list of publications for a volume // Parameters: -// volumeName: name of the volume -// Returns: -// []*utils.VolumePublication: list of publications for the volume +// volumeName - the name of the volume +// Return: +// the list of publications for the volume // Example: -// publications := o.listVolumePublicationsForVolume(ctx, volumeName) +// publications := o.listVolumePublicationsForVolume("myvol") // -// -- Doc autogenerated on 2022-05-26 19:43:56. Function hash: 44ca89b928a2986ee3de364f14767cb3 -- - +// -- Doc autogenerated on 2022-05-26 22:44:22. Function hash: 44ca89b928a2986ee3de364f14767cb3 -- func (o *TridentOrchestrator) listVolumePublicationsForVolume( _ context.Context, volumeName string, ) (publications []*utils.VolumePublication) { @@ -5320,16 +5280,15 @@ func (o *TridentOrchestrator) ListVolumePublicationsForNode( return } -// listVolumePublicationsForNode returns a list of volume publications for the given node +// listVolumePublicationsForNode returns a list of VolumePublications for a given node // Parameters: -// nodeName - the name of the node -// Return: -// a list of volume publications for the given node +// nodeName: name of the node to get the list of VolumePublications for +// Returns: +// []*utils.VolumePublication: list of VolumePublications for the given node // Example: -// publications, err := o.listVolumePublicationsForNode(nodeName) +// publications := o.listVolumePublicationsForNode("node1") // -// -- Doc autogenerated on 2022-05-26 19:44:12. Function hash: 8341522491607108df10aca16d8bc332 -- - +// -- Doc autogenerated on 2022-05-26 22:44:40. Function hash: 8341522491607108df10aca16d8bc332 -- func (o *TridentOrchestrator) listVolumePublicationsForNode( _ context.Context, nodeName string, ) (publications []*utils.VolumePublication) { @@ -5370,15 +5329,14 @@ func (o *TridentOrchestrator) DeleteVolumePublication(ctx context.Context, volum // removeVolumePublicationFromCache removes the volume publication from the cache // Parameters: -// volumeID - the volume's unique ID -// nodeID - the node's unique ID +// volumeID - the ID of the volume +// nodeID - the node that the volume is being removed from // Returns: // None // Example: -// o.removeVolumePublicationFromCache("volume-123", "node-123") +// removeVolumePublicationFromCache("volume1", "node1") // -// -- Doc autogenerated on 2022-05-26 19:44:35. Function hash: 0edde50e382bbe37edba87d678249a5a -- - +// -- Doc autogenerated on 2022-05-26 22:45:00. Function hash: 0edde50e382bbe37edba87d678249a5a -- func (o *TridentOrchestrator) removeVolumePublicationFromCache(volumeID, nodeID string) { delete(o.volumePublications[volumeID], nodeID) // If there are no more nodes for this volume, remove the volume's entry @@ -5392,16 +5350,13 @@ func (o *TridentOrchestrator) removeVolumePublicationFromCache(volumeID, nodeID // Parameters: // ctx - context for logging // backend - the backend to update -// newBackend - whether this is a new backend or an existing one +// newBackend - true if this is a new backend, false if it is an update // Returns: // error - error if the backend could not be updated // Example: -// if err := o.updateBackendOnPersistentStore(ctx, backend, newBackend); err != nil { -// return err -// } +// err := o.updateBackendOnPersistentStore(ctx, backend, true) // -// -- Doc autogenerated on 2022-05-26 19:45:16. Function hash: 0b8bff03ea76c0c057f27c6fad87a4db -- - +// -- Doc autogenerated on 2022-05-26 22:47:30. Function hash: 0b8bff03ea76c0c057f27c6fad87a4db -- func (o *TridentOrchestrator) updateBackendOnPersistentStore( ctx context.Context, backend storage.Backend, newBackend bool, ) error { @@ -5428,18 +5383,14 @@ func (o *TridentOrchestrator) updateBackendOnPersistentStore( // updateVolumeOnPersistentStore updates the volume information in persistent store // It returns an error if the volume is not found in persistent store // Parameters: -// ctx - context for logging -// vol - volume to be updated +// ctx - context +// vol - volume object // Returns: -// error - error if any +// error - error // Example: // err := o.updateVolumeOnPersistentStore(ctx, vol) -// if err != nil { -// return err -// } // -// -- Doc autogenerated on 2022-05-26 19:45:40. Function hash: c4edd3c8428fe8edb94d43e360c1775a -- - +// -- Doc autogenerated on 2022-05-26 22:47:54. Function hash: c4edd3c8428fe8edb94d43e360c1775a -- func (o *TridentOrchestrator) updateVolumeOnPersistentStore(ctx context.Context, vol *storage.Volume) error { // Update the volume information in persistent store Logc(ctx).WithFields(log.Fields{ @@ -5451,19 +5402,18 @@ func (o *TridentOrchestrator) updateVolumeOnPersistentStore(ctx context.Context, return o.storeClient.UpdateVolume(ctx, vol) } -// replaceBackendAndUpdateVolumesOnPersistentStore updates the backend and volume information in persistent store -// It returns an error if the backend or volume information could not be updated. +// replaceBackendAndUpdateVolumesOnPersistentStore replaces the backend and updates the volumes on the persistent store +// It returns an error if the backend could not be replaced // Parameters: -// ctx - context -// origBackend - original backend -// newBackend - new backend -// Return: -// error - error if the backend or volume information could not be updated +// ctx - context for logging +// origBackend - the backend to be replaced +// newBackend - the backend to replace the original backend with +// Returns: +// error - error if the backend could not be replaced // Example: -// err := o.replaceBackendAndUpdateVolumesOnPersistentStore(ctx, origBackend, newBackend) +// err := o.replaceBackendAndUpdateVolumesOnPersistentStore(context.Background(), origBackend, newBackend) // -// -- Doc autogenerated on 2022-05-26 19:46:10. Function hash: a493110fffae19fac507baac4b3502e7 -- - +// -- Doc autogenerated on 2022-05-26 22:48:20. Function hash: a493110fffae19fac507baac4b3502e7 -- func (o *TridentOrchestrator) replaceBackendAndUpdateVolumesOnPersistentStore( ctx context.Context, origBackend, newBackend storage.Backend, ) error { @@ -5475,17 +5425,17 @@ func (o *TridentOrchestrator) replaceBackendAndUpdateVolumesOnPersistentStore( return o.storeClient.ReplaceBackendAndUpdateVolumes(ctx, origBackend, newBackend) } -// isCRDContext returns true if the context is from a CRD request +// isCRDContext returns true if the context is from a CRD // Parameters: -// ctx - the context +// ctx - the context // Returns: -// bool - true if the context is from a CRD request +// true if the context is from a CRD // Example: -// ctx := context.WithValue(context.Background(), ContextKeyRequestSource, ContextSourceCRD) -// isCRD := o.isCRDContext(ctx) +// if o.isCRDContext(ctx) { +// // context is from a CRD +// } // -// -- Doc autogenerated on 2022-05-26 19:47:01. Function hash: fac4a506fe93e8407310464685f2985d -- - +// -- Doc autogenerated on 2022-05-26 22:48:47. Function hash: fac4a506fe93e8407310464685f2985d -- func (o *TridentOrchestrator) isCRDContext(ctx context.Context) bool { ctxSource := ctx.Value(ContextKeyRequestSource) return ctxSource != nil && ctxSource == ContextSourceCRD @@ -5583,18 +5533,15 @@ func (o *TridentOrchestrator) GetMirrorStatus( return mirrorBackend.GetMirrorStatus(ctx, localVolumeHandle, remoteVolumeHandle) } -// CanBackendMirror returns whether the backend is capable of mirroring +// CanBackendMirror returns true if the backend can mirror // Parameters: -// context - The context -// backendUUID - The backend UUID +// backendUUID - backend to check // Returns: -// capable - Whether the backend is mirror capable -// err - Any errors +// (capable, error) // Example: -// capable, err := trident.CanBackendMirror(ctx, backendUUID) +// capable, err := orchestrator.CanBackendMirror(context.Background(), "backend-uuid") // -// -- Doc autogenerated on 2022-05-26 19:47:24. Function hash: bc1b19ddd30247a2154212e70860764d -- - +// -- Doc autogenerated on 2022-05-26 22:49:04. Function hash: bc1b19ddd30247a2154212e70860764d -- func (o *TridentOrchestrator) CanBackendMirror(_ context.Context, backendUUID string) (capable bool, err error) { if o.bootstrapError != nil { return false, o.bootstrapError @@ -5634,20 +5581,18 @@ func (o *TridentOrchestrator) ReleaseMirror( return mirrorBackend.ReleaseMirror(ctx, localVolumeHandle) } -// GetCHAP retrieves the CHAP information for a volume -// It returns the CHAP information for the volume, or an error if the volume does not exist +// GetCHAP returns the CHAP credentials for the specified volume and node. // Parameters: -// ctx - context -// volumeName - name of the volume -// nodeName - name of the node +// ctx - context for logging +// volumeName - the name of the volume +// nodeName - the name of the node // Returns: -// chapInfo - CHAP information for the volume -// err - error if any +// chapInfo - the CHAP credentials +// err - error if CHAP credentials could not be retrieved // Example: -// chapInfo, err := orchestrator.GetCHAP(ctx, "vol01", "node01") +// chapInfo, err := orchestrator.GetCHAP(ctx, "volume1", "node1") // -// -- Doc autogenerated on 2022-05-26 19:47:55. Function hash: 235deca5df832ab0568e48718d1e814c -- - +// -- Doc autogenerated on 2022-05-26 22:49:24. Function hash: 235deca5df832ab0568e48718d1e814c -- func (o *TridentOrchestrator) GetCHAP( ctx context.Context, volumeName, nodeName string, ) (chapInfo *utils.IscsiChapInfo, err error) { From d47fdd16bb9a2db0b13be7bdf15ae5f329d331eb Mon Sep 17 00:00:00 2001 From: "Roussin, Jerome" Date: Thu, 23 Jun 2022 09:51:02 -0400 Subject: [PATCH 3/3] Regenerated doc using latest autodoc version --- core/orchestrator_core.go | 1782 ++++++++++++++++++++++++------------- 1 file changed, 1165 insertions(+), 617 deletions(-) diff --git a/core/orchestrator_core.go b/core/orchestrator_core.go index 8ec6b5ae8..2d17434a2 100644 --- a/core/orchestrator_core.go +++ b/core/orchestrator_core.go @@ -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. +// Parameters: +// operation - the name of the operation +// err - the error if there is any +// Returns: +// error - the error if the update is invalid, nil if the update is valid +// Example: +// err := o.recordTiming("backend_add", err) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 10725abd4157c24fed404e7638b0fc0c -- func recordTiming(operation string, err *error) func() { startTime := time.Now() return func() { @@ -54,21 +65,14 @@ func recordTiming(operation string, err *error) func() { } } -// recordTransactionTiming records the duration of a transaction in milliseconds -// and whether it was successful or not. +// recordTransactionTiming records the timing of a volume transaction. // Parameters: -// txn: the transaction to record -// err: the error that occurred, or nil if no error occurred -// Returns: -// nothing +// txn - the volume transaction +// err - the error if there is any // Example: -// err := c.transaction(func(txn *storage.VolumeTransaction) error { -// // do something -// return nil -// }) -// recordTransactionTiming(txn, &err) +// recordTransactionTiming(txn, err) // -// -- Doc autogenerated on 2022-05-26 22:14:22. Function hash: d39f7d63300a6cea90e7402ac7280126 -- +// -- Doc autogenerated on 2022-06-21. Function hash: d39f7d63300a6cea90e7402ac7280126 -- func recordTransactionTiming(txn *storage.VolumeTransaction, err *error) { if txn == nil || txn.VolumeCreatingConfig == nil { // for unit tests, there will be no txn to record @@ -107,6 +111,15 @@ type TridentOrchestrator struct { } // NewTridentOrchestrator returns a storage orchestrator instance +// It returns a new storage orchestrator instance +// Parameters: +// client - the persistent store client +// Returns: +// *TridentOrchestrator - the new storage orchestrator instance +// Example: +// orchestrator := NewTridentOrchestrator(client) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 191889dd8a79b6ce0f352ad6106b0f84 -- func NewTridentOrchestrator(client persistentstore.Client) *TridentOrchestrator { return &TridentOrchestrator{ backends: make(map[string]storage.Backend), // key is UUID, not name @@ -123,20 +136,17 @@ func NewTridentOrchestrator(client persistentstore.Client) *TridentOrchestrator } } -// transformPersistentState transforms the persistent state from previous versions to the current -// version. +// transformPersistentState transforms the persistent store to the current Trident API version. // It returns an error if the transformation fails. // Parameters: // ctx - context for logging // Returns: -// error - error if the transformation fails +// error - the error if the transformation fails, nil if the transformation succeeds // Example: // err := o.transformPersistentState(ctx) -// if err != nil { -// return err -// } // -// -- Doc autogenerated on 2022-05-26 22:14:49. Function hash: c9019c1c63e1407926e156160bcba2b4 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: c9019c1c63e1407926e156160bcba2b4 -- func (o *TridentOrchestrator) transformPersistentState(ctx context.Context) error { version, err := o.storeClient.GetVersion(ctx) if err != nil && persistentstore.MatchKeyNotFoundErr(err) { @@ -170,16 +180,16 @@ func (o *TridentOrchestrator) transformPersistentState(ctx context.Context) erro return nil } -// Bootstrap initializes the orchestrator. -// It returns an error if the orchestrator is already bootstrapped. +// Bootstrap initializes the orchestrator. It reads persistent state from the +// database and initializes the in-memory state. It also initializes the +// backend storage drivers. +// It returns an error if the initialization fails. // Returns: -// - utils.BootstrapError if the orchestrator is already bootstrapped -// - utils.PersistentStoreError if there is an error reading from the persistent store -// - utils.OrchestratorError if there is an error bootstrapping the orchestrator +// error - the error if there is any // Example: -// err := o.Bootstrap() +// err := o.Bootstrap(ctx) // -// -- Doc autogenerated on 2022-05-26 22:15:25. Function hash: 04dcb5d2d9ba6669a7ec6f5734590b4e -- +// -- Doc autogenerated on 2022-06-21. Function hash: 04dcb5d2d9ba6669a7ec6f5734590b4e -- func (o *TridentOrchestrator) Bootstrap() error { ctx := GenerateRequestContext(context.Background(), "", ContextSourceInternal) var err error @@ -209,19 +219,16 @@ func (o *TridentOrchestrator) Bootstrap() error { return nil } -// bootstrapBackends is used to initialize the backends from the persistent store. -// It returns an error if there is a problem reading the backends from the persistent store. +// bootstrapBackends initializes the backends that were persisted in the store. +// It returns an error if there is any. // Parameters: -// ctx - context +// ctx - context for logging // Returns: -// error - error if there is a problem reading the backends from the persistent store. +// error - the error if there is any // Example: -// err := bootstrapBackends(ctx) -// if err != nil { -// log.Errorf("Could not bootstrap backends: %v", err) -// } +// err := o.bootstrapBackends(ctx) // -// -- Doc autogenerated on 2022-05-26 22:16:21. Function hash: ace19e963152e034bd3e2ad4e44efd2a -- +// -- Doc autogenerated on 2022-06-21. Function hash: ace19e963152e034bd3e2ad4e44efd2a -- func (o *TridentOrchestrator) bootstrapBackends(ctx context.Context) error { persistentBackends, err := o.storeClient.GetBackends(ctx) if err != nil { @@ -313,17 +320,16 @@ func (o *TridentOrchestrator) bootstrapBackends(ctx context.Context) error { return nil } -// bootstrapStorageClasses adds storage classes from the persistent store to the orchestrator's -// in-memory storage class map. -// It returns an error if the persistent store cannot be accessed. +// bootstrapStorageClasses initializes the storage class cache from the backend store. +// It returns an error if the initialization fails. // Parameters: // ctx - context for logging // Returns: -// error - if the persistent store cannot be accessed +// error - error if there is any // Example: // err := o.bootstrapStorageClasses(ctx) // -// -- Doc autogenerated on 2022-05-26 22:16:42. Function hash: 21a98ba2c9aed0a70ca745011194074a -- +// -- Doc autogenerated on 2022-06-21. Function hash: 21a98ba2c9aed0a70ca745011194074a -- func (o *TridentOrchestrator) bootstrapStorageClasses(ctx context.Context) error { persistentStorageClasses, err := o.storeClient.GetStorageClasses(ctx) if err != nil { @@ -344,18 +350,18 @@ func (o *TridentOrchestrator) bootstrapStorageClasses(ctx context.Context) error return nil } -// Updates the o.volumes cache with the latest backend data. This function should only edit o.volumes in place to avoid +// bootstrapVolumes 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 -// It returns an error if it fails to get the volumes from the store +// It returns an error if there is any. // Parameters: // ctx - context for logging // Returns: -// error - error if any +// error - the error if there is any // Example: // err := o.bootstrapVolumes(ctx) // -// -- Doc autogenerated on 2022-05-26 22:17:01. Function hash: 713a6e9aafc3998ba2508038c533087d -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: 713a6e9aafc3998ba2508038c533087d -- func (o *TridentOrchestrator) bootstrapVolumes(ctx context.Context) error { volumes, err := o.storeClient.GetVolumes(ctx) if err != nil { @@ -408,16 +414,17 @@ func (o *TridentOrchestrator) bootstrapVolumes(ctx context.Context) error { return nil } -// bootstrapSnapshots loads existing snapshots from the backend store. -// It returns an error if the store is unavailable. +// bootstrapSnapshots initializes the snapshots map with snapshots that already exist in the backend. +// It returns an error if the initialization fails. // Parameters: -// ctx - context for the operation +// ctx - context for logging // Returns: -// error - any error encountered +// error - the error if the initialization is invalid, nil if the initialization is valid // Example: -// err := o.bootstrapSnapshots(ctx) +// err := o.bootstrapSnapshots(ctx) +// // -// -- Doc autogenerated on 2022-05-26 22:17:27. Function hash: 7cc86ef066af5a6d4d4cccf2aaacc362 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 7cc86ef066af5a6d4d4cccf2aaacc362 -- func (o *TridentOrchestrator) bootstrapSnapshots(ctx context.Context) error { snapshots, err := o.storeClient.GetSnapshots(ctx) if err != nil { @@ -452,20 +459,16 @@ func (o *TridentOrchestrator) bootstrapSnapshots(ctx context.Context) error { return nil } -// bootstrapVolTxns retrieves any volume transaction logs from the persistent store and attempts to -// complete them. -// It returns an error if any of the transactions fail to complete. +// bootstrapVolTxns initializes the volume transaction logs from the persistent store. +// It returns an error if the initialization fails. // Parameters: -// ctx - context +// ctx - context for logging // Returns: -// error - an error if any of the transactions fail to complete +// error - the error if there is any // Example: // err := o.bootstrapVolTxns(ctx) -// if err != nil { -// return err -// } // -// -- Doc autogenerated on 2022-05-26 22:18:03. Function hash: e33c0ea45aaa4a9d8262fd4f04ac4667 -- +// -- Doc autogenerated on 2022-06-21. Function hash: e33c0ea45aaa4a9d8262fd4f04ac4667 -- func (o *TridentOrchestrator) bootstrapVolTxns(ctx context.Context) error { volTxns, err := o.storeClient.GetVolumeTransactions(ctx) if err != nil && !persistentstore.MatchKeyNotFoundErr(err) { @@ -482,16 +485,17 @@ func (o *TridentOrchestrator) bootstrapVolTxns(ctx context.Context) error { return nil } -// bootstrapNodes initializes the nodes map with existing nodes -// It returns an error if there was a problem getting the nodes +// bootstrapNodes initializes the nodes in the store. +// It returns an error if the initialization fails. // Parameters: -// ctx - context +// ctx - context for logging // Returns: -// error - error if there was a problem getting the nodes +// error - the error if there is any // Example: // err := o.bootstrapNodes(ctx) // -// -- Doc autogenerated on 2022-05-26 22:18:32. Function hash: 7cfe94c5ecbb68533b741378eaa5ee46 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: 7cfe94c5ecbb68533b741378eaa5ee46 -- func (o *TridentOrchestrator) bootstrapNodes(ctx context.Context) error { // Don't bootstrap nodes if we're not CSI if config.CurrentDriverContext != config.ContextCSI { @@ -516,16 +520,17 @@ func (o *TridentOrchestrator) bootstrapNodes(ctx context.Context) error { return nil } -// bootstrapVolumePublications adds any existing volume publications to the cache -// It returns an error if the volume publications cannot be retrieved from the store +// bootstrapVolumePublications initializes the volume publications cache with any publications that already exist in the store. +// It returns an error if the initialization fails. // Parameters: // ctx - context for logging // Returns: -// error - nil if the volume publications were successfully added to the cache +// error - the error if there is any // Example: // err := o.bootstrapVolumePublications(ctx) // -// -- Doc autogenerated on 2022-05-26 22:18:54. Function hash: feea1b84b5d4a911d16860d0c211b775 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: feea1b84b5d4a911d16860d0c211b775 -- func (o *TridentOrchestrator) bootstrapVolumePublications(ctx context.Context) error { // Don't bootstrap volume publications if we're not CSI if config.CurrentDriverContext != config.ContextCSI { @@ -547,15 +552,14 @@ func (o *TridentOrchestrator) bootstrapVolumePublications(ctx context.Context) e return nil } -// addVolumePublicationToCache adds the volume publication to the orchestrator's cache +// addVolumePublicationToCache adds a volume publication to the cache. // Parameters: -// vp: Volume publication to add to the cache -// Returns: -// none +// vp - the volume publication // Example: -// o.addVolumePublicationToCache(&vp) +// o.addVolumePublicationToCache(vp) +// // -// -- Doc autogenerated on 2022-05-26 22:19:15. Function hash: 6831b1fc734710c782e9132682016e51 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 6831b1fc734710c782e9132682016e51 -- func (o *TridentOrchestrator) addVolumePublicationToCache(vp *utils.VolumePublication) { // If the volume has no entry we need to initialize the inner map if o.volumePublications[vp.VolumeName] == nil { @@ -564,20 +568,17 @@ func (o *TridentOrchestrator) addVolumePublicationToCache(vp *utils.VolumePublic o.volumePublications[vp.VolumeName][vp.NodeName] = vp } -// bootstrap loads all persistent objects from the store and initializes the -// orchestrator state. -// It returns an error if the bootstrap fails. +// bootstrap initializes the orchestrator by fetching all of the backends, storage classes, volumes, snapshots, +// volumetxns, nodes, and volume publications from the store. It also initializes the core metrics. +// It returns an error if any of the fetches fail. // Parameters: -// ctx - context +// ctx - context for logging // Returns: -// error - bootstrap error if any +// error - error if there is any // Example: -// err := o.bootstrap(ctx) -// if err != nil { -// return err -// } +// err := o.bootstrap(ctx) // -// -- Doc autogenerated on 2022-05-26 22:19:32. Function hash: bcd99e963177e37d4f93a0ee26ad9890 -- +// -- Doc autogenerated on 2022-06-21. Function hash: bcd99e963177e37d4f93a0ee26ad9890 -- func (o *TridentOrchestrator) bootstrap(ctx context.Context) error { // Fetching backend information @@ -625,6 +626,11 @@ func (o *TridentOrchestrator) bootstrap(ctx context.Context) error { } // Stop stops the orchestrator core. +// Example: +// orchestrator.Stop() +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 3a67a0fe542b11aed94153d8aabdd3cc -- func (o *TridentOrchestrator) Stop() { // Stop the node access reconciliation background task if o.stopNodeAccessLoop != nil { @@ -637,6 +643,11 @@ func (o *TridentOrchestrator) Stop() { // updateMetrics updates the metrics that track the core objects. // The caller should hold the orchestrator lock. +// Example: +// o.updateMetrics() +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: ab104a423eb8f8557aa63ebaff87a6bf -- func (o *TridentOrchestrator) updateMetrics() { tridentBuildInfo.WithLabelValues(config.BuildHash, config.OrchestratorVersion.ShortString(), @@ -688,24 +699,18 @@ func (o *TridentOrchestrator) updateMetrics() { } } -// handleFailedTransaction attempts to clean up a failed transaction. -// -// This function is called when a transaction fails to complete, and the -// orchestrator is restarted. It is responsible for cleaning up any -// resources that were created as part of the transaction, and for removing -// the transaction from persistent store. -// It returns an error if it is unable to clean up the transaction. +// handleFailedTransaction handles the failed transaction. +// It returns an error if the transaction is invalid. // Parameters: -// v - the volume transaction to clean up +// ctx - context for logging +// v - the volume transaction // Returns: -// error - any error encountered while cleaning up the transaction +// error - the error if there is any // Example: -// err := handleFailedTransaction(v) -// if err != nil { -// return err -// } +// err := o.handleFailedTransaction(ctx, v) +// // -// -- Doc autogenerated on 2022-05-26 22:19:55. Function hash: 39541d951f05903909338f9e59963947 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 39541d951f05903909338f9e59963947 -- func (o *TridentOrchestrator) handleFailedTransaction(ctx context.Context, v *storage.VolumeTransaction) error { switch v.Op { case storage.AddVolume, storage.DeleteVolume, @@ -943,22 +948,17 @@ func (o *TridentOrchestrator) handleFailedTransaction(ctx context.Context, v *st return nil } -// resetImportedVolumeName attempts to rename the volume back to its original name. -// It returns an error if the volume is not found. +// resetImportedVolumeName resets the name of an imported volume to its original name. +// It returns an error if the volume cannot be renamed. // Parameters: -// volume - volume to rename +// ctx - context for logging +// volume - the volume to reset // Returns: -// error - error if the volume is not found +// error - the error if the reset failed, nil if the reset succeeded // Example: -// volume := &storage.VolumeConfig{ -// Name: "volume1", -// InternalName: "volume1-internal", -// ImportOriginalName: "volume1-original", -// ImportNotManaged: false, -// } -// error := orchestrator.resetImportedVolumeName(ctx, volume) +// err := o.resetImportedVolumeName(ctx, volume) // -// -- Doc autogenerated on 2022-05-26 22:20:21. Function hash: 1033950f7f2014fd8a87dbfb93781f51 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 1033950f7f2014fd8a87dbfb93781f51 -- func (o *TridentOrchestrator) resetImportedVolumeName(ctx context.Context, volume *storage.VolumeConfig) error { // The volume could be renamed (notManaged = false) without being persisted. // If the volume wasn't added to the persistent store, we attempt to rename @@ -975,15 +975,13 @@ func (o *TridentOrchestrator) resetImportedVolumeName(ctx context.Context, volum return nil } -// AddFrontend adds a frontend to the orchestrator. +// AddFrontend adds a new frontend to the orchestrator. // Parameters: -// f - frontend to add -// Returns: -// none +// f - the frontend plugin // Example: -// o.AddFrontend(f) +// orchestrator.AddFrontend(frontend1) // -// -- Doc autogenerated on 2022-05-26 22:20:34. Function hash: be80e16a539796ac4231803c9351df2d -- +// -- Doc autogenerated on 2022-06-21. Function hash: be80e16a539796ac4231803c9351df2d -- func (o *TridentOrchestrator) AddFrontend(f frontend.Plugin) { name := f.GetName() if _, ok := o.frontends[name]; ok { @@ -994,17 +992,18 @@ func (o *TridentOrchestrator) AddFrontend(f frontend.Plugin) { o.frontends[name] = f } -// GetFrontend returns the frontend plugin with the specified name. +// GetFrontend returns a frontend by name +// It returns an error if the frontend does not exist // Parameters: -// ctx - context for logging -// name - name of the frontend plugin +// ctx - context for logging +// name - the name of the frontend // Returns: -// frontend plugin with the specified name -// error - error if frontend does not exist +// frontend.Plugin - the frontend +// error - error if there is any // Example: -// fe, err := GetFrontend(ctx, "nfs") +// fe, err := orchestrator.GetFrontend(ctx, "frontend1") // -// -- Doc autogenerated on 2022-05-26 22:20:49. Function hash: 68c5aa2cdd27528e7d82eb37fe73b601 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 68c5aa2cdd27528e7d82eb37fe73b601 -- func (o *TridentOrchestrator) GetFrontend(ctx context.Context, name string) (frontend.Plugin, error) { if fe, ok := o.frontends[name]; !ok { err := fmt.Errorf("requested frontend %s does not exist", name) @@ -1023,9 +1022,9 @@ func (o *TridentOrchestrator) GetFrontend(ctx context.Context, name string) (fro // Returns: // error - the error if the update is invalid, nil if the update is valid // Example: -// err := validateBackendUpdate(oldBackend, newBackend) +// err := o.validateBackendUpdate(oldBackend, newBackend) // -// -- Doc autogenerated on 2022-05-26 22:21:45. Function hash: 80555ddd7f23803234d84705cd8e72e3 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 80555ddd7f23803234d84705cd8e72e3 -- func (o *TridentOrchestrator) validateBackendUpdate(oldBackend, newBackend storage.Backend) error { // Validate that backend type isn't being changed as backend type has // implications for the internal volume names. @@ -1038,21 +1037,35 @@ func (o *TridentOrchestrator) validateBackendUpdate(oldBackend, newBackend stora return nil } -// GetVersion returns the version of the orchestrator +// GetVersion returns the version of the orchestrator. +// It returns an error if the orchestrator is not yet initialized. // Parameters: -// ctx - context for the request +// ctx - context for logging // Returns: -// version string -// error - if any +// string - the version of the orchestrator +// error - the error if there is any // Example: -// version, err := orchestrator.GetVersion(ctx) +// version, err := o.GetVersion(ctx) // -// -- Doc autogenerated on 2022-05-26 22:22:01. Function hash: b3ff28ff24fcdaca9fca3da6aa509290 -- +// -- Doc autogenerated on 2022-06-21. Function hash: b3ff28ff24fcdaca9fca3da6aa509290 -- func (o *TridentOrchestrator) GetVersion(context.Context) (string, error) { return config.OrchestratorVersion.String(), o.bootstrapError } // AddBackend handles creation of a new storage backend +// It returns an error if the backend cannot be added. +// Parameters: +// ctx - context for logging +// configJSON - the JSON configuration for the backend +// configRef - the reference to the backend configuration +// Returns: +// storage.BackendExternal - the backend external representation +// error - the error if the backend cannot be added, nil if the backend is added successfully +// Example: +// backendExternal, err := o.AddBackend(ctx, configJSON, configRef) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 34be8d97dce7cb93c1f08707afc3fa62 -- func (o *TridentOrchestrator) AddBackend( ctx context.Context, configJSON, configRef string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1085,6 +1098,20 @@ func (o *TridentOrchestrator) AddBackend( // addBackend creates a new storage backend. It assumes the mutex lock is // already held or not required (e.g., during bootstrapping). +// It returns an error if the backend cannot be added. +// Parameters: +// ctx - context for logging +// configJSON - the JSON configuration for the backend +// backendUUID - the UUID of the backend +// configRef - the configRef for the backend +// Returns: +// storage.BackendExternal - the backend external representation +// error - the error if the backend cannot be added, nil if the backend is added +// Example: +// backendExternal, err := o.addBackend(ctx, configJSON, backendUUID, configRef) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 1844d31bca8826ed9ced9036eb98c934 -- func (o *TridentOrchestrator) addBackend( ctx context.Context, configJSON, backendUUID, configRef string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1187,6 +1214,19 @@ func (o *TridentOrchestrator) addBackend( } // validateAndCreateBackendFromConfig validates config and creates backend based on Config +// It returns an error if the backend update is invalid. +// Parameters: +// ctx - context for logging +// configJSON - the config JSON +// configRef - the config reference +// backendUUID - the backend UUID +// Returns: +// storage.Backend - the backend +// error - the error if the update is invalid, nil if the update is valid +// Example: +// err := o.validateAndCreateBackendFromConfig(ctx, configJSON, configRef, backendUUID) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 2fefe24643f68e5970070168da26f2d9 -- func (o *TridentOrchestrator) validateAndCreateBackendFromConfig( ctx context.Context, configJSON, configRef, backendUUID string, ) (backendExternal storage.Backend, err error) { @@ -1224,6 +1264,20 @@ func (o *TridentOrchestrator) validateAndCreateBackendFromConfig( } // UpdateBackend updates an existing backend. +// It returns an error if the backend update is invalid. +// Parameters: +// ctx - context for logging +// backendName - the name of the backend +// configJSON - the JSON configuration for the backend +// configRef - the reference to the backend configuration +// Returns: +// storage.BackendExternal - the backend +// error - the error if the update is invalid, nil if the update is valid +// Example: +// backend, err := o.UpdateBackend(ctx, "backend1", configJSON, configRef) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: ac16cef94ad15602c48bdc8ddaac8f09 -- func (o *TridentOrchestrator) UpdateBackend( ctx context.Context, backendName, configJSON, configRef string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1257,6 +1311,19 @@ func (o *TridentOrchestrator) UpdateBackend( } // updateBackend updates an existing backend. It assumes the mutex lock is already held. +// It returns an error if the backend update is invalid. +// Parameters: +// ctx - context for logging +// backendName - the name of the backend +// configJSON - JSON string representation of the backend config +// configRef - configuration reference for this orchestrator (e.g. a configmap) +// Returns: +// storage.BackendExternal - the backend external +// error - the error if the update is invalid, nil if the update is valid +// Example: +// backendExternal, err := orchestrator.updateBackend("backend1", "configJSON", "backendUUID", "configRef") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 77a2adc15ab73dcb06f28116870daedc -- func (o *TridentOrchestrator) updateBackend( ctx context.Context, backendName, configJSON, configRef string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1270,6 +1337,21 @@ func (o *TridentOrchestrator) updateBackend( } // UpdateBackendByBackendUUID updates an existing backend. +// It returns an error if the backend update is invalid. +// Parameters: +// ctx - context for logging +// backendName - the name of the backend +// configJSON - the JSON configuration for the backend +// backendUUID - the UUID of the backend +// configRef - the config reference for the backend +// Returns: +// storage.BackendExternal - the backend +// error - the error if the update is invalid, nil if the update is valid +// Example: +// backend, err := orchestrator.UpdateBackendByBackendUUID(ctx, "backend1", configJSON, backendUUID, configRef) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 44aa8fb20d8dabe1ff9780954d172644 -- func (o *TridentOrchestrator) UpdateBackendByBackendUUID( ctx context.Context, backendName, configJSON, backendUUID, configRef string, ) (backend *storage.BackendExternal, err error) { @@ -1302,8 +1384,21 @@ func (o *TridentOrchestrator) UpdateBackendByBackendUUID( return backend, nil } -// TODO combine this one and the one above // updateBackendByBackendUUID updates an existing backend. It assumes the mutex lock is already held. +// It returns an error if the backend update is invalid. +// Parameters: +// ctx - context for logging +// backendName - the name of the backend +// configJSON - the JSON configuration for the backend +// backendUUID - the UUID of the backend +// callingConfigRef - the UUID of the TridentBackendConfig CR that initiated this update +// Returns: +// storage.BackendExternal - the backend external representation +// error - error if there is any +// Example: +// backendExternal, err := orchestrator.updateBackendByBackendUUID(ctx, "backend1", configJSON, "uuid1", "uuid2") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 8026625a6962d3055aaee3801d241d07 -- func (o *TridentOrchestrator) updateBackendByBackendUUID( ctx context.Context, backendName, configJSON, backendUUID, callingConfigRef string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1526,6 +1621,19 @@ func (o *TridentOrchestrator) updateBackendByBackendUUID( } // UpdateBackendState updates an existing backend's state. +// It returns an error if the backend update is invalid. +// Parameters: +// ctx - context for logging +// backendName - the name of the backend +// backendState - the new state of the backend +// Returns: +// storage.BackendExternal - the backend +// error - error if there is any +// Example: +// backend, err := orchestrator.UpdateBackendState(ctx, "backend1", "up") +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 98c9ddbad561e4fd433f44fac8ab4e78 -- func (o *TridentOrchestrator) UpdateBackendState( ctx context.Context, backendName, backendState string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1543,6 +1651,18 @@ func (o *TridentOrchestrator) UpdateBackendState( } // updateBackendState updates an existing backend's state. It assumes the mutex lock is already held. +// It returns an error if the backend update is invalid. +// Parameters: +// ctx - context for logging +// backendName - the name of the backend +// backendState - the new state of the backend +// Returns: +// storage.BackendExternal - the backend +// error - the error if the update is invalid, nil if the update is valid +// Example: +// backend, err := orchestrator.updateBackendState(ctx, "backend1", "Failed") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 2a4b31771a2b11c73b1d43bc4fa94d33 -- func (o *TridentOrchestrator) updateBackendState( ctx context.Context, backendName, backendState string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1578,16 +1698,17 @@ func (o *TridentOrchestrator) updateBackendState( return backend.ConstructExternal(ctx), o.storeClient.UpdateBackend(ctx, backend) } -// getBackendUUIDByBackendName returns the backend UUID for the given backend name +// getBackendUUIDByBackendName returns a backend UUID by name +// It returns an error if the backend UUID is not found. // Parameters: // backendName - the name of the backend // Returns: -// backendUUID - the backend UUID -// error - any error encountered +// string - the UUID of the backend +// error - error if there is any // Example: -// backendUUID, _ := o.getBackendUUIDByBackendName("ontap-nas-1") +// backendUUID, err := orchestrator.getBackendUUIDByBackendName("backend1") // -// -- Doc autogenerated on 2022-05-26 22:22:21. Function hash: 3432223f3c321828475a38387539f630 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 3432223f3c321828475a38387539f630 -- func (o *TridentOrchestrator) getBackendUUIDByBackendName(backendName string) (string, error) { backendUUID := "" for _, b := range o.backends { @@ -1600,6 +1721,7 @@ func (o *TridentOrchestrator) getBackendUUIDByBackendName(backendName string) (s } // getBackendByBackendName returns a backend by name +// It returns an error if the backend is not found // Parameters: // backendName - the name of the backend // Returns: @@ -1608,7 +1730,7 @@ func (o *TridentOrchestrator) getBackendUUIDByBackendName(backendName string) (s // Example: // backend, err := orchestrator.getBackendByBackendName("backend1") // -// -- Doc autogenerated on 2022-05-26 22:22:40. Function hash: 5359cbb6a4e1cb6e05469580d3214563 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 5359cbb6a4e1cb6e05469580d3214563 -- func (o *TridentOrchestrator) getBackendByBackendName(backendName string) (storage.Backend, error) { for _, b := range o.backends { if b.Name() == backendName { @@ -1618,20 +1740,17 @@ func (o *TridentOrchestrator) getBackendByBackendName(backendName string) (stora return nil, utils.NotFoundError(fmt.Sprintf("backend %v was not found", backendName)) } -// getBackendByConfigRef returns a backend based on its configRef +// getBackendByConfigRef returns a backend by configRef +// It returns an error if the backend is not found. // Parameters: -// configRef - the configRef of the backend +// configRef - the configRef of the backend // Returns: -// storage.Backend - the backend -// error - any error encountered +// storage.Backend - the backend +// error - error if there is any // Example: -// backend, err := o.getBackendByConfigRef("backend1") -// if err != nil { -// log.Error(err) -// return err -// } +// backend, err := orchestrator.getBackendByConfigRef("configRef1") // -// -- Doc autogenerated on 2022-05-26 22:23:05. Function hash: 37e7727af627a51a35149814c5e420af -- +// -- Doc autogenerated on 2022-06-21. Function hash: 37e7727af627a51a35149814c5e420af -- func (o *TridentOrchestrator) getBackendByConfigRef(configRef string) (storage.Backend, error) { for _, b := range o.backends { if b.ConfigRef() == configRef { @@ -1641,20 +1760,17 @@ func (o *TridentOrchestrator) getBackendByConfigRef(configRef string) (storage.B return nil, utils.NotFoundError(fmt.Sprintf("backend based on configRef '%v' was not found", configRef)) } -// getBackendByBackendUUID returns the backend with the given backendUUID +// getBackendByBackendUUID returns a backend by UUID +// It returns an error if the backend UUID is not found. // Parameters: -// backendUUID - the backendUUID of the backend to return +// backendUUID - the UUID of the backend // Returns: -// storage.Backend - the backend with the given backendUUID -// error - nil if the backend was found, otherwise an error is returned +// storage.Backend - the backend +// error - error if there is any // Example: -// backend, err := orchestrator.getBackendByBackendUUID(backendUUID) -// if err != nil { -// return err -// } -// // use the backend +// backend, err := orchestrator.getBackendByBackendUUID("backend1") // -// -- Doc autogenerated on 2022-05-26 22:23:32. Function hash: 5b6c42a570cd7be7efb047a76057cbdd -- +// -- Doc autogenerated on 2022-06-21. Function hash: 5b6c42a570cd7be7efb047a76057cbdd -- func (o *TridentOrchestrator) getBackendByBackendUUID(backendUUID string) (storage.Backend, error) { backend := o.backends[backendUUID] if backend != nil { @@ -1663,20 +1779,18 @@ func (o *TridentOrchestrator) getBackendByBackendUUID(backendUUID string) (stora return nil, utils.NotFoundError(fmt.Sprintf("backend uuid %v was not found", backendUUID)) } -// GetBackend returns the backend object for the specified backend name. +// GetBackend returns a backend by name +// It returns an error if the backend is not found // Parameters: -// ctx - context for logging -// backendName - name of the backend to get +// ctx - context for logging +// backendName - the name of the backend // Returns: -// *storage.BackendExternal - backend object -// error - an error if there was a problem getting the backend +// storage.BackendExternal - the backend +// error - error if there is any // Example: -// backend, err := orchestrator.GetBackend(ctx, "backend1") -// if err != nil { -// return fmt.Errorf("Error getting backend: %v", err) -// } +// backend, err := orchestrator.GetBackend(ctx, "backend1") // -// -- Doc autogenerated on 2022-05-26 22:23:58. Function hash: 97ea7edf0258bdf4ee62e165318ef219 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 97ea7edf0258bdf4ee62e165318ef219 -- func (o *TridentOrchestrator) GetBackend( ctx context.Context, backendName string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1708,17 +1822,19 @@ func (o *TridentOrchestrator) GetBackend( return backendExternal, nil } -// GetBackendByBackendUUID returns a backend by backendUUID +// GetBackendByBackendUUID returns a backend by UUID +// It returns an error if the backend UUID is invalid. // Parameters: // ctx - context for logging -// backendUUID - the backend UUID +// backendUUID - the UUID of the backend // Returns: -// *storage.BackendExternal - the backend -// error - any error encountered +// storage.BackendExternal - the backend +// error - error if there is any // Example: -// backend, err := orchestrator.GetBackendByBackendUUID(ctx, "1") +// backend, err := orchestrator.GetBackendByBackendUUID(ctx, "backend1") +// // -// -- Doc autogenerated on 2022-05-26 22:24:28. Function hash: 81d8fa64dc1b3803acd28fbacf4b0287 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 81d8fa64dc1b3803acd28fbacf4b0287 -- func (o *TridentOrchestrator) GetBackendByBackendUUID( ctx context.Context, backendUUID string, ) (backendExternal *storage.BackendExternal, err error) { @@ -1747,16 +1863,18 @@ func (o *TridentOrchestrator) GetBackendByBackendUUID( return backendExternal, nil } -// ListBackends lists the backends in the system -// It returns a list of backends and an error +// ListBackends lists all the backends that are currently configured. +// It returns an error if there is any. // Parameters: -// ctx - context (for cancellation) +// ctx - context for logging // Returns: -// list of backends and an error +// []*storage.BackendExternal - the list of backends +// error - the error if there is any // Example: -// backends, err := ListBackends(ctx) +// backendExternals, err := o.ListBackends(ctx) +// // -// -- Doc autogenerated on 2022-05-26 22:24:48. Function hash: 2d98525f51bd5d6b7df26ff8693141e9 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 2d98525f51bd5d6b7df26ff8693141e9 -- func (o *TridentOrchestrator) ListBackends( ctx context.Context, ) (backendExternals []*storage.BackendExternal, err error) { @@ -1780,20 +1898,18 @@ func (o *TridentOrchestrator) ListBackends( return backends, nil } -// DeleteBackend deletes a backend from the orchestrator -// It returns an error if the backend does not exist +// DeleteBackend deletes a backend. +// It returns an error if the backend doesn't exist or if the backend is in use. // Parameters: -// ctx - context for logging -// backendName - the name of the backend to delete +// ctx - context for logging +// backendName - the name of the backend to delete // Returns: -// error - any error encountered +// error - the error if the backend could not be deleted, nil if the backend was deleted // Example: -// err := orchestrator.DeleteBackend(ctx, backendName) -// if err != nil { -// log.Errorf("Could not delete backend %s: %v", backendName, err) -// } +// err := o.DeleteBackend(ctx, "backend1") +// // -// -- Doc autogenerated on 2022-05-26 22:25:08. Function hash: dac0943d6e46a81a0f9787f5f6ef64f3 -- +// -- Doc autogenerated on 2022-06-21. Function hash: dac0943d6e46a81a0f9787f5f6ef64f3 -- func (o *TridentOrchestrator) DeleteBackend(ctx context.Context, backendName string) (err error) { if o.bootstrapError != nil { Logc(ctx).WithFields(log.Fields{ @@ -1815,18 +1931,19 @@ func (o *TridentOrchestrator) DeleteBackend(ctx context.Context, backendName str return o.deleteBackendByBackendUUID(ctx, backendName, backendUUID) } -// DeleteBackendByBackendUUID deletes a backend by backendUUID -// It returns an error if the backend is not found +// DeleteBackendByBackendUUID deletes a backend by UUID. +// It returns an error if the backend doesn't exist. // Parameters: // ctx - context for logging -// backendName - name of the backend -// backendUUID - UUID of the backend +// backendName - the name of the backend +// backendUUID - the UUID of the backend // Returns: -// error - any error encountered +// error - the error if the delete failed, nil if the delete succeeded // Example: -// err := orchestrator.DeleteBackendByBackendUUID(ctx, "backend1", "b9e9d4c8-f0b4-4d13-a4a4-8bcfc1f7bd1e") +// err := o.DeleteBackendByBackendUUID(ctx, "backend1", "12345") +// // -// -- Doc autogenerated on 2022-05-26 22:25:31. Function hash: ade56985c915048a2ff8350f698c0690 -- +// -- Doc autogenerated on 2022-06-21. Function hash: ade56985c915048a2ff8350f698c0690 -- func (o *TridentOrchestrator) DeleteBackendByBackendUUID( ctx context.Context, backendName, backendUUID string, ) (err error) { @@ -1846,18 +1963,19 @@ func (o *TridentOrchestrator) DeleteBackendByBackendUUID( return o.deleteBackendByBackendUUID(ctx, backendName, backendUUID) } -// deleteBackendByBackendUUID deletes a backend by backendUUID -// It returns an error if the backend is not found. +// deleteBackendByBackendUUID deletes a backend by name +// It returns an error if the backend doesn't exist or if the backend has volumes. // Parameters: // ctx - context for logging -// backendName - name of the backend -// backendUUID - UUID of the backend +// backendName - the name of the backend +// backendUUID - the UUID of the backend // Returns: -// error - error if the backend is not found +// error - the error if the backend could not be deleted, nil if the backend was deleted // Example: -// err := deleteBackendByBackendUUID(ctx, backendName, backendUUID) +// err := o.deleteBackendByBackendUUID(ctx, "backend1", "12345") // -// -- Doc autogenerated on 2022-05-26 22:26:14. Function hash: 2568753d63d7e3305bdc4b1ea5d422de -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: 2568753d63d7e3305bdc4b1ea5d422de -- func (o *TridentOrchestrator) deleteBackendByBackendUUID(ctx context.Context, backendName, backendUUID string) error { Logc(ctx).WithFields(log.Fields{ "backendName": backendName, @@ -1912,6 +2030,17 @@ func (o *TridentOrchestrator) deleteBackendByBackendUUID(ctx context.Context, ba } // RemoveBackendConfigRef sets backend configRef to empty and updates it. +// It returns an error if the backend update is invalid. +// Parameters: +// ctx - context for logging +// backendUUID - the UUID of the backend +// configRef - the configRef of the backend +// Returns: +// error - the error if the update is invalid, nil if the update is valid +// Example: +// err := o.RemoveBackendConfigRef(ctx, backendUUID, configRef) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 331e58f467a6cdb46f9fe1e3df756370 -- func (o *TridentOrchestrator) RemoveBackendConfigRef(ctx context.Context, backendUUID, configRef string) (err error) { defer recordTiming("backend_update", &err)() @@ -1936,18 +2065,19 @@ func (o *TridentOrchestrator) RemoveBackendConfigRef(ctx context.Context, backen return o.storeClient.UpdateBackend(ctx, b) } -// AddVolume adds a volume to the orchestrator -// It returns the volume object and error +// AddVolume creates a new volume. +// It returns an error if the volume already exists or if the backend does not exist. // Parameters: -// volumeConfig: VolumeConfig object -// ctx: context +// ctx - context for logging +// volumeConfig - the volume config // Returns: -// externalVol: VolumeExternal object -// err: error object +// storage.VolumeExternal - the new volume +// error - error if there is any // Example: -// vol, err := o.AddVolume(ctx, volumeConfig) +// externalVol, err := orchestrator.AddVolume(ctx, volumeConfig) // -// -- Doc autogenerated on 2022-05-26 22:27:13. Function hash: 6b3abc4db9d4558bf39248381f6e73e6 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: 6b3abc4db9d4558bf39248381f6e73e6 -- func (o *TridentOrchestrator) AddVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -1982,6 +2112,18 @@ func (o *TridentOrchestrator) AddVolume( // addVolumeInitial continues the volume creation operation. // This method should only be called from AddVolume, as it does not take locks or otherwise do much validation // of the volume config. +// It returns an error if the volume creation is invalid. +// Parameters: +// ctx - context for logging +// volumeConfig - the volume config +// Returns: +// externalVol - the external volume +// error - the error if the creation is invalid, nil if the creation is valid +// Example: +// externalVol, err := o.addVolumeInitial(ctx, volumeConfig) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: b5ae8d6da66bca2cf182c5d0013b1c02 -- func (o *TridentOrchestrator) addVolumeInitial( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2109,6 +2251,17 @@ func (o *TridentOrchestrator) addVolumeInitial( // addVolumeRetry continues a volume creation operation that previously failed with a VolumeCreatingError. // This method should only be called from AddVolume, as it does not take locks or otherwise do much validation // of the volume config. +// It returns an error if the volume creation operation fails. +// Parameters: +// ctx - context for logging +// txn - the volume transaction +// Returns: +// externalVol - the external volume +// error - the error if the volume creation operation fails, nil if it succeeds +// Example: +// externalVol, err := o.addVolumeRetry(ctx, txn) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 1ef65ba5121b49ef47f655224be95398 -- func (o *TridentOrchestrator) addVolumeRetry( ctx context.Context, txn *storage.VolumeTransaction, ) (externalVol *storage.VolumeExternal, err error) { @@ -2173,6 +2326,20 @@ func (o *TridentOrchestrator) addVolumeRetry( // addVolumeFinish is called after successful completion of a volume create/clone operation // to save the volume in the persistent store as well as Trident's in-memory cache. +// It returns an error if there is any. +// Parameters: +// ctx - context for logging +// txn - the volume transaction +// vol - the volume +// backend - the backend +// pool - the pool +// Returns: +// storage.VolumeExternal - the external volume +// error - the error if there is any +// Example: +// externalVol, err := o.addVolumeFinish(ctx, txn, vol, backend, pool) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 550c1e0b637b8b5a2f43afa834fd1758 -- func (o *TridentOrchestrator) addVolumeFinish( ctx context.Context, txn *storage.VolumeTransaction, vol *storage.Volume, backend storage.Backend, pool storage.Pool, @@ -2201,18 +2368,19 @@ func (o *TridentOrchestrator) addVolumeFinish( return externalVol, nil } -// CloneVolume clones a volume -// It returns the volume and an error +// CloneVolume creates a new volume by cloning an existing volume. +// It returns an error if the new volume cannot be created. // Parameters: -// ctx - context -// volumeConfig - volume config +// ctx - context for logging +// volumeConfig - the configuration for the new volume // Returns: -// *storage.VolumeExternal - volume -// error - error +// storage.VolumeExternal - the new volume +// error - the error if any // Example: -// volume, err := orchestrator.CloneVolume(ctx, volumeConfig) +// externalVol, err := o.CloneVolume(ctx, volumeConfig) // -// -- Doc autogenerated on 2022-05-26 22:27:31. Function hash: 3b05245cf8d531e1b7e704f1d7673887 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: 3b05245cf8d531e1b7e704f1d7673887 -- func (o *TridentOrchestrator) CloneVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2245,17 +2413,18 @@ func (o *TridentOrchestrator) CloneVolume( } // cloneVolumeInitial creates a new volume by cloning an existing volume. -// It returns the new volume and any error encountered. +// It returns an error if the new volume cannot be created. // Parameters: -// ctx - context -// volumeConfig - volume config of the new volume +// ctx - context for logging +// volumeConfig - the volume config // Returns: -// externalVol - the new volume -// err - any error encountered +// storage.VolumeExternal - the new volume +// error - error if there is any // Example: -// externalVol, err := o.cloneVolumeInitial(ctx, volumeConfig) +// externalVol, err := orchestrator.cloneVolumeInitial(ctx, volumeConfig) +// // -// -- Doc autogenerated on 2022-05-26 22:27:58. Function hash: 3f83112418a823bdafb4b150c3214f8e -- +// -- Doc autogenerated on 2022-06-21. Function hash: 3f83112418a823bdafb4b150c3214f8e -- func (o *TridentOrchestrator) cloneVolumeInitial( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2397,18 +2566,18 @@ func (o *TridentOrchestrator) cloneVolumeInitial( return o.addVolumeFinish(ctx, txn, vol, backend, pool) } -// cloneVolumeRetry attempts to create a clone of the specified volume. -// It returns the external volume representation if successful, or an error otherwise. +// cloneVolumeRetry validates that the backend update is valid. +// It returns an error if the backend update is invalid. // Parameters: -// ctx - context -// txn - transaction -// Return: -// externalVol - external volume representation -// err - error +// ctx - context for logging +// txn - the volume transaction +// Returns: +// externalVol - the external volume +// error - the error if the update is invalid, nil if the update is valid // Example: -// externalVol, err := o.cloneVolumeRetry(ctx, txn) +// err := o.cloneVolumeRetry(ctx, txn) // -// -- Doc autogenerated on 2022-05-26 22:28:18. Function hash: d3195084da6ca49594299f21956d774c -- +// -- Doc autogenerated on 2022-06-21. Function hash: d3195084da6ca49594299f21956d774c -- func (o *TridentOrchestrator) cloneVolumeRetry( ctx context.Context, txn *storage.VolumeTransaction, ) (externalVol *storage.VolumeExternal, err error) { @@ -2487,6 +2656,18 @@ func (o *TridentOrchestrator) cloneVolumeRetry( // GetVolumeExternal is used by volume import so it doesn't check core's o.volumes to see if the // volume exists or not. Instead it asks the driver if the volume exists before requesting // the volume size. Returns the VolumeExternal representation of the volume. +// It returns an error if the volume doesn't exist. +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume +// backendName - the name of the backend +// Returns: +// volExternal - the VolumeExternal representation of the volume +// error - the error if the volume doesn't exist, nil if the volume exists +// Example: +// volExternal, err := o.GetVolumeExternal(ctx, "volume1", "backend1") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 6d7df3139b77d4e7f3b0c5a1f0401aed -- func (o *TridentOrchestrator) GetVolumeExternal( ctx context.Context, volumeName, backendName string, ) (volExternal *storage.VolumeExternal, err error) { @@ -2522,6 +2703,20 @@ func (o *TridentOrchestrator) GetVolumeExternal( } // GetVolumeByInternalName returns a volume by the given internal name +// It returns the volume name and error if any +// Parameters: +// volumeInternal - the internal name of the volume +// context - context for logging +// Returns: +// string - the volume name +// error - error if any +// Example: +// volume, err := orchestrator.GetVolumeByInternalName("volume1", nil) +// +// GetVolumeExternal queries a backend driver for a given volume identified by the +// internal name. If the volume doesn't exist, an error is returned. +// +// -- Doc autogenerated on 2022-06-21. Function hash: e81135d85cf26e9b05d143d437569df4 -- func (o *TridentOrchestrator) GetVolumeByInternalName( volumeInternal string, _ context.Context, ) (volume string, err error) { @@ -2538,17 +2733,18 @@ func (o *TridentOrchestrator) GetVolumeByInternalName( return "", utils.NotFoundError(fmt.Sprintf("volume %s not found", volumeInternal)) } -// validateImportVolume validates the volume import request -// It returns error if the volume is already imported or if the volume does not exist on the backend +// validateImportVolume validates that the volume import is valid. +// It returns an error if the volume import is invalid. // Parameters: -// ctx - context -// volumeConfig - volume config -// Return: -// error - error if any +// ctx - context for logging +// volumeConfig - the volume config +// Returns: +// error - the error if the import is invalid, nil if the import is valid // Example: -// err := o.validateImportVolume(ctx, volumeConfig) +// err := o.validateImportVolume(ctx, volumeConfig) // -// -- Doc autogenerated on 2022-05-26 22:28:35. Function hash: 0b239a8ef621ed2e08adbc4c80a11281 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: 0b239a8ef621ed2e08adbc4c80a11281 -- func (o *TridentOrchestrator) validateImportVolume(ctx context.Context, volumeConfig *storage.VolumeConfig) error { backend, err := o.getBackendByBackendUUID(volumeConfig.ImportBackendUUID) if err != nil { @@ -2610,21 +2806,21 @@ func (o *TridentOrchestrator) validateImportVolume(ctx context.Context, volumeCo return nil } -// LegacyImportVolume imports a volume from an external storage system. -// It returns a VolumeExternal object that can be used to create a PV and PVC. +// LegacyImportVolume imports a volume from an external storage backend. +// It returns an error if the volume cannot be imported. // Parameters: -// ctx - context for logging -// volumeConfig - volume configuration -// backendName - name of the backend to import the volume to -// notManaged - true if the volume is not managed by Trident -// createPVandPVC - callback function to create a PV and PVC for the volume +// ctx - context for logging +// volumeConfig - the volume config +// backendName - the name of the backend +// notManaged - if true, the volume will not be persisted in the store +// createPVandPVC - the callback function to create PV and PVC for the volume // Returns: -// VolumeExternal object -// error - if any +// storage.VolumeExternal - the volume external +// error - error if there is any // Example: -// importVol, err := o.LegacyImportVolume(ctx, volumeConfig, backendName, notManaged, createPVandPVC) +// volExternal, err := o.LegacyImportVolume(ctx, volumeConfig, backendName, notManaged, createPVandPVC) // -// -- Doc autogenerated on 2022-05-26 22:29:04. Function hash: f8c072d23374263c1a818a13bc96fac1 -- +// -- Doc autogenerated on 2022-06-21. Function hash: f8c072d23374263c1a818a13bc96fac1 -- func (o *TridentOrchestrator) LegacyImportVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, backendName string, notManaged bool, createPVandPVC VolumeCallback, @@ -2715,18 +2911,19 @@ func (o *TridentOrchestrator) LegacyImportVolume( return volExternal, nil } -// ImportVolume imports a volume from a backend -// It returns the volume's external representation +// ImportVolume imports a volume into Trident. The volume must already exist on the specified backend. +// It returns an error if the volume cannot be imported. // Parameters: -// ctx - context -// volumeConfig - the volume to import +// ctx - context for logging +// volumeConfig - the volume config // Returns: -// *storage.VolumeExternal - the volume's external representation -// error - any error encountered +// storage.VolumeExternal - the external volume +// error - the error if there is any // Example: -// volumeExternal, err := core.ImportVolume(ctx, volumeConfig) +// volExternal, err := orchestrator.ImportVolume(ctx, volumeConfig) +// // -// -- Doc autogenerated on 2022-05-26 22:29:32. Function hash: caf9bc105080edc2f7b86c15a43a3f1e -- +// -- Doc autogenerated on 2022-06-21. Function hash: caf9bc105080edc2f7b86c15a43a3f1e -- func (o *TridentOrchestrator) ImportVolume( ctx context.Context, volumeConfig *storage.VolumeConfig, ) (externalVol *storage.VolumeExternal, err error) { @@ -2815,6 +3012,16 @@ func (o *TridentOrchestrator) ImportVolume( // AddVolumeTransaction is called from the volume create, clone, and resize // methods to save a record of the operation in case it fails and must be // cleaned up later. +// It returns an error if the transaction could not be added. +// Parameters: +// ctx - context for logging +// volTxn - the volume transaction +// Returns: +// error - the error if the transaction could not be added, nil if the transaction was added +// Example: +// err := o.AddVolumeTransaction(ctx, volTxn) +// +// -- Doc autogenerated on 2022-06-21. Function hash: e26d3c9af53a81028676844f37108220 -- func (o *TridentOrchestrator) AddVolumeTransaction(ctx context.Context, volTxn *storage.VolumeTransaction) error { // Check if a transaction already exists for this volume. This condition // can occur if we failed to clean up the transaction object during the @@ -2857,23 +3064,18 @@ func (o *TridentOrchestrator) AddVolumeTransaction(ctx context.Context, volTxn * return o.storeClient.AddVolumeTransaction(ctx, volTxn) } -// GetVolumeCreatingTransaction returns the volume transaction if it exists, or nil if it does not. +// GetVolumeCreatingTransaction returns a volume transaction that is currently creating a volume. +// It returns an error if the volume transaction cannot be retrieved. // Parameters: -// ctx - context -// config - volume config +// ctx - context for logging +// config - the volume config // Returns: -// volume transaction -// error -// Example: -// txn, err := o.GetVolumeCreatingTransaction(ctx, config) -// if err != nil { -// return err -// } -// if txn != nil { -// return fmt.Errorf("volume %v is already being created", config.InternalName) -// } -// -// -- Doc autogenerated on 2022-05-26 22:29:52. Function hash: 4025deb561dc0aba9e0fa596740664b8 -- +// storage.VolumeTransaction - the volume transaction +// error - error if there is any +// Example: +// txn, err := orchestrator.GetVolumeCreatingTransaction(ctx, config) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 4025deb561dc0aba9e0fa596740664b8 -- func (o *TridentOrchestrator) GetVolumeCreatingTransaction( ctx context.Context, config *storage.VolumeConfig, ) (*storage.VolumeTransaction, error) { @@ -2893,17 +3095,18 @@ func (o *TridentOrchestrator) GetVolumeCreatingTransaction( } } -// GetVolumeTransaction returns a volume transaction from the backend +// GetVolumeTransaction returns a volume transaction by name +// It returns an error if the volume transaction is not found // Parameters: -// ctx - context for logging -// volTxn - the volume transaction to get +// ctx - context for logging +// volTxn - the volume transaction // Returns: -// *storage.VolumeTransaction - the volume transaction -// error - any error encountered +// storage.VolumeTransaction - the volume transaction +// error - error if there is any // Example: -// volTxn, err := tridentOrchestrator.GetVolumeTransaction(ctx, volTxn) +// volTxn, err := orchestrator.GetVolumeTransaction(ctx, "volTxn1") // -// -- Doc autogenerated on 2022-05-26 22:30:16. Function hash: d8a638429c4b2c3043bb0281d5c34490 -- +// -- Doc autogenerated on 2022-06-21. Function hash: d8a638429c4b2c3043bb0281d5c34490 -- func (o *TridentOrchestrator) GetVolumeTransaction( ctx context.Context, volTxn *storage.VolumeTransaction, ) (*storage.VolumeTransaction, error) { @@ -2912,12 +3115,37 @@ func (o *TridentOrchestrator) GetVolumeTransaction( // DeleteVolumeTransaction deletes a volume transaction created by // addVolumeTransaction. +// It returns an error if the volume transaction could not be deleted. +// Parameters: +// ctx - context for logging +// volTxn - the volume transaction to delete +// Returns: +// error - the error if the volume transaction could not be deleted, nil if the volume transaction was deleted +// Example: +// err := o.DeleteVolumeTransaction(ctx, volTxn) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 795e32bfe4a5dd11a92ae36c8c1c3e07 -- func (o *TridentOrchestrator) DeleteVolumeTransaction(ctx context.Context, volTxn *storage.VolumeTransaction) error { return o.storeClient.DeleteVolumeTransaction(ctx, volTxn) } // addVolumeCleanup is used as a deferred method from the volume create/clone methods // to clean up in case anything goes wrong during the operation. +// It returns an error if the cleanup is unsuccessful. +// Parameters: +// ctx - context for logging +// err - the error that occurred during the operation +// backend - the backend where the volume was created +// vol - the volume that was created +// volTxn - the volume transaction associated with the operation +// volumeConfig - the volume config associated with the operation +// Returns: +// error - the error if the cleanup is unsuccessful, nil if the cleanup is successful +// Example: +// err := o.addVolumeCleanup(ctx, err, backend, vol, volTxn, volumeConfig) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 10707fd80e961ea473b9d9d8b57018aa -- func (o *TridentOrchestrator) addVolumeCleanup( ctx context.Context, err error, backend storage.Backend, vol *storage.Volume, volTxn *storage.VolumeTransaction, volumeConfig *storage.VolumeConfig, @@ -2977,6 +3205,20 @@ func (o *TridentOrchestrator) addVolumeCleanup( // addVolumeRetryCleanup is used as a deferred method from the volume create/clone methods // to handles the case where a volume creation took too long, is still ongoing, and must be // preserved in a transaction. +// It returns an error if the volume creation is still ongoing. +// Parameters: +// ctx - context for logging +// err - the error if the volume creation is still ongoing +// backend - the backend +// pool - the pool +// volTxn - the volume transaction +// volumeConfig - the volume config +// Returns: +// error - the error if the volume creation is still ongoing, nil if the volume creation is successful +// Example: +// err := o.addVolumeRetryCleanup(ctx, err, backend, pool, volTxn, volumeConfig) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 012cba4286b63bb807e231a47dcbae05 -- func (o *TridentOrchestrator) addVolumeRetryCleanup( ctx context.Context, err error, backend storage.Backend, pool storage.Pool, volTxn *storage.VolumeTransaction, volumeConfig *storage.VolumeConfig, @@ -3028,20 +3270,21 @@ func (o *TridentOrchestrator) addVolumeRetryCleanup( return err } -// importVolumeCleanup is called when an error occurs during the import process. -// It attempts to clean up any artifacts created during the import process. -// It returns an error if any of the cleanup steps fail. +// importVolumeCleanup is a helper function that cleans up after a failed volume import. +// +// It returns an error if it was unable to clean up all artifacts of the volume import. +// // Parameters: -// ctx - context for logging -// err - the error that occurred during the import process. -// volumeConfig - the volume config of the volume being imported. -// volTxn - the volume transaction of the volume being imported. +// ctx - context for logging +// err - the error that occurred during the import, if any +// volumeConfig - the volume config object for the volume being imported +// volTxn - the volume transaction object for the volume being imported // Returns: -// error - an error if any of the cleanup steps fail. +// error - the error if it was unable to clean up all artifacts of the volume import, nil if it was successful // Example: -// err := o.importVolumeCleanup(ctx, err, volumeConfig, volTxn) +// err := o.importVolumeCleanup(ctx, err, volumeConfig, volTxn) // -// -- Doc autogenerated on 2022-05-26 22:31:17. Function hash: f5e220ffc92fbb12521834e8dbc438aa -- +// -- Doc autogenerated on 2022-06-21. Function hash: f5e220ffc92fbb12521834e8dbc438aa -- func (o *TridentOrchestrator) importVolumeCleanup( ctx context.Context, err error, volumeConfig *storage.VolumeConfig, volTxn *storage.VolumeTransaction, ) error { @@ -3096,18 +3339,19 @@ func (o *TridentOrchestrator) importVolumeCleanup( return err } -// GetVolume retrieves a volume by name -// It returns the volume and any error encountered +// GetVolume returns a volume by name +// It returns an error if the volume does not exist // Parameters: -// ctx - context for logging -// volume - name of the volume +// ctx - context for logging +// volume - the name of the volume // Returns: -// VolumeExternal - volume object -// error - any error encountered +// storage.VolumeExternal - the volume +// error - error if there is any // Example: -// vol, err := orchestrator.GetVolume(ctx, "volume1") +// vol, err := orchestrator.GetVolume(ctx, "volume1") +// // -// -- Doc autogenerated on 2022-05-26 22:31:37. Function hash: 7b809028c4c2d34e481ebd4d9ceadcdf -- +// -- Doc autogenerated on 2022-06-21. Function hash: 7b809028c4c2d34e481ebd4d9ceadcdf -- func (o *TridentOrchestrator) GetVolume( ctx context.Context, volume string, ) (volExternal *storage.VolumeExternal, err error) { @@ -3123,19 +3367,18 @@ func (o *TridentOrchestrator) GetVolume( return o.getVolume(ctx, volume) } -// getVolume returns the volume with the specified name +// getVolume returns a volume by name +// It returns an error if the volume is not found // Parameters: -// volume - name of the volume to retrieve +// ctx - context for logging +// volume - the name of the volume // Returns: -// the volume object -// error if the volume was not found +// storage.VolumeExternal - the volume +// error - error if there is any // Example: -// vol, err := o.getVolume("myvol") -// if err != nil { -// log.Errorf("unable to retrieve volume %v: %v", vol, err) -// } +// vol, err := orchestrator.getVolume(ctx, "volume1") // -// -- Doc autogenerated on 2022-05-26 22:31:55. Function hash: a3180f3812fb8b86173ca5c119bc52db -- +// -- Doc autogenerated on 2022-06-21. Function hash: a3180f3812fb8b86173ca5c119bc52db -- func (o *TridentOrchestrator) getVolume( _ context.Context, volume string, ) (volExternal *storage.VolumeExternal, err error) { @@ -3146,19 +3389,19 @@ func (o *TridentOrchestrator) getVolume( return vol.ConstructExternal(), nil } -// GetDriverTypeForVolume returns the driver type for a volume +// GetDriverTypeForVolume returns the driver type for the specified volume. +// It returns an error if the volume does not exist. // Parameters: -// vol - volume to get the driver type for +// ctx - context for logging +// vol - the volume // Returns: -// string - driver type -// error - any error that occurred +// string - the driver type +// error - the error if there is any // Example: -// driverType, err := orchestrator.GetDriverTypeForVolume(&storage.VolumeExternal{BackendUUID: "5f8a9b60-a4c4-4d83-8e35-7b8c6b2ecc1b"}) -// if err != nil { -// ... -// } +// driverType, err := o.GetDriverTypeForVolume(ctx, vol) +// // -// -- Doc autogenerated on 2022-05-26 22:32:11. Function hash: fa6bc896c59ce9a936c5679fd5c658b9 -- +// -- Doc autogenerated on 2022-06-21. Function hash: fa6bc896c59ce9a936c5679fd5c658b9 -- func (o *TridentOrchestrator) GetDriverTypeForVolume(_ context.Context, vol *storage.VolumeExternal) (string, error) { if o.bootstrapError != nil { return config.UnknownDriver, o.bootstrapError @@ -3174,6 +3417,16 @@ func (o *TridentOrchestrator) GetDriverTypeForVolume(_ context.Context, vol *sto // not construct a transaction, nor does it take locks; it assumes that the // caller will take care of both of these. It also assumes that the backend // exists in memory. +// It returns the driver type and error if there is any. +// Parameters: +// backendUUID - the UUID of the backend +// Returns: +// string - the driver type +// error - error if there is any +// Example: +// driverType, err := orchestrator.getDriverTypeForVolume("backend1") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 36984fba5929c8a289f6429d6e12a212 -- func (o *TridentOrchestrator) getDriverTypeForVolume(backendUUID string) (string, error) { if b, ok := o.backends[backendUUID]; ok { return b.Driver().Name(), nil @@ -3181,25 +3434,18 @@ func (o *TridentOrchestrator) getDriverTypeForVolume(backendUUID string) (string return config.UnknownDriver, nil } -// GetVolumeType returns the volume type for the given volume. +// GetVolumeType returns the volume type of the specified volume. +// It returns an error if the volume type could not be determined. // Parameters: -// vol *storage.VolumeExternal -// Volume to get the volume type for +// ctx - context for logging +// vol - the volume // Returns: -// volumeType config.VolumeType -// Volume type for the given volume -// err error -// Error, if any -// Example: -// vt, err := tridentOrchestrator.GetVolumeType(ctx, vol) -// if err != nil { -// // Handle error -// } -// if vt == config.OntapNFS { -// // Handle NFS volume -// } -// -// -- Doc autogenerated on 2022-05-26 22:32:28. Function hash: 38bae4a9a9ca7f54bb863b2c10a6fe6e -- +// volumeType - the volume type +// error - the error if there is any +// Example: +// volumeType, err := orchestrator.GetVolumeType(ctx, vol) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 38bae4a9a9ca7f54bb863b2c10a6fe6e -- func (o *TridentOrchestrator) GetVolumeType( _ context.Context, vol *storage.VolumeExternal, ) (volumeType config.VolumeType, err error) { @@ -3233,19 +3479,18 @@ func (o *TridentOrchestrator) GetVolumeType( return } -// ListVolumes returns a list of volumes +// ListVolumes returns a list of all volumes in the system. +// It returns an error if there is any. // Parameters: -// context - context for logging -// Return: -// volumes - list of volumes -// error - error, if any +// ctx - context for logging +// Returns: +// volumes - a list of all volumes in the system +// error - error if there is any // Example: -// volumes, err := o.ListVolumes(context) -// if err != nil { -// return err -// } +// volumes, err := orchestrator.ListVolumes(ctx) +// // -// -- Doc autogenerated on 2022-05-26 22:32:42. Function hash: 85d4a8042740926b2d85a28566cb3403 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 85d4a8042740926b2d85a28566cb3403 -- func (o *TridentOrchestrator) ListVolumes(context.Context) (volumes []*storage.VolumeExternal, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -3267,6 +3512,16 @@ func (o *TridentOrchestrator) ListVolumes(context.Context) (volumes []*storage.V } // volumeSnapshots returns any Snapshots for the specified volume +// It returns a slice of snapshots and an error if there is any +// Parameters: +// volumeName - the name of the volume +// Returns: +// []*storage.Snapshot - a slice of snapshots +// error - error if there is any +// Example: +// snapshots, err := orchestrator.volumeSnapshots("volume1") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 24b97a5ce641e2652b0a580c3bd0f00f -- func (o *TridentOrchestrator) volumeSnapshots(volumeName string) ([]*storage.Snapshot, error) { volume, volumeFound := o.volumes[volumeName] if !volumeFound { @@ -3286,6 +3541,16 @@ func (o *TridentOrchestrator) volumeSnapshots(volumeName string) ([]*storage.Sna // not construct a transaction, nor does it take locks; it assumes that the // caller will take care of both of these. It also assumes that the volume // exists in memory. +// It returns an error if the volume cannot be deleted. +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume to delete +// Returns: +// error - the error if the volume cannot be deleted, nil if the volume is deleted +// Example: +// err := o.deleteVolume(ctx, "volume1") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 47503a83b9223c8109913559c890d916 -- func (o *TridentOrchestrator) deleteVolume(ctx context.Context, volumeName string) error { volume := o.volumes[volumeName] volumeBackend := o.backends[volume.BackendUUID] @@ -3363,18 +3628,18 @@ func (o *TridentOrchestrator) deleteVolume(ctx context.Context, volumeName strin return nil } -// deleteVolumeFromPersistentStoreIgnoreError deletes a volume from the persistent store, ignoring -// errors if the volume does not exist. -// It returns an error if the volume exists but could not be deleted. +// deleteVolumeFromPersistentStoreIgnoreError deletes a volume from the persistent store. +// It ignores errors if the volume is not found in the store. +// It returns an error if the volume is found in the store but cannot be deleted. // Parameters: -// ctx - context for logging -// volume - volume to delete -// Return: -// error - error if the volume could not be deleted, nil otherwise +// ctx - context for logging +// volume - the volume to delete +// Returns: +// error - the error if the delete failed, nil if the delete succeeded // Example: -// err := deleteVolumeFromPersistentStoreIgnoreError(ctx, volume) +// err := o.deleteVolumeFromPersistentStoreIgnoreError(ctx, volume) // -// -- Doc autogenerated on 2022-05-26 22:33:10. Function hash: c2bcad7a430c67f70288fd3b95d63886 -- +// -- Doc autogenerated on 2022-06-21. Function hash: c2bcad7a430c67f70288fd3b95d63886 -- func (o *TridentOrchestrator) deleteVolumeFromPersistentStoreIgnoreError( ctx context.Context, volume *storage.Volume, ) error { @@ -3394,6 +3659,17 @@ func (o *TridentOrchestrator) deleteVolumeFromPersistentStoreIgnoreError( // DeleteVolume does the necessary set up to delete a volume during the course // of normal operation, verifying that the volume is present in Trident and // creating a transaction to ensure that the delete eventually completes. +// It returns an error if the volume is not present in Trident. +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume to delete +// Returns: +// error - the error if the volume is not present in Trident, nil if the volume is present in Trident +// Example: +// err := o.DeleteVolume(ctx, "volume1") +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: c39825c5fd380766f73ef5c7d8653ca6 -- func (o *TridentOrchestrator) DeleteVolume(ctx context.Context, volumeName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -3448,18 +3724,18 @@ func (o *TridentOrchestrator) DeleteVolume(ctx context.Context, volumeName strin return o.deleteVolume(ctx, volumeName) } -// ListVolumesByPlugin lists all volumes managed by the specified plugin -// It returns a list of volumes and an error +// ListVolumesByPlugin returns a list of volumes by plugin name +// It returns an error if the plugin name is invalid. // Parameters: -// pluginName - name of the plugin -// context - context +// ctx - context for logging +// pluginName - the name of the plugin // Returns: -// volumes - list of volumes -// error - error +// volumes - a list of volumes +// error - error if there is any // Example: -// volumes, err := o.ListVolumesByPlugin(pluginName, context) +// volumes, err := orchestrator.ListVolumesByPlugin(ctx, "plugin1") // -// -- Doc autogenerated on 2022-05-26 22:33:32. Function hash: 60b8076f3180c5e202ffbeeef30d97b0 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 60b8076f3180c5e202ffbeeef30d97b0 -- func (o *TridentOrchestrator) ListVolumesByPlugin( _ context.Context, pluginName string, ) (volumes []*storage.VolumeExternal, err error) { @@ -3484,18 +3760,19 @@ func (o *TridentOrchestrator) ListVolumesByPlugin( return volumes, nil } -// PublishVolume publishes the volume to the nodes. -// It returns an error if the volume is not found or is being deleted. +// PublishVolume publishes a volume to a node. +// It returns an error if the volume cannot be published. // Parameters: -// ctx - context for logging -// volumeName - name of the volume to publish -// publishInfo - information about the publish operation -// Return: -// error - error if any +// ctx - context for logging +// volumeName - the name of the volume +// publishInfo - the publish info +// Returns: +// error - the error if there is any // Example: -// err := o.PublishVolume(ctx, volumeName, publishInfo) +// err := o.PublishVolume(ctx, "volume1", publishInfo) +// // -// -- Doc autogenerated on 2022-05-26 22:33:55. Function hash: b7313803948e3a02c08b72fd07dd08d0 -- +// -- Doc autogenerated on 2022-06-21. Function hash: b7313803948e3a02c08b72fd07dd08d0 -- func (o *TridentOrchestrator) PublishVolume( ctx context.Context, volumeName string, publishInfo *utils.VolumePublishInfo, ) (err error) { @@ -3547,18 +3824,19 @@ func (o *TridentOrchestrator) PublishVolume( return nil } -// UnpublishVolume unpublishes a volume from a node -// It returns an error if the volume is not found or if the node is not found. +// UnpublishVolume unpublishes a volume from a node. +// It returns an error if the volume is not found or if the volume is not published to the node. // Parameters: -// ctx - context -// volumeName - name of volume to unpublish -// nodeName - name of node from which to unpublish the volume +// ctx - context for logging +// volumeName - the name of the volume +// nodeName - the name of the node // Returns: -// error - error if one occurred +// error - the error if the unpublish failed, nil if the unpublish succeeded // Example: -// err := o.UnpublishVolume(ctx, "vol1", "node1") +// err := o.UnpublishVolume(ctx, "volume1", "node1") +// // -// -- Doc autogenerated on 2022-05-26 22:34:18. Function hash: 8051f44dc4b6fa47e354a66dd188ad29 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 8051f44dc4b6fa47e354a66dd188ad29 -- func (o *TridentOrchestrator) UnpublishVolume(ctx context.Context, volumeName, nodeName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -3630,6 +3908,18 @@ func (o *TridentOrchestrator) UnpublishVolume(ctx context.Context, volumeName, n // and it should be able to accomplish its task using only the data passed in; it should not need to // use the storage controller API. It may be assumed that this method always runs on the host to // which the volume will be attached. +// It returns an error if the volume is not found or if the volume is already mounted. +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume +// mountpoint - the mount point +// publishInfo - the volume publish info +// Returns: +// error - the error if the volume is not found or if the volume is already mounted +// Example: +// err := o.AttachVolume(ctx, "volume1", "/mnt/volume1", &utils.VolumePublishInfo{}) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 08cc29fac1ea53ca467a8405912d1e51 -- func (o *TridentOrchestrator) AttachVolume( ctx context.Context, volumeName, mountpoint string, publishInfo *utils.VolumePublishInfo, ) (err error) { @@ -3718,6 +4008,17 @@ func (o *TridentOrchestrator) AttachVolume( // use the storage controller API. It may be assumed that this method always runs on the host to // which the volume will be attached. It ensures the volume is already mounted, and it attempts to // delete the mount point. +// It returns an error if the volume is not found, the volume is deleting, or the unmount fails. +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume +// mountpoint - the mount point of the volume +// Returns: +// error - the error if the unmount fails, nil if the unmount succeeds +// Example: +// err := o.DetachVolume(ctx, "volume1", "/mnt/volume1") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 3ab9993f2717bc59f0937d19e862392c -- func (o *TridentOrchestrator) DetachVolume(ctx context.Context, volumeName, mountpoint string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -3756,6 +4057,17 @@ func (o *TridentOrchestrator) DetachVolume(ctx context.Context, volumeName, moun } // SetVolumeState sets the state of a volume to a given value +// It returns an error if the volume state is invalid. +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume +// state - the state of the volume +// Returns: +// error - the error if the volume state is invalid, nil if the volume state is valid +// Example: +// err := o.SetVolumeState(ctx, "volume1", storage.VolumeStateOnline) +// +// -- Doc autogenerated on 2022-06-21. Function hash: caf19abab665ec64cd4d73b4922701d6 -- func (o *TridentOrchestrator) SetVolumeState( ctx context.Context, volumeName string, state storage.VolumeState, ) (err error) { @@ -3788,6 +4100,18 @@ func (o *TridentOrchestrator) SetVolumeState( } // CreateSnapshot creates a snapshot of the given volume +// It returns an error if the snapshot cannot be created. +// Parameters: +// ctx - context for logging +// snapshotConfig - the snapshot config +// Returns: +// storage.SnapshotExternal - the snapshot external +// error - the error if the snapshot cannot be created, nil if the snapshot is created +// Example: +// snapshotExternal, err := o.CreateSnapshot(ctx, snapshotConfig) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 9dd9e1ca67aaa0c73abe28dd52f15f10 -- func (o *TridentOrchestrator) CreateSnapshot( ctx context.Context, snapshotConfig *storage.SnapshotConfig, ) (externalSnapshot *storage.SnapshotExternal, err error) { @@ -3875,6 +4199,20 @@ func (o *TridentOrchestrator) CreateSnapshot( // addSnapshotCleanup is used as a deferred method from the snapshot create method // to clean up in case anything goes wrong during the operation. +// It returns an error if the cleanup fails. +// Parameters: +// ctx - context for logging +// err - the error that occurred during the operation +// backend - the backend +// snapshot - the snapshot +// volTxn - the volume transaction +// snapConfig - the snapshot config +// Returns: +// error - the error if the cleanup fails, nil if it succeeds +// Example: +// err := o.addSnapshotCleanup(ctx, err, backend, snapshot, volTxn, snapConfig) +// +// -- Doc autogenerated on 2022-06-21. Function hash: e813878e10d5a25a278213aa427ec219 -- func (o *TridentOrchestrator) addSnapshotCleanup( ctx context.Context, err error, backend storage.Backend, snapshot *storage.Snapshot, volTxn *storage.VolumeTransaction, snapConfig *storage.SnapshotConfig, @@ -3923,19 +4261,19 @@ func (o *TridentOrchestrator) addSnapshotCleanup( return err } -// GetSnapshot retrieves a snapshot from the backend. -// It returns the snapshot and a boolean indicating whether the snapshot exists. +// GetSnapshot returns a snapshot by name +// It returns an error if the snapshot is not found. // Parameters: -// ctx - context -// volumeName - name of the volume -// snapshotName - name of the snapshot +// ctx - context for logging +// volumeName - the name of the volume +// snapshotName - the name of the snapshot // Returns: -// snapshotExternal - snapshot -// err - error +// storage.SnapshotExternal - the snapshot +// error - error if there is any // Example: -// snapshotExternal, err := o.GetSnapshot(ctx, "myVolume", "mySnapshot") +// snapshot, err := orchestrator.GetSnapshot(ctx, "volume1", "snapshot1") // -// -- Doc autogenerated on 2022-05-26 22:34:41. Function hash: e989ccf35cebc85380ef65b188fb3054 -- +// -- Doc autogenerated on 2022-06-21. Function hash: e989ccf35cebc85380ef65b188fb3054 -- func (o *TridentOrchestrator) GetSnapshot( ctx context.Context, volumeName, snapshotName string, ) (snapshotExternal *storage.SnapshotExternal, err error) { @@ -3951,18 +4289,19 @@ func (o *TridentOrchestrator) GetSnapshot( return o.getSnapshot(ctx, volumeName, snapshotName) } -// getSnapshot returns the snapshot object for the given volume and snapshot name +// getSnapshot returns a snapshot by name +// It returns an error if the snapshot is not found // Parameters: // ctx - context for logging -// volumeName - name of the volume that contains the snapshot -// snapshotName - name of the snapshot to retrieve +// volumeName - the name of the volume +// snapshotName - the name of the snapshot // Returns: -// *storage.SnapshotExternal - snapshot object -// error - error if one occurred, nil otherwise +// storage.SnapshotExternal - the snapshot +// error - error if there is any // Example: -// snapshot, err := o.getSnapshot(ctx, "volume1", "snapshot1") +// snapshot, err := orchestrator.getSnapshot(ctx, "volume1", "snapshot1") // -// -- Doc autogenerated on 2022-05-26 22:35:00. Function hash: b64251745b9e500e060496470970c425 -- +// -- Doc autogenerated on 2022-06-21. Function hash: b64251745b9e500e060496470970c425 -- func (o *TridentOrchestrator) getSnapshot( ctx context.Context, volumeName, snapshotName string, ) (*storage.SnapshotExternal, error) { @@ -3981,21 +4320,18 @@ func (o *TridentOrchestrator) getSnapshot( } } -// updateSnapshot updates the snapshot's state in the orchestrator. -// It returns the updated snapshot, or an error. +// updateSnapshot updates the snapshot in the orchestrator's internal state and in the persistent store. +// It returns the updated snapshot and an error if there is any. // Parameters: -// ctx - context +// ctx - context for logging // snapshot - the snapshot to update -// Return: -// updated snapshot -// error +// Returns: +// storage.Snapshot - the updated snapshot +// error - error if there is any // Example: -// snapshot, err := o.updateSnapshot(ctx, snapshot) -// if err != nil { -// return nil, err -// } +// snapshot, err := orchestrator.updateSnapshot(ctx, snapshot) // -// -- Doc autogenerated on 2022-05-26 22:35:20. Function hash: 325d46cbf1273d5ada4aee5aad9d18fc -- +// -- Doc autogenerated on 2022-06-21. Function hash: 325d46cbf1273d5ada4aee5aad9d18fc -- func (o *TridentOrchestrator) updateSnapshot( ctx context.Context, snapshot *storage.Snapshot, ) (*storage.Snapshot, error) { @@ -4040,6 +4376,16 @@ func (o *TridentOrchestrator) updateSnapshot( // deleteSnapshot does the necessary work to delete a snapshot entirely. It does // not construct a transaction, nor does it take locks; it assumes that the caller will // take care of both of these. +// It returns an error if the snapshot could not be deleted. +// Parameters: +// ctx - context for logging +// snapshotConfig - the snapshot config +// Returns: +// error - the error if the snapshot could not be deleted, nil if the snapshot was deleted +// Example: +// err := o.deleteSnapshot(ctx, snapshotConfig) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 97f2ac0088209154223e59b734eefc83 -- func (o *TridentOrchestrator) deleteSnapshot(ctx context.Context, snapshotConfig *storage.SnapshotConfig) error { snapshotID := snapshotConfig.ID() snapshot, ok := o.snapshots[snapshotID] @@ -4093,17 +4439,18 @@ func (o *TridentOrchestrator) deleteSnapshot(ctx context.Context, snapshotConfig return nil } -// deleteSnapshotFromPersistentStoreIgnoreError deletes a snapshot from the persistent store, ignoring any errors. -// It returns an error if the snapshot was not found in the persistent store. +// deleteSnapshotFromPersistentStoreIgnoreError deletes a snapshot from the persistent store. +// It returns an error if the snapshot cannot be deleted. // Parameters: -// ctx - context +// ctx - context for logging // snapshot - the snapshot to delete // Returns: -// error - if the snapshot was not found in the persistent store +// error - the error if the delete failed, nil if the delete succeeded // Example: -// snapshot, err := o.deleteSnapshotFromPersistentStoreIgnoreError(ctx, snapshot) +// err := o.deleteSnapshotFromPersistentStoreIgnoreError(ctx, snapshot) // -// -- Doc autogenerated on 2022-05-26 22:38:00. Function hash: 3d9299843d219334e59de17ceccabde9 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: 3d9299843d219334e59de17ceccabde9 -- func (o *TridentOrchestrator) deleteSnapshotFromPersistentStoreIgnoreError( ctx context.Context, snapshot *storage.Snapshot, ) error { @@ -4122,6 +4469,17 @@ func (o *TridentOrchestrator) deleteSnapshotFromPersistentStoreIgnoreError( } // DeleteSnapshot deletes a snapshot of the given volume +// It returns an error if the snapshot is not found or if the snapshot cannot be deleted +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume +// snapshotName - the name of the snapshot +// Returns: +// error - the error if the snapshot cannot be deleted, nil if the snapshot is deleted +// Example: +// err := o.DeleteSnapshot(ctx, "volume1", "snapshot1") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 5c4f78ff92e95a7708153394e239bac0 -- func (o *TridentOrchestrator) DeleteSnapshot(ctx context.Context, volumeName, snapshotName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -4220,23 +4578,18 @@ func (o *TridentOrchestrator) DeleteSnapshot(ctx context.Context, volumeName, sn return o.deleteSnapshot(ctx, snapshot.Config) } -// ListSnapshots returns a list of all snapshots in the system. +// ListSnapshots lists all snapshots in the system. +// It returns a slice of snapshots and an error if there is any. // Parameters: -// ctx - context (for cancellation) +// ctx - context for logging // Returns: -// []*storage.SnapshotExternal - list of snapshots in the system -// error - any error encountered -// Example: -// snapshots, err := orchestrator.ListSnapshots(context) -// if err != nil { -// fmt.Printf("Error: %v\n", err) -// } else { -// for _, s := range snapshots { -// fmt.Printf("Snapshot: %v\n", s) -// } -// } -// -// -- Doc autogenerated on 2022-05-26 22:38:18. Function hash: d08dffcc2af9a6d1f09139abdd3c8e33 -- +// snapshots - a slice of snapshots +// error - error if there is any +// Example: +// snapshots, err := o.ListSnapshots(ctx) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: d08dffcc2af9a6d1f09139abdd3c8e33 -- func (o *TridentOrchestrator) ListSnapshots(context.Context) (snapshots []*storage.SnapshotExternal, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -4255,17 +4608,18 @@ func (o *TridentOrchestrator) ListSnapshots(context.Context) (snapshots []*stora return snapshots, nil } -// ListSnapshotsByName returns a list of snapshots matching the specified name +// ListSnapshotsByName returns a list of snapshots by name +// It returns an error if the snapshot name is invalid. // Parameters: -// context - context for logging -// snapshotName - name of the snapshot to be returned +// ctx - context for logging +// snapshotName - the name of the snapshot // Returns: -// list of snapshots matching the specified name -// error - non-nil if there was an error retrieving the snapshot list +// snapshots - the list of snapshots +// error - error if there is any // Example: -// snapshots, err := orchestrator.ListSnapshotsByName(context.Background(), "foo") +// snapshots, err := orchestrator.ListSnapshotsByName(ctx, "snapshot1") // -// -- Doc autogenerated on 2022-05-26 22:38:37. Function hash: 053cf2d47c2f1434c21a089a0fbeb072 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 053cf2d47c2f1434c21a089a0fbeb072 -- func (o *TridentOrchestrator) ListSnapshotsByName( _ context.Context, snapshotName string, ) (snapshots []*storage.SnapshotExternal, err error) { @@ -4288,18 +4642,18 @@ func (o *TridentOrchestrator) ListSnapshotsByName( return snapshots, nil } -// ListSnapshotsForVolume lists all snapshots for a given volume -// It returns a list of SnapshotExternal objects +// ListSnapshotsForVolume returns a list of snapshots for a volume. +// It returns an error if the volume does not exist. // Parameters: -// ctx - context -// volumeName - name of the volume +// ctx - context for logging +// volumeName - the name of the volume // Returns: -// snapshots - a list of SnapshotExternal objects -// err - error, if any +// snapshots - the list of snapshots +// error - error if there is any // Example: -// snapshotExternal, err := tridentOrchestrator.ListSnapshotsForVolume(context.Background(), "volume1") +// snapshots, err := orchestrator.ListSnapshotsForVolume(ctx, "volume1") // -// -- Doc autogenerated on 2022-05-26 22:39:03. Function hash: 623db3c5dd57eabbdc24f51e0e61b3a0 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 623db3c5dd57eabbdc24f51e0e61b3a0 -- func (o *TridentOrchestrator) ListSnapshotsForVolume( _ context.Context, volumeName string, ) (snapshots []*storage.SnapshotExternal, err error) { @@ -4326,17 +4680,18 @@ func (o *TridentOrchestrator) ListSnapshotsForVolume( return snapshots, nil } -// ReadSnapshotsForVolume returns a list of snapshots for the specified volume +// ReadSnapshotsForVolume returns a list of snapshots for a volume. +// It returns an error if the volume does not exist. // Parameters: -// ctx - context for the request -// volumeName - name of the volume to read snapshots for +// ctx - context for logging +// volumeName - the name of the volume // Returns: -// a list of snapshots for the specified volume -// an error if there was a problem reading the snapshots +// externalSnapshots - a list of snapshots for the volume +// error - the error if there is any // Example: -// snapshots, err := orchestrator.ReadSnapshotsForVolume(context.Background(), "vol1") +// snapshots, err := orchestrator.ReadSnapshotsForVolume(ctx, "volume1") // -// -- Doc autogenerated on 2022-05-26 22:39:21. Function hash: ccd4d329e169484695ad148c14dfbf12 -- +// -- Doc autogenerated on 2022-06-21. Function hash: ccd4d329e169484695ad148c14dfbf12 -- func (o *TridentOrchestrator) ReadSnapshotsForVolume( ctx context.Context, volumeName string, ) (externalSnapshots []*storage.SnapshotExternal, err error) { @@ -4364,16 +4719,16 @@ func (o *TridentOrchestrator) ReadSnapshotsForVolume( return externalSnapshots, nil } -// ReloadVolumes reloads the volumes from the backend -// It returns an error if the reload failed +// ReloadVolumes reloads the volumes from the backend storage systems. +// It returns an error if the reload fails. // Parameters: -// ctx - context +// ctx - context for logging // Returns: -// error - error +// error - error if there is any // Example: -// err := orchestrator.ReloadVolumes(context.Background()) +// err := o.ReloadVolumes(ctx) // -// -- Doc autogenerated on 2022-05-26 22:39:39. Function hash: 5f5aebb4e5d30c072efd3c62cb1564b0 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 5f5aebb4e5d30c072efd3c62cb1564b0 -- func (o *TridentOrchestrator) ReloadVolumes(ctx context.Context) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -4416,6 +4771,17 @@ func (o *TridentOrchestrator) ReloadVolumes(ctx context.Context) (err error) { } // ResizeVolume resizes a volume to the new size. +// It returns an error if the volume doesn't exist or is being deleted. +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume +// newSize - the new size of the volume +// Returns: +// error - the error if the resize fails, nil if the resize succeeds +// Example: +// err := o.ResizeVolume(ctx, "volume1", "10G") +// +// -- Doc autogenerated on 2022-06-21. Function hash: 25114e8d10b21d57c34efa66960065f9 -- func (o *TridentOrchestrator) ResizeVolume(ctx context.Context, volumeName, newSize string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -4472,6 +4838,17 @@ func (o *TridentOrchestrator) ResizeVolume(ctx context.Context, volumeName, newS // construct a transaction, nor does it take locks; it assumes that the // caller will take care of both of these. It also assumes that the volume // exists in memory. +// It returns an error if the resize is unsuccessful. +// Parameters: +// ctx - context for logging +// volume - the volume to resize +// newSize - the new size of the volume +// Returns: +// error - the error if the resize is unsuccessful, nil if the resize is successful +// Example: +// err := o.resizeVolume(ctx, volume, newSize) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 11b6c3fdc1fc037db20316277d5938ee -- func (o *TridentOrchestrator) resizeVolume(ctx context.Context, volume *storage.Volume, newSize string) error { volumeBackend, found := o.backends[volume.BackendUUID] if !found { @@ -4511,6 +4888,18 @@ func (o *TridentOrchestrator) resizeVolume(ctx context.Context, volume *storage. // resizeVolumeCleanup is used to clean up artifacts of volume resize in case // anything goes wrong during the operation. +// It returns an error if the cleanup fails. +// Parameters: +// ctx - context for logging +// err - the error if there is any +// vol - the volume +// volTxn - the volume transaction +// Returns: +// error - the error if the cleanup fails, nil if the cleanup succeeds +// Example: +// err := o.resizeVolumeCleanup(ctx, err, vol, volTxn) +// +// -- Doc autogenerated on 2022-06-21. Function hash: a1efa3082b3524d75fbefb8f828baae8 -- func (o *TridentOrchestrator) resizeVolumeCleanup( ctx context.Context, err error, vol *storage.Volume, volTxn *storage.VolumeTransaction, ) error { @@ -4552,6 +4941,19 @@ func (o *TridentOrchestrator) resizeVolumeCleanup( // NOTE: 1. DO NOT ALLOW ROX and RWX for block on file // 2. 'BlockOnFile' protocol set via the PVC annotation with multi-node access mode // 3. We do not support raw block volumes with block on file or NFS protocol. +// It returns an error if the backend update is invalid. +// Parameters: +// ctx - context for logging +// volumeMode - the volume mode +// accessMode - the access mode +// protocol - the protocol +// Returns: +// config.Protocol - the protocol +// error - the error if the update is invalid, nil if the update is valid +// Example: +// protocol, err := o.getProtocol(ctx, volumeMode, accessMode, protocol) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 995d04ac2f2247c573571a1b586e3638 -- func (o *TridentOrchestrator) getProtocol( ctx context.Context, volumeMode config.VolumeMode, accessMode config.AccessMode, protocol config.Protocol, ) (config.Protocol, error) { @@ -4632,21 +5034,19 @@ func (o *TridentOrchestrator) getProtocol( return res.protocol, res.err } -// AddStorageClass adds a storage class to the orchestrator -// It returns an error if the storage class already exists +// AddStorageClass adds a new storage class to the orchestrator. +// It returns an error if the storage class already exists or if there is any other problem. // Parameters: -// ctx - context -// scConfig - storage class config +// ctx - context for logging +// scConfig - the storage class config // Returns: -// *storageclass.External - the storage class -// error - error if one occurred +// scExternal - the storage class external +// error - the error if there is any // Example: -// sc, err := o.AddStorageClass(ctx, scConfig) -// if err != nil { -// return nil, err -// } +// scExternal, err := o.AddStorageClass(ctx, scConfig) +// // -// -- Doc autogenerated on 2022-05-26 22:40:01. Function hash: 7dd9fefe2646ed78b243a4d6e24b7079 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 7dd9fefe2646ed78b243a4d6e24b7079 -- func (o *TridentOrchestrator) AddStorageClass( ctx context.Context, scConfig *storageclass.Config, ) (scExternal *storageclass.External, err error) { @@ -4685,16 +5085,19 @@ func (o *TridentOrchestrator) AddStorageClass( return sc.ConstructExternal(ctx), nil } -// GetStorageClass returns the storage class with the given name +// GetStorageClass returns a storage class by name +// It returns an error if the storage class is not found // Parameters: -// scName - the name of the storage class to retrieve +// ctx - context for logging +// scName - the name of the storage class // Returns: -// scExternal - the storage class, if found -// err - an error, if any +// storageclass.External - the storage class +// error - error if there is any // Example: -// sc, err := o.GetStorageClass(ctx, scName) +// sc, err := orchestrator.GetStorageClass(ctx, "sc1") // -// -- Doc autogenerated on 2022-05-26 22:40:15. Function hash: 8ea7a3398086c800c66845416db5fef0 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: 8ea7a3398086c800c66845416db5fef0 -- func (o *TridentOrchestrator) GetStorageClass( ctx context.Context, scName string, ) (scExternal *storageclass.External, err error) { @@ -4716,16 +5119,18 @@ func (o *TridentOrchestrator) GetStorageClass( return sc.ConstructExternal(ctx), nil } -// ListStorageClasses returns a list of all storage classes +// ListStorageClasses lists all storage classes. +// It returns an error if there is any. // Parameters: // ctx - context for logging // Returns: -// []*storageclass.External - a list of storage classes -// error - any errors encountered +// scExternals - a slice of storage class externals +// error - the error if there is any // Example: -// storageClasses, err := tridentOrchestrator.ListStorageClasses(ctx) +// scExternals, err := o.ListStorageClasses(ctx) +// // -// -- Doc autogenerated on 2022-05-26 22:40:32. Function hash: 1d060e4f98ef90c4e6fd57ca995cef7d -- +// -- Doc autogenerated on 2022-06-21. Function hash: 1d060e4f98ef90c4e6fd57ca995cef7d -- func (o *TridentOrchestrator) ListStorageClasses(ctx context.Context) ( scExternals []*storageclass.External, err error, ) { @@ -4745,17 +5150,18 @@ func (o *TridentOrchestrator) ListStorageClasses(ctx context.Context) ( return storageClasses, nil } -// DeleteStorageClass deletes a storage class -// It returns an error if the storage class does not exist +// DeleteStorageClass deletes a storage class. +// It returns an error if the storage class does not exist. // Parameters: -// ctx - context -// scName - name of the storage class to delete +// ctx - context for logging +// scName - the name of the storage class // Returns: -// error - result of the delete operation +// error - the error if the storage class could not be deleted, nil if the storage class was deleted // Example: -// err := o.DeleteStorageClass(ctx, "sc1") +// err := o.DeleteStorageClass(ctx, "storageclass1") +// // -// -- Doc autogenerated on 2022-05-26 22:40:54. Function hash: 7a09523cfb169968ae4a2c6a92941083 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 7a09523cfb169968ae4a2c6a92941083 -- func (o *TridentOrchestrator) DeleteStorageClass(ctx context.Context, scName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -4788,18 +5194,15 @@ func (o *TridentOrchestrator) DeleteStorageClass(ctx context.Context, scName str } // reconcileNodeAccessOnAllBackends reconciles node access on all backends. -// It returns an error if any backend fails to reconcile. +// It returns an error if there is any. // Parameters: -// ctx - context +// ctx - context for logging // Returns: -// error - if any backend fails to reconcile +// error - the error if there is any // Example: -// err := o.reconcileNodeAccessOnAllBackends(ctx) -// if err != nil { -// log.Errorf("Error reconciling node access on backends: %v", err) -// } +// err := o.reconcileNodeAccessOnAllBackends(ctx) // -// -- Doc autogenerated on 2022-05-26 22:41:13. Function hash: 05c9e184edcad2ea38d16deda4378f81 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 05c9e184edcad2ea38d16deda4378f81 -- func (o *TridentOrchestrator) reconcileNodeAccessOnAllBackends(ctx context.Context) error { if config.CurrentDriverContext != config.ContextCSI { return nil @@ -4820,20 +5223,17 @@ func (o *TridentOrchestrator) reconcileNodeAccessOnAllBackends(ctx context.Conte return nil } -// reconcileNodeAccessOnBackend reconciles node access on a backend -// It returns an error if the operation fails +// reconcileNodeAccessOnBackend updates the node access on the backend. +// It returns an error if the update fails. // Parameters: -// ctx - context -// b - backend -// Return: -// error - error if any +// ctx - context for logging +// b - the backend +// Returns: +// error - the error if the update fails, nil if the update succeeds // Example: // err := o.reconcileNodeAccessOnBackend(ctx, backend) -// if err != nil { -// return err -// } // -// -- Doc autogenerated on 2022-05-26 22:41:32. Function hash: 32894d9e525f95bbcc5fd8c4512369cf -- +// -- Doc autogenerated on 2022-06-21. Function hash: 32894d9e525f95bbcc5fd8c4512369cf -- func (o *TridentOrchestrator) reconcileNodeAccessOnBackend(ctx context.Context, b storage.Backend) error { if config.CurrentDriverContext != config.ContextCSI { return nil @@ -4850,6 +5250,17 @@ func (o *TridentOrchestrator) reconcileNodeAccessOnBackend(ctx context.Context, // safeReconcileNodeAccessOnBackend wraps reconcileNodeAccessOnBackend in a mutex lock for use in functions that aren't // already locked +// It returns an error if the reconcileNodeAccessOnBackend is invalid. +// Parameters: +// ctx - context for logging +// b - the backend +// Returns: +// error - the error if the reconcileNodeAccessOnBackend is invalid, nil if the reconcileNodeAccessOnBackend is valid +// Example: +// err := o.safeReconcileNodeAccessOnBackend(ctx, b) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: bdb28af6609b6ba01797424052aa73e7 -- func (o *TridentOrchestrator) safeReconcileNodeAccessOnBackend(ctx context.Context, b storage.Backend) error { o.mutex.Lock() defer o.mutex.Unlock() @@ -4858,6 +5269,11 @@ func (o *TridentOrchestrator) safeReconcileNodeAccessOnBackend(ctx context.Conte // PeriodicallyReconcileNodeAccessOnBackends is intended to be run as a goroutine and will periodically run // safeReconcileNodeAccessOnBackend for each backend in the orchestrator +// Example: +// o.PeriodicallyReconcileNodeAccessOnBackends() +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: df6e25b990a456580f2a0f5d0d3cf3ff -- func (o *TridentOrchestrator) PeriodicallyReconcileNodeAccessOnBackends() { o.stopNodeAccessLoop = make(chan bool) ctx := GenerateRequestContext(context.Background(), "", ContextSourcePeriodic) @@ -4891,18 +5307,19 @@ func (o *TridentOrchestrator) PeriodicallyReconcileNodeAccessOnBackends() { } } -// AddNode adds a new node to the orchestrator -// It returns an error if the node already exists +// AddNode adds a new node to the orchestrator. +// It returns an error if the node cannot be added. // Parameters: -// ctx +// ctx - context for logging // node - the node to add -// nodeEventCallback - callback function to call when node status changes +// nodeEventCallback - the callback to invoke when node events occur // Returns: -// error - any error encountered +// error - the error if the node could not be added, nil if the node was added successfully // Example: -// err := o.AddNode(ctx, node, nil) +// err := o.AddNode(ctx, node, nodeEventCallback) +// // -// -- Doc autogenerated on 2022-05-26 22:41:57. Function hash: cd542a37d4abbbf6ed9a5b48b6c67621 -- +// -- Doc autogenerated on 2022-06-21. Function hash: cd542a37d4abbbf6ed9a5b48b6c67621 -- func (o *TridentOrchestrator) AddNode( ctx context.Context, node *utils.Node, nodeEventCallback NodeEventCallback, ) (err error) { @@ -4945,31 +5362,29 @@ func (o *TridentOrchestrator) AddNode( return nil } -// invalidateAllBackendNodeAccess invalidates all backend node access -// Returns: -// None +// invalidateAllBackendNodeAccess invalidates all backend node access. +// This function is called when a node is removed from the cluster. // Example: -// orchestrator.invalidateAllBackendNodeAccess() +// o.invalidateAllBackendNodeAccess() // -// -- Doc autogenerated on 2022-05-26 22:42:10. Function hash: 217366d8152ca1accdb52538ef405299 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 217366d8152ca1accdb52538ef405299 -- func (o *TridentOrchestrator) invalidateAllBackendNodeAccess() { for _, backend := range o.backends { backend.InvalidateNodeAccess() } } -// handleUpdatedNodePrep handles the node prep status update. +// handleUpdatedNodePrep validates that the backend update is valid. +// It returns an error if the backend update is invalid. // Parameters: // ctx - context for logging -// protocol - protocol for which the prep status is being reported -// node - node for which the prep status is being reported -// nodeEventCallback - callback function to report events -// Returns: -// None +// protocol - the protocol for the backend +// node - the node to update +// nodeEventCallback - the callback for node events // Example: -// handleUpdatedNodePrep(ctx, "NFS", node, nodeEventCallback) +// err := o.handleUpdatedNodePrep(ctx, "NFS", node, nodeEventCallback) // -// -- Doc autogenerated on 2022-05-26 22:42:34. Function hash: a834161b9eb4a27bfbb289d967a44a23 -- +// -- Doc autogenerated on 2022-06-21. Function hash: a834161b9eb4a27bfbb289d967a44a23 -- func (o *TridentOrchestrator) handleUpdatedNodePrep( ctx context.Context, protocol string, node *utils.Node, nodeEventCallback NodeEventCallback, ) { @@ -5011,21 +5426,18 @@ func (o *TridentOrchestrator) handleUpdatedNodePrep( } } -// GetNode retrieves a node from the orchestrator -// It returns a NotFoundError if the node is not found +// GetNode returns a node by name +// It returns an error if the node is not found // Parameters: -// ctx - context -// nName - name of the node +// ctx - context for logging +// nName - the name of the node // Returns: -// *utils.Node - a pointer to the node object -// error - any error encountered +// utils.Node - the node +// error - error if there is any // Example: // node, err := orchestrator.GetNode(ctx, "node1") -// if err != nil { -// t.Error(err) -// } // -// -- Doc autogenerated on 2022-05-26 22:42:57. Function hash: 8adb5cc590b1e328ec136e1d38883212 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 8adb5cc590b1e328ec136e1d38883212 -- func (o *TridentOrchestrator) GetNode(ctx context.Context, nName string) (node *utils.Node, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -5046,21 +5458,17 @@ func (o *TridentOrchestrator) GetNode(ctx context.Context, nName string) (node * return node, nil } -// ListNodes lists all nodes in the cluster -// It returns a list of Node objects +// ListNodes returns a list of all nodes in the cluster. +// It returns an error if there is any. // Parameters: -// ctx - context (for cancellation) +// ctx - context for logging // Returns: -// list of nodes in the cluster -// error - non-nil if an error occurred +// nodes - a list of all nodes in the cluster +// error - the error if there is any // Example: -// nodes, err := orchestrator.ListNodes(ctx) -// if err != nil { -// log.Error(err) -// return -// } +// nodes, err := o.ListNodes(ctx) // -// -- Doc autogenerated on 2022-05-26 22:43:18. Function hash: 9bdd3a6d45b81df549bbe35f26aeeb85 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 9bdd3a6d45b81df549bbe35f26aeeb85 -- func (o *TridentOrchestrator) ListNodes(context.Context) (nodes []*utils.Node, err error) { if o.bootstrapError != nil { return nil, o.bootstrapError @@ -5078,17 +5486,18 @@ func (o *TridentOrchestrator) ListNodes(context.Context) (nodes []*utils.Node, e return nodes, nil } -// DeleteNode removes the node from the orchestrator. -// It returns an error if the node is not found. +// DeleteNode deletes a node from the orchestrator. +// It returns an error if the node cannot be deleted. // Parameters: +// ctx - context for logging // nodeName - the name of the node to delete -// force - if true, delete the node even if volumes are published to it // Returns: -// error - nil if the node was deleted successfully, or an error if the node was not found +// error - the error if the node cannot be deleted, nil if the node is deleted // Example: -// err := orchestrator.DeleteNode("node1") +// err := o.DeleteNode(ctx, "node1") // -// -- Doc autogenerated on 2022-05-26 22:43:44. Function hash: f40063d78d89136a99089e4c9c2b95a7 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: f40063d78d89136a99089e4c9c2b95a7 -- func (o *TridentOrchestrator) DeleteNode(ctx context.Context, nodeName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -5133,20 +5542,18 @@ func (o *TridentOrchestrator) DeleteNode(ctx context.Context, nodeName string) ( return nil } -// deleteNode removes the specified node from the orchestrator -// It returns an error if the node does not exist +// deleteNode deletes a node from the backend. +// It returns an error if the node cannot be deleted. // Parameters: -// ctx - context -// nodeName - name of the node to be deleted -// Return: -// error - error if one occurred +// ctx - context for logging +// nodeName - the name of the node to delete +// Returns: +// error - the error if the node could not be deleted, nil if the node was deleted // Example: // err := o.deleteNode(ctx, "node1") -// if err != nil { -// return err -// } // -// -- Doc autogenerated on 2022-05-26 22:44:08. Function hash: 06e53486e08860cbb879e4101d6a9c68 -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: 06e53486e08860cbb879e4101d6a9c68 -- func (o *TridentOrchestrator) deleteNode(ctx context.Context, nodeName string) (err error) { node, found := o.nodes[nodeName] if !found { @@ -5162,6 +5569,17 @@ func (o *TridentOrchestrator) deleteNode(ctx context.Context, nodeName string) ( } // AddVolumePublication records the volume publication for a given volume/node pair +// It returns an error if the volume publication is invalid. +// Parameters: +// ctx - context for logging +// publication - the volume publication +// Returns: +// error - the error if the volume publication is invalid, nil if the volume publication is valid +// Example: +// err := o.AddVolumePublication(ctx, publication) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: b1668caeb5dc278a0b31431c551b5138 -- func (o *TridentOrchestrator) AddVolumePublication( ctx context.Context, publication *utils.VolumePublication, ) (err error) { @@ -5185,6 +5603,19 @@ func (o *TridentOrchestrator) AddVolumePublication( } // GetVolumePublication returns the volume publication for a given volume/node pair +// It returns an error if the volume publication is not found +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume +// nodeName - the name of the node +// Returns: +// *utils.VolumePublication - the volume publication +// error - error if there is any +// Example: +// publication, err := orchestrator.GetVolumePublication(ctx, "volume1", "node1") +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: b1fc2e7f685a7a38388d3fccd1ae996c -- func (o *TridentOrchestrator) GetVolumePublication( _ context.Context, volumeName, nodeName string, ) (publication *utils.VolumePublication, err error) { @@ -5206,6 +5637,16 @@ func (o *TridentOrchestrator) GetVolumePublication( } // ListVolumePublications returns a list of all volume publications +// It returns a list of all volume publications +// Parameters: +// context.Context - the context for the request +// Returns: +// publications []*utils.VolumePublication - the list of all volume publications +// err error - error if there is any +// Example: +// publications, err := orchestrator.ListVolumePublications(context.Context) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 35b0c9f7716835376b83e5b08e5d914b -- func (o *TridentOrchestrator) ListVolumePublications( context.Context, ) (publications []*utils.VolumePublication, err error) { @@ -5228,6 +5669,18 @@ func (o *TridentOrchestrator) ListVolumePublications( } // ListVolumePublicationsForVolume returns a list of all volume publications for a given volume +// It returns an error if the volume doesn't exist +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume +// Returns: +// publications - a list of volume publications +// error - the error if there is any +// Example: +// publications, err := orchestrator.ListVolumePublicationsForVolume(ctx, "volume1") +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: c53b2c66667305b38b8683919d86e898 -- func (o *TridentOrchestrator) ListVolumePublicationsForVolume( ctx context.Context, volumeName string, ) (publications []*utils.VolumePublication, err error) { @@ -5244,15 +5697,18 @@ func (o *TridentOrchestrator) ListVolumePublicationsForVolume( return } -// listVolumePublicationsForVolume returns the list of publications for a volume +// listVolumePublicationsForVolume returns a list of VolumePublications for a volume +// It returns an error if the volume doesn't exist // Parameters: +// ctx - context for logging // volumeName - the name of the volume -// Return: -// the list of publications for the volume +// Returns: +// []*utils.VolumePublication - the list of VolumePublications +// error - error if there is any // Example: -// publications := o.listVolumePublicationsForVolume("myvol") +// publications, err := orchestrator.listVolumePublicationsForVolume(ctx, "volume1") // -// -- Doc autogenerated on 2022-05-26 22:44:22. Function hash: 44ca89b928a2986ee3de364f14767cb3 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 44ca89b928a2986ee3de364f14767cb3 -- func (o *TridentOrchestrator) listVolumePublicationsForVolume( _ context.Context, volumeName string, ) (publications []*utils.VolumePublication) { @@ -5264,6 +5720,18 @@ func (o *TridentOrchestrator) listVolumePublicationsForVolume( } // ListVolumePublicationsForNode returns a list of all volume publications for a given node +// It returns a list of all volume publications for a given node +// Parameters: +// ctx - context for logging +// nodeName - the name of the node +// Returns: +// publications - the list of volume publications +// error - error if there is any +// Example: +// publications, err := orchestrator.ListVolumePublicationsForNode(ctx, "node1") +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 9f0a1519a0a5c2c573b3fe8bd06586ab -- func (o *TridentOrchestrator) ListVolumePublicationsForNode( ctx context.Context, nodeName string, ) (publications []*utils.VolumePublication, err error) { @@ -5280,15 +5748,18 @@ func (o *TridentOrchestrator) ListVolumePublicationsForNode( return } -// listVolumePublicationsForNode returns a list of VolumePublications for a given node +// listVolumePublicationsForNode returns a list of volume publications for a node. +// It returns an error if the node name is invalid. // Parameters: -// nodeName: name of the node to get the list of VolumePublications for +// ctx - context for logging +// nodeName - the name of the node // Returns: -// []*utils.VolumePublication: list of VolumePublications for the given node +// publications - the list of volume publications +// error - error if there is any // Example: -// publications := o.listVolumePublicationsForNode("node1") +// publications, err := orchestrator.listVolumePublicationsForNode(ctx, "node1") // -// -- Doc autogenerated on 2022-05-26 22:44:40. Function hash: 8341522491607108df10aca16d8bc332 -- +// -- Doc autogenerated on 2022-06-21. Function hash: 8341522491607108df10aca16d8bc332 -- func (o *TridentOrchestrator) listVolumePublicationsForNode( _ context.Context, nodeName string, ) (publications []*utils.VolumePublication) { @@ -5302,6 +5773,17 @@ func (o *TridentOrchestrator) listVolumePublicationsForNode( } // DeleteVolumePublication deletes the record of the volume publication for a given volume/node pair +// It returns an error if the volume publication is not found. +// Parameters: +// ctx - context for logging +// volumeName - the name of the volume +// nodeName - the name of the node +// Returns: +// error - the error if there is any +// Example: +// err := o.DeleteVolumePublication(ctx, volumeName, nodeName) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 91456af5ab89a609eb84c7bcf52644ce -- func (o *TridentOrchestrator) DeleteVolumePublication(ctx context.Context, volumeName, nodeName string) (err error) { if o.bootstrapError != nil { return o.bootstrapError @@ -5327,16 +5809,14 @@ func (o *TridentOrchestrator) DeleteVolumePublication(ctx context.Context, volum return nil } -// removeVolumePublicationFromCache removes the volume publication from the cache +// removeVolumePublicationFromCache removes a volume publication from the cache. // Parameters: // volumeID - the ID of the volume -// nodeID - the node that the volume is being removed from -// Returns: -// None +// nodeID - the ID of the node // Example: -// removeVolumePublicationFromCache("volume1", "node1") +// o.removeVolumePublicationFromCache(volumeID, nodeID) // -// -- Doc autogenerated on 2022-05-26 22:45:00. Function hash: 0edde50e382bbe37edba87d678249a5a -- +// -- Doc autogenerated on 2022-06-21. Function hash: 0edde50e382bbe37edba87d678249a5a -- func (o *TridentOrchestrator) removeVolumePublicationFromCache(volumeID, nodeID string) { delete(o.volumePublications[volumeID], nodeID) // If there are no more nodes for this volume, remove the volume's entry @@ -5345,18 +5825,18 @@ func (o *TridentOrchestrator) removeVolumePublicationFromCache(volumeID, nodeID } } -// updateBackendOnPersistentStore updates the backend on the persistent store -// It returns an error if the backend could not be updated +// updateBackendOnPersistentStore updates the backend information on the persistent store +// It returns an error if the backend update is invalid. // Parameters: // ctx - context for logging // backend - the backend to update -// newBackend - true if this is a new backend, false if it is an update +// newBackend - true if this is a new backend, false if this is an update to an existing backend // Returns: -// error - error if the backend could not be updated +// error - the error if there is any // Example: // err := o.updateBackendOnPersistentStore(ctx, backend, true) // -// -- Doc autogenerated on 2022-05-26 22:47:30. Function hash: 0b8bff03ea76c0c057f27c6fad87a4db -- +// -- Doc autogenerated on 2022-06-21. Function hash: 0b8bff03ea76c0c057f27c6fad87a4db -- func (o *TridentOrchestrator) updateBackendOnPersistentStore( ctx context.Context, backend storage.Backend, newBackend bool, ) error { @@ -5381,16 +5861,17 @@ func (o *TridentOrchestrator) updateBackendOnPersistentStore( } // updateVolumeOnPersistentStore updates the volume information in persistent store -// It returns an error if the volume is not found in persistent store +// It returns an error if the update fails. // Parameters: -// ctx - context -// vol - volume object +// ctx - context for logging +// vol - the volume to update // Returns: -// error - error +// error - the error if there is any // Example: // err := o.updateVolumeOnPersistentStore(ctx, vol) // -// -- Doc autogenerated on 2022-05-26 22:47:54. Function hash: c4edd3c8428fe8edb94d43e360c1775a -- +// +// -- Doc autogenerated on 2022-06-21. Function hash: c4edd3c8428fe8edb94d43e360c1775a -- func (o *TridentOrchestrator) updateVolumeOnPersistentStore(ctx context.Context, vol *storage.Volume) error { // Update the volume information in persistent store Logc(ctx).WithFields(log.Fields{ @@ -5402,18 +5883,18 @@ func (o *TridentOrchestrator) updateVolumeOnPersistentStore(ctx context.Context, return o.storeClient.UpdateVolume(ctx, vol) } -// replaceBackendAndUpdateVolumesOnPersistentStore replaces the backend and updates the volumes on the persistent store -// It returns an error if the backend could not be replaced +// replaceBackendAndUpdateVolumesOnPersistentStore updates the backend and volume information in persistent store +// It returns an error if the backend update is invalid. // Parameters: -// ctx - context for logging -// origBackend - the backend to be replaced -// newBackend - the backend to replace the original backend with +// ctx - context for logging +// origBackend - the original backend +// newBackend - the new backend // Returns: -// error - error if the backend could not be replaced +// error - the error if there is any // Example: -// err := o.replaceBackendAndUpdateVolumesOnPersistentStore(context.Background(), origBackend, newBackend) +// err := o.replaceBackendAndUpdateVolumesOnPersistentStore(ctx, oldBackend, newBackend) // -// -- Doc autogenerated on 2022-05-26 22:48:20. Function hash: a493110fffae19fac507baac4b3502e7 -- +// -- Doc autogenerated on 2022-06-21. Function hash: a493110fffae19fac507baac4b3502e7 -- func (o *TridentOrchestrator) replaceBackendAndUpdateVolumesOnPersistentStore( ctx context.Context, origBackend, newBackend storage.Backend, ) error { @@ -5425,23 +5906,34 @@ func (o *TridentOrchestrator) replaceBackendAndUpdateVolumesOnPersistentStore( return o.storeClient.ReplaceBackendAndUpdateVolumes(ctx, origBackend, newBackend) } -// isCRDContext returns true if the context is from a CRD +// isCRDContext returns true if the context is from a CRD request, false otherwise. +// It returns an error if the context is nil. // Parameters: -// ctx - the context +// ctx - context for logging // Returns: -// true if the context is from a CRD +// bool - true if the context is from a CRD request, false otherwise // Example: -// if o.isCRDContext(ctx) { -// // context is from a CRD -// } +// crdContext := o.isCRDContext(ctx) // -// -- Doc autogenerated on 2022-05-26 22:48:47. Function hash: fac4a506fe93e8407310464685f2985d -- +// -- Doc autogenerated on 2022-06-21. Function hash: fac4a506fe93e8407310464685f2985d -- func (o *TridentOrchestrator) isCRDContext(ctx context.Context) bool { ctxSource := ctx.Value(ContextKeyRequestSource) return ctxSource != nil && ctxSource == ContextSourceCRD } // EstablishMirror creates a net-new replication mirror relationship between 2 volumes on a backend +// It returns an error if the backend does not support mirroring or if there is any other issue +// Parameters: +// ctx - context for logging +// backendUUID - the UUID of the backend +// localVolumeHandle - the handle of the local volume +// remoteVolumeHandle - the handle of the remote volume +// Returns: +// error - the error if there is any +// Example: +// err := o.EstablishMirror(ctx, backendUUID, localVolumeHandle, remoteVolumeHandle) +// +// -- Doc autogenerated on 2022-06-21. Function hash: c1b765518fd5a2d8aba3fd70a859cc19 -- func (o *TridentOrchestrator) EstablishMirror( ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle string, ) (err error) { @@ -5465,6 +5957,18 @@ func (o *TridentOrchestrator) EstablishMirror( } // ReestablishMirror recreates a previously existing replication mirror relationship between 2 volumes on a backend +// It returns an error if the backend does not support mirroring or if the mirror relationship could not be reestablished +// Parameters: +// ctx - context for logging +// backendUUID - the UUID of the backend +// localVolumeHandle - the handle of the local volume +// remoteVolumeHandle - the handle of the remote volume +// Returns: +// error - the error if the mirror relationship could not be reestablished, nil if the mirror relationship was reestablished +// Example: +// err := o.ReestablishMirror(ctx, backendUUID, localVolumeHandle, remoteVolumeHandle) +// +// -- Doc autogenerated on 2022-06-21. Function hash: 40c0b94acb3698f346989583106795e9 -- func (o *TridentOrchestrator) ReestablishMirror( ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle string, ) (err error) { @@ -5488,6 +5992,21 @@ func (o *TridentOrchestrator) ReestablishMirror( } // PromoteMirror makes the local volume the primary +// It returns a boolean indicating if the operation is waiting for a snapshot to be created +// Parameters: +// ctx - context for logging +// backendUUID - the UUID of the backend +// localVolumeHandle - the handle of the local volume +// remoteVolumeHandle - the handle of the remote volume +// snapshotHandle - the handle of the snapshot +// Returns: +// waitingForSnapshot - a boolean indicating if the operation is waiting for a snapshot to be created +// error - error if there is any +// Example: +// waitingForSnapshot, err := orchestrator.PromoteMirror(ctx, backendUUID, localVolumeHandle, remoteVolumeHandle, snapshotHandle) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 8230ace2dfda41f272c4cbd62ca3e0d2 -- func (o *TridentOrchestrator) PromoteMirror( ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle, snapshotHandle string, ) (waitingForSnapshot bool, err error) { @@ -5511,6 +6030,19 @@ func (o *TridentOrchestrator) PromoteMirror( } // GetMirrorStatus returns the current status of the mirror relationship +// It returns the status of the mirror relationship +// Parameters: +// ctx - context for logging +// backendUUID - the UUID of the backend +// localVolumeHandle - the handle of the local volume +// remoteVolumeHandle - the handle of the remote volume +// Returns: +// status - the status of the mirror relationship +// error - error if there is any +// Example: +// status, err := orchestrator.GetMirrorStatus(ctx, backendUUID, localVolumeHandle, remoteVolumeHandle) +// +// -- Doc autogenerated on 2022-06-21. Function hash: ed60295af3f0c04c70f60e57d5548a49 -- func (o *TridentOrchestrator) GetMirrorStatus( ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle string, ) (status string, err error) { @@ -5533,15 +6065,18 @@ func (o *TridentOrchestrator) GetMirrorStatus( return mirrorBackend.GetMirrorStatus(ctx, localVolumeHandle, remoteVolumeHandle) } -// CanBackendMirror returns true if the backend can mirror +// CanBackendMirror returns a boolean indicating whether the backend is capable of mirroring. +// It returns an error if the backend does not exist. // Parameters: -// backendUUID - backend to check +// ctx - context for logging +// backendUUID - the UUID of the backend // Returns: -// (capable, error) +// capable - boolean indicating whether the backend is capable of mirroring +// error - error if there is any // Example: -// capable, err := orchestrator.CanBackendMirror(context.Background(), "backend-uuid") +// capable, err := orchestrator.CanBackendMirror(ctx, backendUUID) // -// -- Doc autogenerated on 2022-05-26 22:49:04. Function hash: bc1b19ddd30247a2154212e70860764d -- +// -- Doc autogenerated on 2022-06-21. Function hash: bc1b19ddd30247a2154212e70860764d -- func (o *TridentOrchestrator) CanBackendMirror(_ context.Context, backendUUID string) (capable bool, err error) { if o.bootstrapError != nil { return false, o.bootstrapError @@ -5559,6 +6094,18 @@ func (o *TridentOrchestrator) CanBackendMirror(_ context.Context, backendUUID st } // ReleaseMirror removes snapmirror relationship infromation and snapshots for a source volume in ONTAP +// It returns an error if the release is unsuccessful. +// Parameters: +// ctx - context for logging +// backendUUID - the UUID of the backend +// localVolumeHandle - the handle of the source volume +// Returns: +// error - the error if the release is unsuccessful, nil if the release is successful +// Example: +// err := o.ReleaseMirror(ctx, backendUUID, localVolumeHandle) +// +// +// -- Doc autogenerated on 2022-06-21. Function hash: 84e545395def660448d10aaebe86988c -- func (o *TridentOrchestrator) ReleaseMirror( ctx context.Context, backendUUID, localVolumeHandle string, ) (err error) { @@ -5581,18 +6128,19 @@ func (o *TridentOrchestrator) ReleaseMirror( return mirrorBackend.ReleaseMirror(ctx, localVolumeHandle) } -// GetCHAP returns the CHAP credentials for the specified volume and node. +// GetCHAP returns the CHAP information for a volume. +// It returns an error if the volume does not exist. // Parameters: -// ctx - context for logging -// volumeName - the name of the volume -// nodeName - the name of the node +// ctx - context for logging +// volumeName - the name of the volume +// nodeName - the name of the node // Returns: -// chapInfo - the CHAP credentials -// err - error if CHAP credentials could not be retrieved +// chapInfo - the CHAP information +// error - the error if there is any // Example: -// chapInfo, err := orchestrator.GetCHAP(ctx, "volume1", "node1") +// chapInfo, err := orchestrator.GetCHAP(ctx, "volume1", "node1") // -// -- Doc autogenerated on 2022-05-26 22:49:24. Function hash: 235deca5df832ab0568e48718d1e814c -- +// -- Doc autogenerated on 2022-06-21. Function hash: 235deca5df832ab0568e48718d1e814c -- func (o *TridentOrchestrator) GetCHAP( ctx context.Context, volumeName, nodeName string, ) (chapInfo *utils.IscsiChapInfo, err error) {