@@ -13,6 +13,10 @@ import (
1313 volumebrokerv1alpha1 "github.com/ironcore-dev/ironcore/broker/volumebroker/api/v1alpha1"
1414 "github.com/ironcore-dev/ironcore/broker/volumebroker/apiutils"
1515 iri "github.com/ironcore-dev/ironcore/iri/apis/volume/v1alpha1"
16+ poolletutils "github.com/ironcore-dev/ironcore/poollet/common/utils"
17+ volumepoolletv1alpha1 "github.com/ironcore-dev/ironcore/poollet/volumepoollet/api/v1alpha1"
18+
19+ "github.com/ironcore-dev/ironcore/utils/maps"
1620 corev1 "k8s.io/api/core/v1"
1721 "k8s.io/apimachinery/pkg/api/resource"
1822 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -25,6 +29,22 @@ type AggregateIronCoreVolume struct {
2529 AccessSecret * corev1.Secret
2630}
2731
32+ func (s * Server ) prepareIronCoreVolumeLabels (volume * iri.Volume ) map [string ]string {
33+ labels := make (map [string ]string )
34+
35+ for downwardAPILabelName , defaultLabelName := range s .brokerDownwardAPILabels {
36+ value := volume .GetMetadata ().GetLabels ()[poolletutils .DownwardAPILabel (volumepoolletv1alpha1 .VolumeDownwardAPIPrefix , downwardAPILabelName )]
37+ if value == "" {
38+ value = volume .GetMetadata ().GetLabels ()[defaultLabelName ]
39+ }
40+ if value != "" {
41+ labels [poolletutils .DownwardAPILabel (volumepoolletv1alpha1 .VolumeDownwardAPIPrefix , downwardAPILabelName )] = value
42+ }
43+ }
44+
45+ return labels
46+ }
47+
2848func (s * Server ) getIronCoreVolumeConfig (_ context.Context , volume * iri.Volume ) (* AggregateIronCoreVolume , error ) {
2949 var volumePoolRef * corev1.LocalObjectReference
3050 if s .volumePoolName != "" {
@@ -55,10 +75,15 @@ func (s *Server) getIronCoreVolumeConfig(_ context.Context, volume *iri.Volume)
5575 }
5676 }
5777
78+ labels := s .prepareIronCoreVolumeLabels (volume )
79+
5880 ironcoreVolume := & storagev1alpha1.Volume {
5981 ObjectMeta : metav1.ObjectMeta {
6082 Namespace : s .namespace ,
6183 Name : s .idGen .Generate (),
84+ Labels : maps .AppendMap (labels , map [string ]string {
85+ volumebrokerv1alpha1 .ManagerLabel : volumebrokerv1alpha1 .VolumeBrokerManager ,
86+ }),
6287 },
6388 Spec : storagev1alpha1.VolumeSpec {
6489 VolumeClassRef : & corev1.LocalObjectReference {Name : volume .Spec .Class },
@@ -75,7 +100,6 @@ func (s *Server) getIronCoreVolumeConfig(_ context.Context, volume *iri.Volume)
75100 if err := apiutils .SetObjectMetadata (ironcoreVolume , volume .Metadata ); err != nil {
76101 return nil , err
77102 }
78- apiutils .SetVolumeManagerLabel (ironcoreVolume , volumebrokerv1alpha1 .VolumeBrokerManager )
79103
80104 return & AggregateIronCoreVolume {
81105 Volume : ironcoreVolume ,
0 commit comments