Skip to content

Commit

Permalink
Merge pull request #124 from nb-ohad/imageset-en
Browse files Browse the repository at this point in the history
Driver Controller: Multi-layer image set loading logic
  • Loading branch information
Madhu-1 authored Sep 3, 2024
2 parents cdc1cd8 + b4f16dd commit 281b79b
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions internal/controller/driver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,37 @@ func (r *driverReconcile) LoadAndValidateDesiredState() error {

// If provided, load an imageset from configmap to overwrite default images
r.images = maps.Clone(imageDefaults)
if r.driver.Spec.ImageSet != nil {
imageSetSpec := opConfig.Spec.DriverSpecDefaults.ImageSet
if imageSetSpec != nil && imageSetSpec.Name != "" {
imageSetCM := corev1.ConfigMap{}
imageSetCM.Name = r.driver.Spec.ImageSet.Name
imageSetCM.Name = imageSetSpec.Name
imageSetCM.Namespace = operatorNamespace
if err := r.Get(r.ctx, client.ObjectKeyFromObject(&imageSetCM), &imageSetCM); err != nil {
r.log.Error(
err,
"Unable to load operator config specified image set config map",
"name",
client.ObjectKeyFromObject(&imageSetCM),
)
return err
}
maps.Copy(r.images, imageSetCM.Data)
}
// If provided, load an imageset from driver spec overwrite default images
imageSetSpec = r.driver.Spec.ImageSet
if imageSetSpec != nil && imageSetSpec.Name != "" {
imageSetCM := corev1.ConfigMap{}
imageSetCM.Name = imageSetSpec.Name
imageSetCM.Namespace = r.driver.Namespace
if err := r.Get(r.ctx, client.ObjectKeyFromObject(&imageSetCM), &imageSetCM); err != nil {
r.log.Error(err, "Unable to load driver specified image set config map", "name", client.ObjectKeyFromObject(&imageSetCM))
r.log.Error(
err,
"Unable to load driver specified image set config map",
"name",
client.ObjectKeyFromObject(&imageSetCM),
)
return err
}

maps.Copy(r.images, imageSetCM.Data)
}

Expand Down Expand Up @@ -1369,9 +1391,6 @@ func mergeDriverSpecs(dest, src *csiv1a1.DriverSpec) {
if dest.Log == nil {
dest.Log = src.Log
}
if dest.ImageSet == nil {
dest.ImageSet = src.ImageSet
}
if dest.ClusterName == nil {
dest.ClusterName = src.ClusterName
}
Expand Down

0 comments on commit 281b79b

Please sign in to comment.