Skip to content

Commit

Permalink
Merge branch 'master' into spliting-controllers2
Browse files Browse the repository at this point in the history
  • Loading branch information
prashanth26 committed Jun 7, 2020
2 parents 9fd3513 + 4eff65a commit f13e506
Show file tree
Hide file tree
Showing 165 changed files with 2,136 additions and 1,432 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.28.0-dev
v0.30.0-dev
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/gardener/machine-controller-manager
go 1.13

require (
github.com/Azure/azure-sdk-for-go v39.0.0+incompatible
github.com/Azure/go-autorest/autorest v0.9.3
github.com/Azure/go-autorest/autorest/adal v0.8.0
github.com/Azure/azure-sdk-for-go v42.2.0+incompatible
github.com/Azure/go-autorest/autorest v0.10.1
github.com/Azure/go-autorest/autorest/adal v0.8.2
github.com/Azure/go-autorest/autorest/to v0.3.0
github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20180828111155-cad214d7d71f
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
github.com/Azure/azure-sdk-for-go v39.0.0+incompatible h1:l2FVXqtd34UC7OZYkhcWY843CSFjRdrIRdBCTOanYwg=
github.com/Azure/azure-sdk-for-go v39.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v42.2.0+incompatible h1:ezf8BQIvXYn+LSf+rDqOVyRG3bWkf/SXKYFz4zIBX1Q=
github.com/Azure/azure-sdk-for-go v42.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
github.com/Azure/go-autorest/autorest v0.9.3 h1:OZEIaBbMdUE/Js+BQKlpO81XlISgipr6yDJ+PSwsgi4=
github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0=
github.com/Azure/go-autorest/autorest v0.10.1 h1:uaB8A32IZU9YKs9v50+/LWIWTDHJk2vlGzbfd7FfESI=
github.com/Azure/go-autorest/autorest v0.10.1/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630=
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
github.com/Azure/go-autorest/autorest/adal v0.8.0 h1:CxTzQrySOxDnKpLjFJeZAS5Qrv/qFPkgLjx5bOAi//I=
github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc=
github.com/Azure/go-autorest/autorest/adal v0.8.2 h1:O1X4oexUxnZCaEUGsvMnr8ZGj8HI37tNezwY4npRqA0=
github.com/Azure/go-autorest/autorest/adal v0.8.2/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q=
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
github.com/Azure/go-autorest/autorest/date v0.2.0 h1:yW+Zlqf26583pE43KhfnhFcdmSWlm5Ew6bxipnr/tbM=
github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g=
Expand Down Expand Up @@ -145,6 +145,7 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down Expand Up @@ -191,6 +192,7 @@ github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/machine_classes/aws-machine-class.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ spec:
namespace: default # Namespace
name: test-secret # Name of the secret
blockDevices:
- name: /root
- deviceName: /root
ebs:
volumeSize: 50 # Size of the root block device
volumeType: gp2 # Type of the root block device
encrypted: false
deleteOnTermination: true
- name: /dev/sdb
- deviceName: /dev/sdb
ebs:
volumeSize: 50 # Size of the root block device
volumeType: gp2 # Type of the root block device
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/machine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,18 @@ type AWSEbsBlockDeviceSpec struct {
// it is not used in requests to create gp2, st1, sc1, or standard volumes.
Iops int64

// Identifier (key ID, key alias, ID ARN, or alias ARN) for a customer managed
// CMK under which the EBS volume is encrypted.
//
// This parameter is only supported on BlockDeviceMapping objects called by
// RunInstances (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html),
// RequestSpotFleet (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RequestSpotFleet.html),
// and RequestSpotInstances (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RequestSpotInstances.html).
KmsKeyID *string

// The ID of the snapshot.
SnapshotID *string

// The size of the volume, in GiB.
//
// Constraints: 1-16384 for General Purpose SSD (gp2), 4-16384 for Provisioned
Expand Down
14 changes: 13 additions & 1 deletion pkg/apis/machine/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,18 @@ type AWSEbsBlockDeviceSpec struct {
// it is not used in requests to create gp2, st1, sc1, or standard volumes.
Iops int64 `json:"iops,omitempty"`

// Identifier (key ID, key alias, ID ARN, or alias ARN) for a customer managed
// CMK under which the EBS volume is encrypted.
//
// This parameter is only supported on BlockDeviceMapping objects called by
// RunInstances (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html),
// RequestSpotFleet (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RequestSpotFleet.html),
// and RequestSpotInstances (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RequestSpotInstances.html).
KmsKeyID *string `json:"kmsKeyID,omitempty"`

// The ID of the snapshot.
SnapshotID *string `json:"snapshotID,omitempty"`

// The size of the volume, in GiB.
//
// Constraints: 1-16384 for General Purpose SSD (gp2), 4-16384 for Provisioned
Expand Down Expand Up @@ -998,7 +1010,7 @@ type AzureOSDisk struct {

type AzureDataDisk struct {
Name string `json:"name,omitempty"`
Lun *int32 `json:"lun,omitempty"`
Lun *int32 `json:"lun,omitempty"`
Caching string `json:"caching,omitempty"`
StorageAccountType string `json:"storageAccountType,omitempty"`
DiskSizeGB int32 `json:"diskSizeGB,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/machine/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/apis/machine/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/apis/machine/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/driver/driver_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (d *AWSDriver) generateBlockDevices(blockDevices []v1alpha1.AWSBlockDeviceM
volumeSize := disk.Ebs.VolumeSize
volumeType := disk.Ebs.VolumeType
encrypted := disk.Ebs.Encrypted
snapshotID := disk.Ebs.SnapshotID

blkDeviceMapping := ec2.BlockDeviceMapping{
DeviceName: aws.String(deviceName),
Expand All @@ -199,6 +200,10 @@ func (d *AWSDriver) generateBlockDevices(blockDevices []v1alpha1.AWSBlockDeviceM
if volumeType == "io1" {
blkDeviceMapping.Ebs.Iops = aws.Int64(disk.Ebs.Iops)
}

if snapshotID != nil {
blkDeviceMapping.Ebs.SnapshotId = snapshotID
}
blkDeviceMappings = append(blkDeviceMappings, &blkDeviceMapping)
}

Expand Down
91 changes: 88 additions & 3 deletions pkg/driver/driver_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
corev1 "k8s.io/api/core/v1"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-11-01/network"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-05-01/resources"

Expand Down Expand Up @@ -87,7 +88,7 @@ func (d *AzureDriver) getNICParameters(vmName string, subnet *network.Subnet) ne
return NICParameters
}

func (d *AzureDriver) getVMParameters(vmName string, networkInterfaceReferenceID string) compute.VirtualMachine {
func (d *AzureDriver) getVMParameters(vmName string, image compute.VirtualMachineImage, networkInterfaceReferenceID string) compute.VirtualMachine {

var (
diskName = dependencyNameFromVMName(vmName, diskSuffix)
Expand All @@ -103,8 +104,20 @@ func (d *AzureDriver) getVMParameters(vmName string, networkInterfaceReferenceID

imageReference := getImageReference(d)

var plan *compute.Plan
if image.Plan != nil {
// If image.Plan exists, create a plan object and attach it to the VM
klog.V(2).Infof("Creating a plan object and attaching it to the VM - %q", vmName)
plan = &compute.Plan{
Name: image.VirtualMachineImageProperties.Plan.Name,
Product: image.VirtualMachineImageProperties.Plan.Product,
Publisher: image.VirtualMachineImageProperties.Plan.Publisher,
}
}

VMParameters := compute.VirtualMachine{
Name: &vmName,
Plan: plan,
Location: &location,
VirtualMachineProperties: &compute.VirtualMachineProperties{
HardwareProfile: &compute.HardwareProfile{
Expand Down Expand Up @@ -368,6 +381,8 @@ type azureDriverClients struct {
vm compute.VirtualMachinesClient
disk compute.DisksClient
deployments resources.DeploymentsClient
images compute.VirtualMachineImagesClient
marketplace marketplaceordering.MarketplaceAgreementsClient
}

type azureTags map[string]string
Expand All @@ -394,13 +409,19 @@ func newClients(subscriptionID, tenantID, clientID, clientSecret string, env azu
vmClient := compute.NewVirtualMachinesClient(subscriptionID)
vmClient.Authorizer = authorizer

vmImagesClient := compute.NewVirtualMachineImagesClient(subscriptionID)
vmImagesClient.Authorizer = authorizer

diskClient := compute.NewDisksClient(subscriptionID)
diskClient.Authorizer = authorizer

deploymentsClient := resources.NewDeploymentsClient(subscriptionID)
deploymentsClient.Authorizer = authorizer

return &azureDriverClients{subnet: subnetClient, nic: interfacesClient, vm: vmClient, disk: diskClient, deployments: deploymentsClient}, nil
marketplaceClient := marketplaceordering.NewMarketplaceAgreementsClient(subscriptionID)
marketplaceClient.Authorizer = authorizer

return &azureDriverClients{subnet: subnetClient, nic: interfacesClient, vm: vmClient, disk: diskClient, deployments: deploymentsClient, images: vmImagesClient, marketplace: marketplaceClient}, nil
}

func (d *AzureDriver) createVMNicDisk() (*compute.VirtualMachine, error) {
Expand Down Expand Up @@ -495,8 +516,72 @@ func (d *AzureDriver) createVMNicDisk() (*compute.VirtualMachine, error) {
VM creation
*/

imageReference := getImageReference(d)
vmImage, err := clients.images.Get(
ctx,
d.AzureMachineClass.Spec.Location,
*imageReference.Publisher,
*imageReference.Offer,
*imageReference.Sku,
*imageReference.Version)

if err != nil {
//Since machine creation failed, delete any infra resources created
deleteErr := clients.deleteVMNicDisks(ctx, resourceGroupName, vmName, nicName, diskName, dataDiskNames)
if deleteErr != nil {
klog.Errorf("Error occurred during resource clean up: %s", deleteErr)
}

return nil, onARMAPIErrorFail(prometheusServiceVM, err, "VirtualMachineImagesClient.Get failed for %s", d.AzureMachineClass.Name)
}

if vmImage.Plan != nil {
// If VMImage.Plan exists, check if agreement is accepted and if not accept it for the subscription

agreement, err := clients.marketplace.Get(
ctx,
*vmImage.Plan.Publisher,
*vmImage.Plan.Product,
*vmImage.Plan.Name,
)

if err != nil {
//Since machine creation failed, delete any infra resources created
deleteErr := clients.deleteVMNicDisks(ctx, resourceGroupName, vmName, nicName, diskName, dataDiskNames)
if deleteErr != nil {
klog.Errorf("Error occurred during resource clean up: %s", deleteErr)
}

return nil, onARMAPIErrorFail(prometheusServiceVM, err, "MarketplaceAgreementsClient.Get failed for %s", d.AzureMachineClass.Name)
}

if agreement.Accepted == nil || *agreement.Accepted == false {
// Need to accept the terms at least once for the subscription
klog.V(2).Info("Accepting terms for subscription to make use of the plan")

agreement.Accepted = to.BoolPtr(true)
_, err = clients.marketplace.Create(
ctx,
*vmImage.Plan.Publisher,
*vmImage.Plan.Product,
*vmImage.Plan.Name,
agreement,
)

if err != nil {
//Since machine creation failed, delete any infra resources created
deleteErr := clients.deleteVMNicDisks(ctx, resourceGroupName, vmName, nicName, diskName, dataDiskNames)
if deleteErr != nil {
klog.Errorf("Error occurred during resource clean up: %s", deleteErr)
}

return nil, onARMAPIErrorFail(prometheusServiceVM, err, "MarketplaceAgreementsClient.Create failed for %s", d.AzureMachineClass.Name)
}
}
}

// Creating VMParameters for new VM creation request
VMParameters := d.getVMParameters(vmName, *NIC.ID)
VMParameters := d.getVMParameters(vmName, vmImage, *NIC.ID)

// VM creation request
VMFuture, err := clients.vm.CreateOrUpdate(ctx, resourceGroupName, *VMParameters.Name, VMParameters)
Expand Down
14 changes: 14 additions & 0 deletions pkg/openapi/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/Azure/azure-sdk-for-go/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f13e506

Please sign in to comment.