Pass Velero server command args to the plugins

Pass Velero server command args to the plugins

Fixes #7806

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
Wenkai Yin(尹文开)
2024-09-04 13:43:27 +08:00
parent 981f30cb25
commit dc6eeafe98
22 changed files with 500 additions and 483 deletions
+1 -28
View File
@@ -17,8 +17,6 @@ limitations under the License.
package process
import (
"strings"
plugin "github.com/hashicorp/go-plugin"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -61,32 +59,7 @@ func newProcess(command string, logger logrus.FieldLogger, logLevel logrus.Level
// This launches the plugin process.
protocolClient, err := client.Client()
if err != nil {
if !strings.Contains(err.Error(), "unknown flag: --features") {
return nil, err
}
// Velero started passing the --features flag to plugins in v1.2, however existing plugins
// may not support that flag and may not silently ignore unknown flags. The plugin server
// code that we make available to plugin authors has since been updated to ignore unknown
// flags, but to avoid breaking plugins that haven't updated to that code and don't support
// the --features flag, we specifically handle not passing the flag if we can detect that
// it's not supported.
logger.Debug("Plugin process does not support the --features flag, removing it and trying again")
builder.commandArgs = removeFeaturesFlag(builder.commandArgs)
logger.Debugf("Updated command args after removing --features flag: %v", builder.commandArgs)
// re-get the client and protocol client now that --features has been removed
// from the command args.
client = builder.client()
protocolClient, err = client.Client()
if err != nil {
return nil, err
}
logger.Debug("Plugin process successfully started without the --features flag")
return nil, err
}
p := &process{