Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api/equinixmetal: do not exclusively rely on Google Cloud Storage #340

Merged
merged 9 commits into from
Jun 27, 2022

Conversation

tormath1
Copy link
Contributor

@tormath1 tormath1 commented Jun 20, 2022

In this PR, we abstract the temporary storage used by Equinix Metal tests and we bring the possibility to implement another ones (like SSH).

Related to: flatcar/Flatcar#720

How to use

./kola run --platform=equinixmetal ... --equinixmetal-storage-url="ssh+https://my-server"

Testing done

(Voluntary obfuscated the server name)

=== RUN   bpf.execsnoop
2022-06-24T09:09:18Z platform/api/equinixmetal/storage/remote: mantle-tormath1-k124-33001fe726-02888b3dd2.ign uploaded to /home/core/content/mantle-tormath1-k124-33001fe726-02888b3dd2.ign
2022-06-24T09:09:18Z platform/api/equinixmetal: user-data available at http://my-server/mantle-tormath1-k124-33001fe726-02888b3dd2.ign
2022-06-24T09:09:18Z platform/api/equinixmetal/storage/remote: mantle-tormath1-k124-33001fe726-fa062834f0.ipxe uploaded to /home/core/content/mantle-tormath1-k124-33001fe726-fa062834f0.ipxe
2022-06-24T09:09:18Z platform/api/equinixmetal: iPXE script available at http://my-server/mantle-tormath1-k124-33001fe726-fa062834f0.ipxe
2022-06-24T09:09:18Z platform/api/equinixmetal: Recycling is not possible, creating a new instance
2022-06-24T09:09:25Z platform/api/equinixmetal: Created device: "43034ffb-29e5-4745-ba2c-c2da49877654"
2022-06-24T09:14:35Z platform/api/equinixmetal: Device active: "43034ffb-29e5-4745-ba2c-c2da49877654"
2022-06-24T09:15:05Z platform/api/equinixmetal: Finished installation of device: "43034ffb-29e5-4745-ba2c-c2da49877654"
2022-06-24T09:15:05Z platform/api/equinixmetal/storage/remote: /home/core/content/mantle-tormath1-k124-33001fe726-fa062834f0.ipxe deleted from remote storage
2022-06-24T09:15:06Z platform/api/equinixmetal/storage/remote: /home/core/content/mantle-tormath1-k124-33001fe726-02888b3dd2.ign deleted from remote storage

Also tested with regular GCS (default behavior)

  • Changelog entries added in the respective changelog/ directory (user-facing change, bug fix, security fix, update)

@tormath1 tormath1 self-assigned this Jun 20, 2022
// created for a test.
type Storage interface {
// Upload the []byte data to the implemented storage.
Upload(string, string, []byte) (string, 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.

This could use a bit of doc about what the string parameters and returns are expected to mean.

Copy link
Member

Choose a reason for hiding this comment

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

Or can one add names?

@tormath1 tormath1 force-pushed the tormath1/equinix branch 2 times, most recently from 7c4ffd4 to 26dfd4f Compare June 24, 2022 09:16
@tormath1 tormath1 changed the title wip: api/equinixmetal: do not exclusively rely on Google Cloud Storage api/equinixmetal: do not exclusively rely on Google Cloud Storage Jun 24, 2022
@tormath1 tormath1 marked this pull request as ready for review June 24, 2022 09:19
@tormath1 tormath1 requested a review from a team June 24, 2022 09:24
@tormath1
Copy link
Contributor Author

@pothos thanks for your review - comments have been addressed:

  • added a destructor for the API (no-op operation for the GCS implementation)
  • renamed remote to sshstorage
  • renamed constructors to New for both implementation to avoid name redundancy

@@ -197,8 +197,11 @@ func init() {
sv(&kola.EquinixMetalOptions.InstallerImageKernelURL, "equinixmetal-installer-image-kernel-url", "", "EquinixMetal installer image kernel URL, (default equinixmetal-installer-image-base-url/flatcar_production_pxe.vmlinuz)")
sv(&kola.EquinixMetalOptions.InstallerImageCpioURL, "equinixmetal-installer-image-cpio-url", "", "EquinixMetal installer image cpio URL, (default equinixmetal-installer-image-base-url/flatcar_production_pxe_image.cpio.gz)")
sv(&kola.EquinixMetalOptions.ImageURL, "equinixmetal-image-url", "", "EquinixMetal image URL (default board-dependent, e.g. \"https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_production_packet_image.bin.bz2\")")
sv(&kola.EquinixMetalOptions.StorageURL, "equinixmetal-storage-url", "gs://users.developer.core-os.net/"+os.Getenv("USER")+"/mantle", "Google Storage base URL for temporary uploads")
sv(&kola.EquinixMetalOptions.StorageURL, "equinixmetal-storage-url", "gs://users.developer.core-os.net/"+os.Getenv("USER")+"/mantle", "Storage URL for temporary uploads (supported: gs, ssh+http, ssh+https, ssh")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sv(&kola.EquinixMetalOptions.StorageURL, "equinixmetal-storage-url", "gs://users.developer.core-os.net/"+os.Getenv("USER")+"/mantle", "Storage URL for temporary uploads (supported: gs, ssh+http, ssh+https, ssh")
sv(&kola.EquinixMetalOptions.StorageURL, "equinixmetal-storage-url", "gs://users.developer.core-os.net/"+os.Getenv("USER")+"/mantle", "Storage URL for temporary uploads (supported: gs, ssh+http, ssh+https, or ssh which defaults to https for download)")

Copy link
Member

@pothos pothos left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks

tormath1 added 9 commits June 27, 2022 11:40
this interface defines three methods:
* `Upload`
* `Delete`
* `Close`

To respectively upload and delete content on implemented storage.

Close can be used to close any created connections.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
`gcs` implements the `Storage` interface to upload and delete data on
Google Cloud Storage.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
this defines a ssh storage implementing the Storage interface. This
implementation can be used if the `--equinixmetal-storage-url` used the
following schemes:
* ssh
* ssh+http
* ssh+https

In the Upload method, a SSH connection is made and the file is uploaded
on the document root of the remote server.

The returned URL is built from the storage URL scheme (http or https)
and the document root.

It's up to the operator to deploy and configure Webserver and SSH setup.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
based on the StorageURL value, we dispatch the storage creation to
instantiate the correct implementation based on the URL scheme.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
Signed-off-by: Mathieu Tortuyaux <[email protected]>
this can be used to close eventual underlying connections.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
@tormath1 tormath1 merged commit 30d0dbe into flatcar-master Jun 27, 2022
@tormath1 tormath1 deleted the tormath1/equinix branch June 27, 2022 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants