osd: only set kek to env var on encryption scenario

There is a corner case where an env variable populated with the prepare
job could influence and trigger some encryption code. We have an env
variable to discover whether the prepare job will encrypt a drive or not
so let's use that instead of running code as a noop and sometimes
trigger a corner case. In this scenario, the prepare job had an "IBM_"
env variable present in the OS image (IBM OS) so the setKEKinEnv()
  function would get called for no reason.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han committed 2022-04-11 16:54:18 +02:00
1 parent 1db2ecf99b
commit 6bc7827150
3 files changed
+4 -3

No files matched your search

+2 -1
View File
@@ -158,7 +158,8 @@ func configRawDevice(name string, context *clusterd.Context) (*sys.LocalDisk, er
// Provision provisions an OSD
func Provision(context *clusterd.Context, agent *OsdAgent, crushLocation, topologyAffinity string) error {
if agent.pvcBacked {
if agent.pvcBacked && os.Getenv(oposd.EncryptedDeviceEnvVarName) == "true" {
logger.Debug("encryption configuration detecting, populating kek to an env variable")
// Init KMS store, retrieve the KEK and store it as an env var for ceph-volume
err := setKEKinEnv(context, agent.clusterInfo)
if err != nil {
+1 -2
View File
@@ -103,8 +103,7 @@ func setKEKinEnv(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo)
return errors.Wrap(err, "failed to set key encryption key env variable for ceph-volume")
}
logger.Debug("successfully set vault env variables")
logger.Debug("successfully set kek to env variable")
return nil
}
+1
View File
@@ -134,6 +134,7 @@ func ConfigEnvsToMapString() map[string]string {
pair := strings.SplitN(e, "=", 2)
for _, knownKMS := range knownKMSPrefix {
if strings.HasPrefix(pair[0], knownKMS) || pair[0] == Provider {
logger.Debugf("adding env %q", pair[0])
envs[pair[0]] = os.Getenv(pair[0])
}
}