Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

platform/azure: add kola/ore commands for Azure #771

Merged
merged 11 commits into from Jul 11, 2019

Conversation

arithx
Copy link
Contributor

@arithx arithx commented Nov 29, 2017

Add support for Azure to kola and add additional ore commands utilizing the ARM API.

@arithx arithx changed the title platform/azure: add kola/ore commands for Azure WIP: platform/azure: add kola/ore commands for Azure Nov 29, 2017
@arithx
Copy link
Contributor Author

arithx commented Nov 29, 2017

Marking WIP until I can perform additional testing (have been hitting an error HTTP_1_1_REQUIRED when creating subnets the past few days)

@arithx arithx force-pushed the kola-azure branch 2 times, most recently from de84589 to 4b02752 Compare November 29, 2017 18:30
@arithx arithx changed the title WIP: platform/azure: add kola/ore commands for Azure platform/azure: add kola/ore commands for Azure Dec 6, 2017
@arithx
Copy link
Contributor Author

arithx commented Dec 6, 2017

All tests that aren't excluded are now passing. Unmarking as WIP. Good to review.

Copy link
Contributor

@dm0- dm0- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it work to just move this file somewhere else and set it with OPENSSL_CONF in the cert creation service?

(This was intended to be on the locksmith TLS test change; wrong text box.)

@arithx
Copy link
Contributor Author

arithx commented Dec 14, 2017

@dm0- that works on Azure, testing on other platforms currently and if everything is passing I'll push the change

@arithx arithx force-pushed the kola-azure branch 2 times, most recently from 5e2a257 to 7df68b4 Compare May 17, 2018 16:07
@arithx
Copy link
Contributor Author

arithx commented May 17, 2018

Updates are pushed and this is ready for review.

I've tested all of the new ARM based functionality but do not have access to the ASM creds to test those components (the old ore commands & plume).

@arithx
Copy link
Contributor Author

arithx commented May 17, 2018

@dm0- in the updated locksmith TLS tests I've changed them to generate the cert into /etc/ssl/etcd.cnf and then pass that profile/extfile to the openssl commands.

auth/azure.go Show resolved Hide resolved
auth/azure.go Outdated
@@ -148,3 +168,25 @@ func ReadAzureProfile(path string) (*AzureProfile, error) {

return &ap, nil
}

func DecodeUtfbomFile(contents []byte) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have dimchansky/utfbom as a vendored dependency because of Azure, switching to x/text/encoding/unicode will also require x/text/transform neither of which are currently vendored.

Do you have a preference between the two?

platform/api/azure/api.go Show resolved Hide resolved
return fmt.Errorf("unable to fetch release bucket %v version: %v", a.opts.Sku, err)
}

scanner := bufio.NewScanner(resp.Body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I remember seeing parsing this format somewhere else. Should break that out into a util package or something after this PR.

platform/api/azure/instance.go Show resolved Hide resolved
if err != nil {
return nil, err
}
ac.sshKey = keys[0].String()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is keys always going to have at least 1 element?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so, when a new SSH agent (which is what the Keys function is listing) is created a key is always generated (see NewSSHAgent in network/ssh.go). We're also doing this same direct access of keys[0] in DigitalOcean.

platform/machine/azure/cluster.go Show resolved Hide resolved
@@ -59,17 +59,23 @@ func init() {
]
}
}`)

// These tests are disabled on Azure because the hostname
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe list the disabled tests in the commit message

README.md Outdated
```
$ az login`
```
It also requires that the environment variable `AZURE_AUTH_LOCATION` points to a JSON file. The JSON file will require a service provider active directory account to be created.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can mantle set this if it's unset so users do not need to?

Copy link
Contributor Author

@arithx arithx May 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could either add a parameter that points to this and/or make a standardized location for it and handle that if it's not already present.

But as it's user generated and not used by anything other than Microsoft/go-autorest there isn't currently a standardized location.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say just pick one and go with it, needing to set an environment variable to run kola is a pain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bgilbert: do you have a preference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I'd add about setting this environment variable is that there isn't going to be a good way to Unset the environment variable. We tend to do platform specific configuration inside of the Cluster or API but those do not provide sufficient points for deferred cleanup of an environment variable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC environment vars should die with the process.

