Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/core/plugin_manager/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (p *PluginManager) SwitchServerlessEndpoint(
if err != nil {
return err
}
return p.clearServerlessRuntimeCache(pluginUniqueIdentifier)
return p.ClearServerlessRuntimeCache(pluginUniqueIdentifier)
}

// serverless runtime uses a strategy that firstly compile the plugin into a docker image
Expand Down Expand Up @@ -109,7 +109,7 @@ func (p *PluginManager) Reinstall(

// cleanup system cache for serverless runtime model
// cleanup must be done after updating the model, otherwise race condition may occur
if err := p.clearServerlessRuntimeCache(pluginUniqueIdentifier); err != nil {
if err := p.ClearServerlessRuntimeCache(pluginUniqueIdentifier); err != nil {
log.Error("failed to cleanup system cache for serverless runtime model", "error", err)
responseStream.Write(installation_entities.PluginInstallResponse{
Event: installation_entities.PluginInstallEventError,
Expand Down
2 changes: 1 addition & 1 deletion internal/core/plugin_manager/serverless.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (p *PluginManager) getServerlessPluginRuntimeModel(
return runtime, nil
}

func (p *PluginManager) clearServerlessRuntimeCache(
func (p *PluginManager) ClearServerlessRuntimeCache(
identity plugin_entities.PluginUniqueIdentifier,
) error {
_, err := cache.Del(p.getServerlessRuntimeCacheKey(identity))
Expand Down
8 changes: 8 additions & 0 deletions internal/service/install_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ func UninstallPlugin(

if deleteResponse != nil && deleteResponse.IsPluginDeleted {
helper.DeletePluginDeclarationCache(pluginUniqueIdentifier, plugin_entities.PluginRuntimeType(installation.RuntimeType))

if plugin_entities.PluginRuntimeType(installation.RuntimeType) == plugin_entities.PLUGIN_RUNTIME_TYPE_SERVERLESS {
if manager := plugin_manager.Manager(); manager != nil {
if err := manager.ClearServerlessRuntimeCache(pluginUniqueIdentifier); err != nil {
log.Error("failed to clear serverless runtime cache on uninstall", "error", err)
}
}
Comment thread
GareArc marked this conversation as resolved.
}
Comment thread
GareArc marked this conversation as resolved.
}

if deleteResponse != nil && deleteResponse.IsPluginDeleted && deleteResponse.Plugin != nil && deleteResponse.Plugin.InstallType == plugin_entities.PLUGIN_RUNTIME_TYPE_LOCAL {
Expand Down
7 changes: 7 additions & 0 deletions internal/tasks/install_plugin_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,12 @@ func RemovePluginIfNeeded(
return errors.Join(err, errors.New("failed to shutdown plugin gracefully"))
}
}

if shouldCleanup && response.DeletedPlugin != nil && response.DeletedPlugin.InstallType == plugin_entities.PLUGIN_RUNTIME_TYPE_SERVERLESS {
if err := manager.ClearServerlessRuntimeCache(originalPluginUniqueIdentifier); err != nil {
log.Error("failed to clear serverless runtime cache on upgrade", "error", err)
}
}

return nil
}
16 changes: 16 additions & 0 deletions internal/types/models/curd/atomic.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,14 @@ func UninstallPlugin(
}, tx); err != nil {
return err
}

if pluginToBeReturns.InstallType == plugin_entities.PLUGIN_RUNTIME_TYPE_SERVERLESS {
if err := db.DeleteByCondition(&models.ServerlessRuntime{
PluginUniqueIdentifier: pluginUniqueIdentifier.String(),
}, tx); err != nil {
return err
}
}
Comment thread
GareArc marked this conversation as resolved.
}

return nil
Expand Down Expand Up @@ -498,6 +506,14 @@ func UpgradePlugin(
}, tx); err != nil {
return err
}

if originalPlugin.InstallType == plugin_entities.PLUGIN_RUNTIME_TYPE_SERVERLESS {
if err := db.DeleteByCondition(&models.ServerlessRuntime{
PluginUniqueIdentifier: originalPluginUniqueIdentifier.String(),
}, tx); err != nil {
return err
}
}
} else if err != nil {
return err
}
Expand Down
Loading