From 9fac6c2371278561a7cfa8f3b254a7008a09b01b Mon Sep 17 00:00:00 2001 From: MayankKakani <110008140+MayankKakani@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:45:16 +0530 Subject: [PATCH 01/12] updated tilt-helper 1.updated tilt image golang version to 1.21.8 2.added bash to kustomize-sub.sh call Signed-off-by: Mayank Kakani --- Tiltfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tiltfile b/Tiltfile index 36c781af1..b1668e086 100644 --- a/Tiltfile +++ b/Tiltfile @@ -41,7 +41,7 @@ if "default_registry" in settings: tilt_helper_dockerfile_header = """ # Tilt image -FROM golang:1.19 as tilt-helper +FROM golang:1.21.8 as tilt-helper # Support live reloading with Tilt RUN go install github.com/go-delve/delve/cmd/dlv@latest RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com/tilt-dev/rerun-process-wrapper/master/restart.sh && \ @@ -196,7 +196,7 @@ def base64_decode(to_decode): return str(decode_blob) def kustomizesub(folder): - yaml = local('hack/kustomize-sub.sh {}'.format(folder), quiet=True) + yaml = local('bash hack/kustomize-sub.sh {}'.format(folder), quiet=True) return yaml ############################## @@ -216,4 +216,4 @@ deploy_capi() capoci() -waitforsystem() \ No newline at end of file +waitforsystem() From 6f6780535e16dc4aecf075579e4bf8c2e6b978b7 Mon Sep 17 00:00:00 2001 From: MayankKakani <110008140+MayankKakani@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:46:40 +0530 Subject: [PATCH 02/12] Update types.go Added LaunchParavirtualizedVolumeAttachment types to v1 --- api/v1beta1/types.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index 66305fdf9..34ba2ec4a 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -1098,6 +1098,7 @@ type VolumeType string const ( IscsiType VolumeType = "iscsi" + ParavirtualizedType VolumeType = "paravirtualized" ) // EncryptionInTransitTypeEnum Enum with underlying type: string @@ -1115,6 +1116,7 @@ type LaunchVolumeAttachment struct { // The details of iscsi volume attachment. IscsiAttachment LaunchIscsiVolumeAttachment `json:"launchIscsiVolumeAttachment,omitempty"` + ParavirtualizedAttachment LaunchParavirtualizedVolumeAttachment `json:"launchParavirtualizedVolumeAttachment,omitempty"` } // LaunchIscsiVolumeAttachment specifies the iscsi volume attachments to create as part of the launch instance operation. @@ -1152,6 +1154,35 @@ type LaunchIscsiVolumeAttachment struct { EncryptionInTransitType EncryptionInTransitTypeEnum `json:"encryptionInTransitType,omitempty"` } +// LaunchParavirtualizedVolumeAttachment specifies the paravirtualized volume attachments to create as part of the launch instance operation. +type LaunchParavirtualizedVolumeAttachment struct { + // The device name. To retrieve a list of devices for a given instance, see ListInstanceDevices. + Device *string `json:"device,omitempty"` + + // A user-friendly name. Does not have to be unique, and it's changeable. + // Avoid entering confidential information. + DisplayName *string `json:"displayName,omitempty"` + + // Whether the attachment was created in read-only mode. + IsReadOnly *bool `json:"isReadOnly,omitempty"` + + // Whether the attachment should be created in shareable mode. If an attachment + // is created in shareable mode, then other instances can attach the same volume, provided + // that they also create their attachments in shareable mode. Only certain volume types can + // be attached in shareable mode. Defaults to false if not specified. + IsShareable *bool `json:"isShareable,omitempty"` + + // The OCID of the volume. If CreateVolumeDetails is specified, this field must be omitted from the request. + VolumeId *string `json:"volumeId,omitempty"` + + // LaunchCreateVolumeFromAttributes The details of the volume to create for CreateVolume operation. + LaunchCreateVolumeFromAttributes LaunchCreateVolumeFromAttributes `json:"launchCreateVolumeFromAttributes,omitempty"` + + // Refer the top-level definition of isPvEncryptionInTransitEnabled. + // The default value is False. + IsPvEncryptionInTransitEnabled *bool `json:"isPvEncryptionInTransitEnabled,omitempty"` +} + // LaunchCreateVolumeFromAttributes The details of the volume to create for CreateVolume operation. type LaunchCreateVolumeFromAttributes struct { From f14856aa93be31dd6c70bd5671702a8cdab83394 Mon Sep 17 00:00:00 2001 From: MayankKakani <110008140+MayankKakani@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:47:39 +0530 Subject: [PATCH 03/12] Update types.go added LaunchParavirtualizedVolumeAttachment type --- api/v1beta2/types.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/api/v1beta2/types.go b/api/v1beta2/types.go index a61c98dcd..d56fa45c0 100644 --- a/api/v1beta2/types.go +++ b/api/v1beta2/types.go @@ -1168,6 +1168,7 @@ type VolumeType string const ( IscsiType VolumeType = "iscsi" + ParavirtualizedType VolumeType = "paravirtualized" ) // EncryptionInTransitTypeEnum Enum with underlying type: string @@ -1186,6 +1187,7 @@ type LaunchVolumeAttachment struct { // The details of iscsi volume attachment. IscsiAttachment LaunchIscsiVolumeAttachment `json:"launchIscsiVolumeAttachment,omitempty"` + ParavirtualizedAttachment LaunchParavirtualizedVolumeAttachment `json:"launchParavirtualizedVolumeAttachment,omitempty"` } // LaunchIscsiVolumeAttachment specifies the iscsi volume attachments to create as part of the launch instance operation. @@ -1223,6 +1225,36 @@ type LaunchIscsiVolumeAttachment struct { EncryptionInTransitType EncryptionInTransitTypeEnum `json:"encryptionInTransitType,omitempty"` } +// LaunchParavirtualizedVolumeAttachment specifies the paravirtualized volume attachments to create as part of the launch instance operation. +type LaunchParavirtualizedVolumeAttachment struct { + // The device name. To retrieve a list of devices for a given instance, see ListInstanceDevices. + Device *string `json:"device,omitempty"` + + // A user-friendly name. Does not have to be unique, and it's changeable. + // Avoid entering confidential information. + DisplayName *string `json:"displayName,omitempty"` + + // Whether the attachment was created in read-only mode. + IsReadOnly *bool `json:"isReadOnly,omitempty"` + + // Whether the attachment should be created in shareable mode. If an attachment + // is created in shareable mode, then other instances can attach the same volume, provided + // that they also create their attachments in shareable mode. Only certain volume types can + // be attached in shareable mode. Defaults to false if not specified. + IsShareable *bool `json:"isShareable,omitempty"` + + // The OCID of the volume. If CreateVolumeDetails is specified, this field must be omitted from the request. + VolumeId *string `json:"volumeId,omitempty"` + + // LaunchCreateVolumeFromAttributes The details of the volume to create for CreateVolume operation. + LaunchCreateVolumeFromAttributes LaunchCreateVolumeFromAttributes `json:"launchCreateVolumeFromAttributes,omitempty"` + + // Refer the top-level definition of encryptionInTransitType. + // The default value is False. + IsPvEncryptionInTransitEnabled *bool `json:"isPvEncryptionInTransitEnabled,omitempty"` +} + + // LaunchCreateVolumeFromAttributes The details of the volume to create for CreateVolume operation. type LaunchCreateVolumeFromAttributes struct { From 51c73b70170eb40993a1734442345971dd3f407b Mon Sep 17 00:00:00 2001 From: MayankKakani <110008140+MayankKakani@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:48:18 +0530 Subject: [PATCH 04/12] Update machine.go Added support for getParavirtualizedVolumeAttachment --- cloud/scope/machine.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cloud/scope/machine.go b/cloud/scope/machine.go index ff3622bb4..a236ee3b3 100644 --- a/cloud/scope/machine.go +++ b/cloud/scope/machine.go @@ -997,6 +997,10 @@ func (m *MachineScope) getLaunchVolumeAttachments() []core.LaunchAttachVolumeDet for _, attachment := range volumeAttachmentsInSpec { if attachment.Type == infrastructurev1beta2.IscsiType { volumes = append(volumes, getIscsiVolumeAttachment(attachment.IscsiAttachment)) + } else if attachment.Type == infrastructurev1beta2.ParavirtualizedType { + volumes = append(volumes, getParavirtualizedVolumeAttachment(attachment.ParavirtualizedAttachment)) + } else { + m.Logger.Info("Block Volume attachment type not supported") } } return volumes @@ -1017,6 +1021,19 @@ func getIscsiVolumeAttachment(attachment infrastructurev1beta2.LaunchIscsiVolume return volumeDetails } +func getParavirtualizedVolumeAttachment(attachment infrastructurev1beta2.LaunchParavirtualizedVolumeAttachment) core.LaunchAttachVolumeDetails { + volumeDetails := core.LaunchAttachParavirtualizedVolumeDetails{ + Device: attachment.Device, + DisplayName: attachment.DisplayName, + IsShareable: attachment.IsShareable, + IsReadOnly: attachment.IsReadOnly, + VolumeId: attachment.VolumeId, + IsPvEncryptionInTransitEnabled: attachment.IsPvEncryptionInTransitEnabled, + LaunchCreateVolumeDetails: getLaunchCreateVolumeDetails(attachment.LaunchCreateVolumeFromAttributes), + } + return volumeDetails +} + func getLaunchCreateVolumeDetails(attributes infrastructurev1beta2.LaunchCreateVolumeFromAttributes) core.LaunchCreateVolumeFromAttributes { return core.LaunchCreateVolumeFromAttributes{ SizeInGBs: attributes.SizeInGBs, From d80fba18fb288b562d1d2d36620731f835e239df Mon Sep 17 00:00:00 2001 From: MayankKakani <110008140+MayankKakani@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:50:28 +0530 Subject: [PATCH 05/12] Update infrastructure.cluster.x-k8s.io_ocimachines.yaml added launchParavirtualizedVolumeAttachment defination --- ...tructure.cluster.x-k8s.io_ocimachines.yaml | 134 +++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachines.yaml index daddc19a9..355900ba0 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachines.yaml @@ -328,8 +328,74 @@ spec: is specified, this field must be omitted from the request. type: string type: object + launchParavirtualizedVolumeAttachment: + description: The details of paravirtualized volume attachment. + properties: + device: + description: The device name. To retrieve a list of devices + for a given instance, see ListInstanceDevices. + type: string + displayName: + description: A user-friendly name. Does not have to be unique, + and it's changeable. Avoid entering confidential information. + type: string + isPvEncryptionInTransitEnabled: + description: Refer the top-level definition of isPvEncryptionInTransitEnabled. + The default value is False. + type: boolean + isReadOnly: + description: Whether the attachment was created in read-only + mode. + type: boolean + isShareable: + description: Whether the attachment should be created in + shareable mode. If an attachment is created in shareable + mode, then other instances can attach the same volume, + provided that they also create their attachments in shareable + mode. Only certain volume types can be attached in shareable + mode. Defaults to false if not specified. + type: boolean + launchCreateVolumeFromAttributes: + description: LaunchCreateVolumeFromAttributes The details + of the volume to create for CreateVolume operation. + properties: + compartmentId: + description: The OCID of the compartment that contains + the volume. If not provided, it will be inherited + from the instance. + type: string + displayName: + description: A user-friendly name. Does not have to + be unique, and it's changeable. Avoid entering confidential + information. + type: string + kmsKeyId: + description: The OCID of the Vault service key to assign + as the master encryption key for the volume. + type: string + sizeInGBs: + description: The size of the volume in GBs. + format: int64 + type: integer + vpusPerGB: + description: 'The number of volume performance units + (VPUs) that will be applied to this volume per GB, + representing the Block Volume service''s elastic performance + options. See Block Volume Performance Levels (https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/blockvolumeperformance.htm#perf_levels) + for more information. Allowed values: * `0`: Represents + Lower Cost option. * `10`: Represents Balanced option. + * `20`: Represents Higher Performance option. * `30`-`120`: + Represents the Ultra High Performance option.' + format: int64 + type: integer + type: object + volumeId: + description: The OCID of the volume. If CreateVolumeDetails + is specified, this field must be omitted from the request. + type: string + type: object volumeType: - description: The type of volume. Valid value is iscsi. + description: The type of volume. Valid value is iscsi/paravirtualized. type: string type: object type: array @@ -1199,6 +1265,72 @@ spec: is specified, this field must be omitted from the request. type: string type: object + launchParavirtualizedVolumeAttachment: + description: The details of paravirtualized volume attachment. + properties: + device: + description: The device name. To retrieve a list of devices + for a given instance, see ListInstanceDevices. + type: string + displayName: + description: A user-friendly name. Does not have to be unique, + and it's changeable. Avoid entering confidential information. + type: string + isPvEncryptionInTransitEnabled: + description: Refer the top-level definition of isPvEncryptionInTransitEnabled. + The default value is False. + type: boolean + isReadOnly: + description: Whether the attachment was created in read-only + mode. + type: boolean + isShareable: + description: Whether the attachment should be created in + shareable mode. If an attachment is created in shareable + mode, then other instances can attach the same volume, + provided that they also create their attachments in shareable + mode. Only certain volume types can be attached in shareable + mode. Defaults to false if not specified. + type: boolean + launchCreateVolumeFromAttributes: + description: LaunchCreateVolumeFromAttributes The details + of the volume to create for CreateVolume operation. + properties: + compartmentId: + description: The OCID of the compartment that contains + the volume. If not provided, it will be inherited + from the instance. + type: string + displayName: + description: A user-friendly name. Does not have to + be unique, and it's changeable. Avoid entering confidential + information. + type: string + kmsKeyId: + description: The OCID of the Vault service key to assign + as the master encryption key for the volume. + type: string + sizeInGBs: + description: The size of the volume in GBs. + format: int64 + type: integer + vpusPerGB: + description: 'The number of volume performance units + (VPUs) that will be applied to this volume per GB, + representing the Block Volume service''s elastic performance + options. See Block Volume Performance Levels (https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/blockvolumeperformance.htm#perf_levels) + for more information. Allowed values: * `0`: Represents + Lower Cost option. * `10`: Represents Balanced option. + * `20`: Represents Higher Performance option. * `30`-`120`: + Represents the Ultra High Performance option.' + format: int64 + type: integer + type: object + volumeId: + description: The OCID of the volume. If CreateVolumeDetails + is specified, this field must be omitted from the request. + type: string + type: object volumeType: description: The type of volume. Valid value is iscsi. type: string From ebbd6f8b746c01c067198f6b9e50806ea8c189f5 Mon Sep 17 00:00:00 2001 From: MayankKakani <110008140+MayankKakani@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:51:00 +0530 Subject: [PATCH 06/12] Update infrastructure.cluster.x-k8s.io_ocimachinetemplates.yaml added launchParavirtualizedVolumeAttachment definations --- ....cluster.x-k8s.io_ocimachinetemplates.yaml | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinetemplates.yaml index 3f209fac7..c30dd3909 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinetemplates.yaml @@ -362,6 +362,72 @@ spec: the request. type: string type: object + launchParavirtualizedVolumeAttachment: + description: The details of paravirtualized volume attachment. + properties: + device: + description: The device name. To retrieve a list of devices + for a given instance, see ListInstanceDevices. + type: string + displayName: + description: A user-friendly name. Does not have to be unique, + and it's changeable. Avoid entering confidential information. + type: string + isPvEncryptionInTransitEnabled: + description: Refer the top-level definition of isPvEncryptionInTransitEnabled. + The default value is False. + type: boolean + isReadOnly: + description: Whether the attachment was created in read-only + mode. + type: boolean + isShareable: + description: Whether the attachment should be created in + shareable mode. If an attachment is created in shareable + mode, then other instances can attach the same volume, + provided that they also create their attachments in shareable + mode. Only certain volume types can be attached in shareable + mode. Defaults to false if not specified. + type: boolean + launchCreateVolumeFromAttributes: + description: LaunchCreateVolumeFromAttributes The details + of the volume to create for CreateVolume operation. + properties: + compartmentId: + description: The OCID of the compartment that contains + the volume. If not provided, it will be inherited + from the instance. + type: string + displayName: + description: A user-friendly name. Does not have to + be unique, and it's changeable. Avoid entering confidential + information. + type: string + kmsKeyId: + description: The OCID of the Vault service key to assign + as the master encryption key for the volume. + type: string + sizeInGBs: + description: The size of the volume in GBs. + format: int64 + type: integer + vpusPerGB: + description: 'The number of volume performance units + (VPUs) that will be applied to this volume per GB, + representing the Block Volume service''s elastic performance + options. See Block Volume Performance Levels (https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/blockvolumeperformance.htm#perf_levels) + for more information. Allowed values: * `0`: Represents + Lower Cost option. * `10`: Represents Balanced option. + * `20`: Represents Higher Performance option. * `30`-`120`: + Represents the Ultra High Performance option.' + format: int64 + type: integer + type: object + volumeId: + description: The OCID of the volume. If CreateVolumeDetails + is specified, this field must be omitted from the request. + type: string + type: object volumeType: description: The type of volume. Valid value is iscsi. type: string @@ -1223,6 +1289,72 @@ spec: the request. type: string type: object + launchParavirtualizedVolumeAttachment: + description: The details of paravirtualized volume attachment. + properties: + device: + description: The device name. To retrieve a list of devices + for a given instance, see ListInstanceDevices. + type: string + displayName: + description: A user-friendly name. Does not have to be unique, + and it's changeable. Avoid entering confidential information. + type: string + isPvEncryptionInTransitEnabled: + description: Refer the top-level definition of isPvEncryptionInTransitEnabled. + The default value is False. + type: boolean + isReadOnly: + description: Whether the attachment was created in read-only + mode. + type: boolean + isShareable: + description: Whether the attachment should be created in + shareable mode. If an attachment is created in shareable + mode, then other instances can attach the same volume, + provided that they also create their attachments in shareable + mode. Only certain volume types can be attached in shareable + mode. Defaults to false if not specified. + type: boolean + launchCreateVolumeFromAttributes: + description: LaunchCreateVolumeFromAttributes The details + of the volume to create for CreateVolume operation. + properties: + compartmentId: + description: The OCID of the compartment that contains + the volume. If not provided, it will be inherited + from the instance. + type: string + displayName: + description: A user-friendly name. Does not have to + be unique, and it's changeable. Avoid entering confidential + information. + type: string + kmsKeyId: + description: The OCID of the Vault service key to assign + as the master encryption key for the volume. + type: string + sizeInGBs: + description: The size of the volume in GBs. + format: int64 + type: integer + vpusPerGB: + description: 'The number of volume performance units + (VPUs) that will be applied to this volume per GB, + representing the Block Volume service''s elastic performance + options. See Block Volume Performance Levels (https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/blockvolumeperformance.htm#perf_levels) + for more information. Allowed values: * `0`: Represents + Lower Cost option. * `10`: Represents Balanced option. + * `20`: Represents Higher Performance option. * `30`-`120`: + Represents the Ultra High Performance option.' + format: int64 + type: integer + type: object + volumeId: + description: The OCID of the volume. If CreateVolumeDetails + is specified, this field must be omitted from the request. + type: string + type: object volumeType: description: The type of volume. Valid value is iscsi. type: string From 8768b8b382db2be1208a635a5b807fefe5bbfa63 Mon Sep 17 00:00:00 2001 From: MayankKakani <110008140+MayankKakani@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:52:16 +0530 Subject: [PATCH 07/12] Update go.mod Updated OCI go sdk version to v65.81.1 to support paravirtualized volume --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b226ea485..6cb340fb2 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/google/gofuzz v1.2.0 github.com/onsi/ginkgo/v2 v2.17.1 github.com/onsi/gomega v1.32.0 - github.com/oracle/oci-go-sdk/v65 v65.70.0 + github.com/oracle/oci-go-sdk/v65 v65.81.1 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.18.0 github.com/spf13/pflag v1.0.5 From 03e005dac2d11234d1940cfe198c9753a1485b7f Mon Sep 17 00:00:00 2001 From: MayankKakani <110008140+MayankKakani@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:52:48 +0530 Subject: [PATCH 08/12] Update go.sum Updated OCI SDK version --- go.sum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index b90c31fae..0ce4af22b 100644 --- a/go.sum +++ b/go.sum @@ -199,8 +199,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/oracle/oci-go-sdk/v65 v65.70.0 h1:gLa0IX/SidTm60VbHabnImrW3hyymmNLQJy6gZGrgDA= -github.com/oracle/oci-go-sdk/v65 v65.70.0/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= +github.com/oracle/oci-go-sdk/v65 v65.81.1 h1:JYc47bk8n/MUchA2KHu1ggsCQzlJZQLJ+tTKfOho00E= +github.com/oracle/oci-go-sdk/v65 v65.81.1/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= From 6f31072e653ee2e18b4f0a00e22a983b354a5937 Mon Sep 17 00:00:00 2001 From: MayankKakani <110008140+MayankKakani@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:56:38 +0530 Subject: [PATCH 09/12] Update machine_test.go added test for paravirtualized volumes --- cloud/scope/machine_test.go | 96 +++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/cloud/scope/machine_test.go b/cloud/scope/machine_test.go index 7c1f5f116..8c2526781 100644 --- a/cloud/scope/machine_test.go +++ b/cloud/scope/machine_test.go @@ -551,6 +551,102 @@ func TestInstanceReconciliation(t *testing.T) { OpcRetryToken: ociutil.GetOPCRetryToken("machineuid")})).Return(core.LaunchInstanceResponse{}, nil) }, }, + { + name: "check all params together, with subnet id set, nsg id list", + errorExpected: false, + testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) { + setupAllParams(ms) + ms.OCIMachine.Spec.CapacityReservationId = common.String("cap-id") + ms.OCIMachine.Spec.DedicatedVmHostId = common.String("dedicated-host-id") + ms.OCIMachine.Spec.NetworkDetails.HostnameLabel = common.String("hostname-label") + ms.OCIMachine.Spec.NetworkDetails.SubnetId = common.String("subnet-machine-id") + ms.OCIMachine.Spec.NetworkDetails.NSGIds = []string{"nsg-machine-id-1", "nsg-machine-id-2"} + // above array should take precedence + ms.OCIMachine.Spec.NetworkDetails.NSGId = common.String("nsg-machine-id") + ms.OCIMachine.Spec.NetworkDetails.SkipSourceDestCheck = common.Bool(true) + ms.OCIMachine.Spec.NetworkDetails.AssignPrivateDnsRecord = common.Bool(true) + ms.OCIMachine.Spec.NetworkDetails.DisplayName = common.String("display-name") + ms.OCIMachine.Spec.LaunchVolumeAttachment = []infrastructurev1beta2.LaunchVolumeAttachment{ + { + Type: infrastructurev1beta2.IscsiType, + IscsiAttachment: infrastructurev1beta2.LaunchIscsiVolumeAttachment{ + Device: common.String("/dev/oci"), + IsShareable: common.Bool(true), + LaunchCreateVolumeFromAttributes: infrastructurev1beta2.LaunchCreateVolumeFromAttributes{ + DisplayName: common.String("test-volume"), + SizeInGBs: common.Int64(75), + VpusPerGB: common.Int64(20), + }, + }, + }, + } + ms.OCIMachine.Spec.InstanceSourceViaImageDetails = &infrastructurev1beta2.InstanceSourceViaImageConfig{ + KmsKeyId: common.String("kms-key-id"), + BootVolumeVpusPerGB: common.Int64(32), + } + computeClient.EXPECT().ListInstances(gomock.Any(), gomock.Eq(core.ListInstancesRequest{ + DisplayName: common.String("name"), + CompartmentId: common.String("test"), + })).Return(core.ListInstancesResponse{}, nil) + + launchDetails := core.LaunchInstanceDetails{DisplayName: common.String("name"), + CapacityReservationId: common.String("cap-id"), + DedicatedVmHostId: common.String("dedicated-host-id"), + SourceDetails: core.InstanceSourceViaImageDetails{ + ImageId: common.String("image"), + BootVolumeSizeInGBs: common.Int64(120), + KmsKeyId: common.String("kms-key-id"), + BootVolumeVpusPerGB: common.Int64(32), + }, + CreateVnicDetails: &core.CreateVnicDetails{ + SubnetId: common.String("subnet-machine-id"), + AssignPublicIp: common.Bool(false), + DefinedTags: map[string]map[string]interface{}{}, + FreeformTags: map[string]string{ + ociutil.CreatedBy: ociutil.OCIClusterAPIProvider, + ociutil.ClusterResourceIdentifier: "resource_uid", + }, + NsgIds: []string{"nsg-machine-id-1", "nsg-machine-id-2"}, + HostnameLabel: common.String("hostname-label"), + SkipSourceDestCheck: common.Bool(true), + AssignPrivateDnsRecord: common.Bool(true), + DisplayName: common.String("display-name"), + }, + LaunchVolumeAttachments: []core.LaunchAttachVolumeDetails{ + core.LaunchAttachParavirtualizedVolumeDetails{ + Device: common.String("/dev/oci"), + IsShareable: common.Bool(true), + IsPvEncryptionInTransitEnabled: common.Bool(false), + LaunchCreateVolumeDetails: core.LaunchCreateVolumeFromAttributes{ + DisplayName: common.String("test-volume"), + SizeInGBs: common.Int64(75), + VpusPerGB: common.Int64(20), + }, + }, + }, + Metadata: map[string]string{ + "user_data": base64.StdEncoding.EncodeToString([]byte("test")), + }, + Shape: common.String("shape"), + ShapeConfig: &core.LaunchInstanceShapeConfigDetails{ + Ocpus: common.Float32(2), + MemoryInGBs: common.Float32(100), + BaselineOcpuUtilization: core.LaunchInstanceShapeConfigDetailsBaselineOcpuUtilization8, + }, + AvailabilityDomain: common.String("ad2"), + CompartmentId: common.String("test"), + IsPvEncryptionInTransitEnabled: common.Bool(true), + DefinedTags: map[string]map[string]interface{}{}, + FreeformTags: map[string]string{ + ociutil.CreatedBy: ociutil.OCIClusterAPIProvider, + ociutil.ClusterResourceIdentifier: "resource_uid", + }, + } + computeClient.EXPECT().LaunchInstance(gomock.Any(), gomock.Eq(core.LaunchInstanceRequest{ + LaunchInstanceDetails: launchDetails, + OpcRetryToken: ociutil.GetOPCRetryToken("machineuid")})).Return(core.LaunchInstanceResponse{}, nil) + }, + }, { name: "shape config is empty", errorExpected: false, From 1717a0dd93621bb4fdc2ea975b5298198edaf556 Mon Sep 17 00:00:00 2001 From: Mayank Kakani <110008140+MayankKakani@users.noreply.github.com> Date: Mon, 10 Feb 2025 22:43:20 +0530 Subject: [PATCH 10/12] Update machine.go updated message "Unknown attachment type not supported" --- cloud/scope/machine.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/scope/machine.go b/cloud/scope/machine.go index a236ee3b3..6b952b79d 100644 --- a/cloud/scope/machine.go +++ b/cloud/scope/machine.go @@ -1000,7 +1000,7 @@ func (m *MachineScope) getLaunchVolumeAttachments() []core.LaunchAttachVolumeDet } else if attachment.Type == infrastructurev1beta2.ParavirtualizedType { volumes = append(volumes, getParavirtualizedVolumeAttachment(attachment.ParavirtualizedAttachment)) } else { - m.Logger.Info("Block Volume attachment type not supported") + m.Logger.Info("Unknown attachment type not supported") } } return volumes From f5261bd70d5c7aab18577f8fbfe968540c4edc8e Mon Sep 17 00:00:00 2001 From: Mayank Kakani <110008140+MayankKakani@users.noreply.github.com> Date: Mon, 10 Feb 2025 22:45:31 +0530 Subject: [PATCH 11/12] Update machine_test.go updated name - "check all params together, with paravirtualized volume support" --- cloud/scope/machine_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/scope/machine_test.go b/cloud/scope/machine_test.go index 8c2526781..af13acc46 100644 --- a/cloud/scope/machine_test.go +++ b/cloud/scope/machine_test.go @@ -552,7 +552,7 @@ func TestInstanceReconciliation(t *testing.T) { }, }, { - name: "check all params together, with subnet id set, nsg id list", + name: "check all params together, with paravirtualized volume support", errorExpected: false, testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) { setupAllParams(ms) From c63969daae09a67e56acbf867684bbde7195ea1e Mon Sep 17 00:00:00 2001 From: Mayank Kakani <110008140+MayankKakani@users.noreply.github.com> Date: Mon, 17 Feb 2025 16:46:45 +0530 Subject: [PATCH 12/12] Fixed unittests Fixed paravirtualized volume support unit test case --- cloud/scope/machine_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cloud/scope/machine_test.go b/cloud/scope/machine_test.go index af13acc46..74e9d9b5d 100644 --- a/cloud/scope/machine_test.go +++ b/cloud/scope/machine_test.go @@ -568,10 +568,11 @@ func TestInstanceReconciliation(t *testing.T) { ms.OCIMachine.Spec.NetworkDetails.DisplayName = common.String("display-name") ms.OCIMachine.Spec.LaunchVolumeAttachment = []infrastructurev1beta2.LaunchVolumeAttachment{ { - Type: infrastructurev1beta2.IscsiType, - IscsiAttachment: infrastructurev1beta2.LaunchIscsiVolumeAttachment{ + Type: infrastructurev1beta2.ParavirtualizedType, + ParavirtualizedAttachment: infrastructurev1beta2.LaunchParavirtualizedVolumeAttachment{ Device: common.String("/dev/oci"), IsShareable: common.Bool(true), + IsPvEncryptionInTransitEnabled: common.Bool(false), LaunchCreateVolumeFromAttributes: infrastructurev1beta2.LaunchCreateVolumeFromAttributes{ DisplayName: common.String("test-volume"), SizeInGBs: common.Int64(75),