The JSON file exported to the variable `AZURE_AUTH_LOCATION` should be generated by hand and have the following contents:
```
{
"clientId": "<service provider id>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should note this is from the az ad sp create-for-rbac

@arithx arithx force-pushed the kola-azure branch 3 times, most recently from 1134022 to f29b0eb Compare May 21, 2018 18:48
@arithx
Copy link
Contributor Author

arithx commented May 21, 2018

Update pushed

Copy link
Contributor

@ajeddeloh ajeddeloh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit then LGTM

@@ -42,6 +43,7 @@ func init() {

sv := Azure.PersistentFlags().StringVar
sv(&azureProfile, "azure-profile", "", "Azure Profile json file")
sv(&azureAuth, "azure-auth", "", "Azure auth location")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we default this to something like .azure/credentials.json. I don't really care what, but we should have a canonical location so kola runs with azure don't need special args/envs

@arithx arithx force-pushed the kola-azure branch 4 times, most recently from cb358d9 to 637504d Compare June 13, 2018 15:25
@arithx
Copy link
Contributor Author

arithx commented Jun 13, 2018

Updates pushed

  • Automatically importing the credentials file (defaults to ~/.azure/credentials.json)
  • Fixed a bug where the API would try to resolve the image when running ore
  • Enabled AcceleratedNetworking on the NIC (required bumping the default size to Standard_D2_v2).

@arithx
Copy link
Contributor Author

arithx commented Jun 18, 2018

Made a small change to the create-image-arm command to output a JSON struct with the ID & Location for future jenkins work.

Copy link
Contributor

@ajeddeloh ajeddeloh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LEBTM

ajeddeloh
ajeddeloh previously approved these changes Jun 27, 2018
Copy link
Contributor

@ajeddeloh ajeddeloh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (again)

@arithx
Copy link
Contributor Author

arithx commented Jun 18, 2019

rebased & updated

ac.sshKey = af.FakeSSHKey
}

ac.ResourceGroup, err = af.api.CreateResourceGroup("kola-cluster")
Copy link
Contributor Author

@arithx arithx Jun 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to open up an issue once this PR merges for moving the creation of the Resource Group & Storage Account into the Flight. It would have required a non-insignificant amount of refactoring to include in this change set, as such to reduce review complexity (@ajeddeloh has reviewed this code previously) I've left it as is.

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane at a high level! Will let @ajeddeloh do a final more informed ACK.

auth/azure.go Outdated
)

const AzureProfilePath = ".azure/azureProfile.json"
// A version of the Options struct from platform/api/azure that only
// contains the ASM values. Otherwise there's a cyclical depdendency
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependence

Azure.AddCommand(cmdCreateImageARM)
}

func runCreateImageARM(cmd *cobra.Command, args []string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was really confused for a sec and thought Azure supported ARM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah ARM (Azure Resource Manager) can be a confusing name when looking from our usual scope.

@arithx arithx force-pushed the kola-azure branch 2 times, most recently from 110ec5f to a108da6 Compare July 10, 2019 14:12
@imcleod
Copy link

imcleod commented Jul 10, 2019

I tested the ARM functionality here end to end with @arithx earlier today. It LGTM and, in fact, is absolutely essential for us to push images to Azure using the type of credentials available to us these days. Put more bluntly, without this, the existing azure implementation is not useful for COSA/RHCOS/FCOS.

Any effort to get this merged quickly would be greatly appreciated.

(cc: @yuqi-zhang )

Copy link
Contributor

@ajeddeloh ajeddeloh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM code wise. Couple minor nits. Needs a go mod tidy.

@@ -18,14 +18,39 @@ import (
"bytes"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nit: s/form/from/ in commit message.

@@ -0,0 +1,119 @@
// Copyright 2016 CoreOS, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably only have RH

package azure

import (
"fmt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\n between go standard library and other imports

arithx added 11 commits July 11, 2019 12:30
Bump the version fo the azure SDK to get required functionality for
later PRs & add additional sections used by the kola API for testing.
Creates an Options struct inside of auth/azure which contains the ASM
options. These are still present inside of the
platform/api/azure/options struct but removes the dependency on
platform/api/azure from auth/azure.

This allows the azure API to call ReadAzureProfile inside of the New
function.
GenerateFakeKey was added for DigitalOcean but it is now needed by Azure
as well. Move it to a centralized area and update Digitalocean to use
the new location.
Adds the Azure cluster. For each cluster a resource group will be
created inside of Azure which is removed at the end of the clusters
lifecycle (ensuring resource cleanup).

The Azure API requires that all machines are given an SSH key, if the
test is specifically not providing an SSH key the cluster will generate
a fake key via the platform/util function GenerateFakeKey.
Updates the existing Azure API to have methods for spawning new
instances, images, etc. for use with kola testing.
Adds a new version of the create-image & upload-blob commands which use
ARM credentials (Azure AD service providers), as well as a GC command to
clean up resource groups.
The Azure SDK requires a hostname to be set via the API during machine
creation and then overwrites the hostname post-boot via wa-agent.

Update the metadata/contents test to only validate
COREOS_AZURE_IPV4_DYNAMIC as the machines being created are not behind a
load balancer.

The disabled tests on Azure are:
 - coreos.ignition.v1.sethostname
 - coreos.ignition.v2.sethostname
 - coreos.install.cloudinit
 - linux.nfs.v3
 - linux.nfs.v4
 - systemd.journal.remote
Updates the coreos.locksmith.tls test to use a seperate configuration file for SSL rather than overwriting the default.

On Azure overwriting the default SSL config breaks wa-agent.
The updated New call for the API takes the API options which contains the auth based options inside of them.
@arithx
Copy link
Contributor Author

arithx commented Jul 11, 2019

Comments addressed

Copy link
Contributor

@ajeddeloh ajeddeloh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 🇮🇹

@arithx arithx merged commit 01320db into coreos:master Jul 11, 2019
@arithx arithx deleted the kola-azure branch July 11, 2019 17:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants