Skip to content

Commit

Permalink
Merge pull request openshift#4509 from nunnatsa/dv-label
Browse files Browse the repository at this point in the history
CNV-42532: KubeVirt: add label to DataVolume
  • Loading branch information
openshift-merge-bot[bot] authored Aug 9, 2024
2 parents 3a5ee81 + b133e0f commit 7d8f103
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions api/hypershift/v1beta1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ const (
// This annotation signals to the NodePool controller that it is safe to use TopologySpreadConstraints on a NodePool
// without triggering an unexpected update of KubeVirt VMs.
NodePoolSupportsKubevirtTopologySpreadConstraintsAnnotation = "hypershift.openshift.io/nodepool-supports-kubevirt-topology-spread-constraints"

// IsKubeVirtRHCOSVolumeLabelName labels rhcos DataVolumes and PVCs, to be able to filter them, e.g. for backup
IsKubeVirtRHCOSVolumeLabelName = "hypershift.openshift.io/is-kubevirt-rhcos"
)

// HostedClusterSpec is the desired behavior of a HostedCluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@ func (qi *cachedBootImage) buildDVForCache(nodePool *hyperv1.NodePool, uid strin
GenerateName: bootImageNamePrefix,
Namespace: qi.namespace,
Labels: map[string]string{
bootImageDVLabelRoleName: bootImageDVLabelRoleValue,
bootImageDVLabelUID: uid,
bootImageDVLabelRoleName: bootImageDVLabelRoleValue,
bootImageDVLabelUID: uid,
hyperv1.IsKubeVirtRHCOSVolumeLabelName: "true",
},
Annotations: map[string]string{
bootImageDVAnnotationHash: qi.hash,
Expand Down
3 changes: 3 additions & 0 deletions hypershift-operator/controllers/nodepool/kubevirt/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ func virtualMachineTemplateBase(nodePool *hyperv1.NodePool, bootImage BootImage)
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
Name: rootVolumeName,
Labels: map[string]string{
hyperv1.IsKubeVirtRHCOSVolumeLabelName: "true",
},
},
Spec: v1beta1.DataVolumeSpec{
Source: dvSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/go-logr/zapr"
"github.com/google/go-cmp/cmp"
. "github.com/onsi/gomega"
suppconfig "github.com/openshift/hypershift/support/config"
"go.uber.org/zap/zaptest"
corev1 "k8s.io/api/core/v1"
apiresource "k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -24,6 +23,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/fake"

hyperv1 "github.com/openshift/hypershift/api/hypershift/v1beta1"
suppconfig "github.com/openshift/hypershift/support/config"
)

const (
Expand Down Expand Up @@ -1328,6 +1328,9 @@ func generateNodeTemplate(options ...nodeTemplateOption) *capikubevirt.VirtualMa
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
Name: "rhcos",
Labels: map[string]string{
hyperv1.IsKubeVirtRHCOSVolumeLabelName: "true",
},
},
Spec: v1beta1.DataVolumeSpec{
Source: &v1beta1.DataVolumeSource{
Expand Down

0 comments on commit 7d8f103

Please sign in to comment.