From 2d845683a2ddf06b956433ff57e04b86890f4776 Mon Sep 17 00:00:00 2001 From: lintongj <55512168+lintongj@users.noreply.github.com> Date: Fri, 27 Sep 2019 13:10:00 -0700 Subject: [PATCH] Add LD_LIBRARY_PATH as an env varible for the use of vsphere plugin (#1893) * Add LD_LIBRARY_PATH as an env varible for the use of vsphere plugin Signed-off-by: Lintong Jiang --- changelogs/unreleased/1893-lintongj | 1 + pkg/install/deployment.go | 4 ++++ pkg/install/deployment_test.go | 4 ++-- site/docs/master/plugins.md | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/1893-lintongj diff --git a/changelogs/unreleased/1893-lintongj b/changelogs/unreleased/1893-lintongj new file mode 100644 index 000000000..4a200e5ed --- /dev/null +++ b/changelogs/unreleased/1893-lintongj @@ -0,0 +1 @@ +Add LD_LIBRARY_PATH (=/plugins) to the env variables of velero deployment. \ No newline at end of file diff --git a/pkg/install/deployment.go b/pkg/install/deployment.go index 6529fcb22..4f8686ecf 100644 --- a/pkg/install/deployment.go +++ b/pkg/install/deployment.go @@ -161,6 +161,10 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment }, }, }, + { + Name: "LD_LIBRARY_PATH", + Value: "/plugins", + }, }, Resources: c.resources, }, diff --git a/pkg/install/deployment_test.go b/pkg/install/deployment_test.go index 2e441a094..aa989cb77 100644 --- a/pkg/install/deployment_test.go +++ b/pkg/install/deployment_test.go @@ -33,7 +33,7 @@ func TestDeployment(t *testing.T) { assert.Equal(t, "--restore-only", deploy.Spec.Template.Spec.Containers[0].Args[1]) deploy = Deployment("velero", WithEnvFromSecretKey("my-var", "my-secret", "my-key")) - envSecret := deploy.Spec.Template.Spec.Containers[0].Env[2] + envSecret := deploy.Spec.Template.Spec.Containers[0].Env[3] assert.Equal(t, "my-var", envSecret.Name) assert.Equal(t, "my-secret", envSecret.ValueFrom.SecretKeyRef.LocalObjectReference.Name) assert.Equal(t, "my-key", envSecret.ValueFrom.SecretKeyRef.Key) @@ -43,7 +43,7 @@ func TestDeployment(t *testing.T) { assert.Equal(t, corev1.PullIfNotPresent, deploy.Spec.Template.Spec.Containers[0].ImagePullPolicy) deploy = Deployment("velero", WithSecret(true)) - assert.Equal(t, 5, len(deploy.Spec.Template.Spec.Containers[0].Env)) + assert.Equal(t, 6, len(deploy.Spec.Template.Spec.Containers[0].Env)) assert.Equal(t, 3, len(deploy.Spec.Template.Spec.Volumes)) deploy = Deployment("velero", WithDefaultResticMaintenanceFrequency(24*time.Hour)) diff --git a/site/docs/master/plugins.md b/site/docs/master/plugins.md index 2cef45cd3..9ff25904b 100644 --- a/site/docs/master/plugins.md +++ b/site/docs/master/plugins.md @@ -82,6 +82,10 @@ Velero will pass any known features flags as a comma-separated list of strings t Once parsed into a `[]string`, the features can then be registered using the `NewFeatureFlagSet` function and queried with `features.Enabled()`. +## Environment Variables + +Velero adds the `LD_LIBRARY_PATH` into the list of environment variables to provide the convenience for plugins that requires C libraries/extensions in the runtime. + [1]: https://github.com/heptio/velero-plugin-example [2]: https://github.com/heptio/velero/blob/master/pkg/plugin/logger.go [3]: https://github.com/heptio/velero/blob/master/pkg/restore/restic_restore_action.go