-
Notifications
You must be signed in to change notification settings - Fork 35
wip: Oracle Cloud support #871
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
Open
navaneeth-dev
wants to merge
16
commits into
flatcar:main
Choose a base branch
from
navaneeth-dev:oracle-cloud-mvp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
66f5fd7
feat: initial kola support for creating oci vm
navaneeth-dev 0fbe96b
feat: add oracle ore garbage collection support
navaneeth-dev 258c2ca
chore: add oci objectstorage module to vendor/
navaneeth-dev b022a6a
feat: ore oci image upload support
navaneeth-dev 990c5bf
feat: retry logic for oci
navaneeth-dev 13e24a8
refactor: rename all references from oracle to oraclecloud
navaneeth-dev 2d35ee5
refactor: cleanup var names
navaneeth-dev 7667cf4
fix: make default ocpu 2 for k8s
navaneeth-dev 6713651
fix: pass absolute path to oci api
navaneeth-dev 5a33c57
fix: use util.retry instead of custom loops
navaneeth-dev 9f97981
chore: document oci retry policy
navaneeth-dev 0ba6184
oraclecloud: use raw authentication provider
tormath1 004a3f4
Update platform/machine/oraclecloud/cluster.go
navaneeth-dev bac4000
fix: handle passphrase protected keys in oci
navaneeth-dev 6d03414
fix: upload ssh keys to oci not user data
navaneeth-dev e2626fa
feat: support arm64 testing
navaneeth-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright The Mantle Authors. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package main | ||
|
|
||
| import "github.com/flatcar/mantle/cmd/ore/oraclecloud" | ||
|
|
||
| func init() { | ||
| root.AddCommand(oraclecloud.OracleCloud) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright The Mantle Authors. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package oraclecloud | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "path/filepath" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var ( | ||
| cmdCreateImage = &cobra.Command{ | ||
| Use: "create-image", | ||
| Short: "Create Oracle Cloud Infrastructure image", | ||
| Long: "Upload an image to Object Storage and import it as an OCI custom image", | ||
| RunE: runCreateImage, | ||
| Example: `IMAGE_ID=$(ore oraclecloud \ | ||
| --oraclecloud-compartment-id "${ORACLE_COMPARTMENT_ID}" \ | ||
| create-image \ | ||
| --oraclecloud-bucket "${ORACLE_BUCKET}" \ | ||
| --board "${CIA_ARCH}-usr" \ | ||
| --name "${kola_test_basename}" \ | ||
| --file "${ORACLE_IMAGE_NAME}")`, | ||
| } | ||
|
|
||
| imageFile string | ||
| imageName string | ||
| imageBoard string | ||
| imageObjectName string | ||
| imageSourceImageType string | ||
| ) | ||
|
|
||
| func init() { | ||
| OracleCloud.AddCommand(cmdCreateImage) | ||
| cmdCreateImage.Flags().StringVar(&options.Namespace, "oraclecloud-namespace", "", "Oracle Cloud Infrastructure Object Storage namespace (default: auto-detect)") | ||
| cmdCreateImage.Flags().StringVar(&options.Bucket, "oraclecloud-bucket", "", "Oracle Cloud Infrastructure Object Storage bucket for image uploads") | ||
| cmdCreateImage.Flags().StringVar(&imageFile, "file", "flatcar_production_oraclecloud_image.qcow2", "path to local Flatcar image (.qcow2 or .vmdk)") | ||
| cmdCreateImage.Flags().StringVar(&imageName, "name", "flatcar-kola-test", "name of the image") | ||
| cmdCreateImage.Flags().StringVar(&imageBoard, "board", "amd64-usr", "board of the image") | ||
| cmdCreateImage.Flags().StringVar(&imageObjectName, "oraclecloud-object-name", "", "Object Storage object name to use for the upload (default: <board>/<basename of --file>)") | ||
| cmdCreateImage.Flags().StringVar(&imageSourceImageType, "source-image-type", "QCOW2", "image import source type: QCOW2 or VMDK") | ||
| } | ||
|
|
||
| func runCreateImage(cmd *cobra.Command, args []string) error { | ||
| if options.CompartmentID == "" { | ||
| return fmt.Errorf("--oraclecloud-compartment-id is required") | ||
| } | ||
| if options.Bucket == "" { | ||
| return fmt.Errorf("--oraclecloud-bucket is required") | ||
| } | ||
|
|
||
| objectName := imageObjectName | ||
| if objectName == "" { | ||
| objectName = fmt.Sprintf("%s/%s", imageBoard, filepath.Base(imageFile)) | ||
| } | ||
|
|
||
| ID, err := api.UploadImage(cmd.Context(), imageName, imageFile, objectName, imageSourceImageType) | ||
| if err != nil { | ||
| return fmt.Errorf("creating Flatcar image: %w", err) | ||
| } | ||
|
|
||
| fmt.Println(ID) | ||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright The Mantle Authors. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package oraclecloud | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "time" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var ( | ||
| cmdGC = &cobra.Command{ | ||
| Use: "gc", | ||
| Short: "GC resources in Oracle Cloud Infrastructure", | ||
| Long: "Delete mantle-managed instances created over the given duration ago", | ||
| RunE: runGC, | ||
| } | ||
|
|
||
| gcDuration time.Duration | ||
| ) | ||
|
|
||
| func init() { | ||
| OracleCloud.AddCommand(cmdGC) | ||
| cmdGC.Flags().DurationVar(&gcDuration, "duration", 5*time.Hour, "how old resources must be before they're considered garbage") | ||
| } | ||
|
|
||
| func runGC(cmd *cobra.Command, args []string) error { | ||
| if options.CompartmentID == "" { | ||
| return fmt.Errorf("--oraclecloud-compartment-id is required") | ||
| } | ||
|
|
||
| if err := api.GC(cmd.Context(), gcDuration); err != nil { | ||
| return fmt.Errorf("running garbage collection: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright The Mantle Authors. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package oraclecloud | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/coreos/pkg/capnslog" | ||
| "github.com/flatcar/mantle/cli" | ||
| "github.com/flatcar/mantle/platform" | ||
| oraclecloudapi "github.com/flatcar/mantle/platform/api/oraclecloud" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var ( | ||
| plog = capnslog.NewPackageLogger("github.com/flatcar/mantle", "ore/oraclecloud") | ||
|
|
||
| OracleCloud = &cobra.Command{ | ||
| Use: "oraclecloud [command]", | ||
| Short: "Oracle Cloud Infrastructure utilities", | ||
| } | ||
|
|
||
| api *oraclecloudapi.API | ||
| options oraclecloudapi.Options | ||
| ) | ||
|
|
||
| func init() { | ||
| cli.WrapPreRun(OracleCloud, preflightCheck) | ||
| OracleCloud.PersistentFlags().StringVar(&options.Tenancy, "oraclecloud-tenancy", "", "Oracle Cloud tenancy") | ||
| OracleCloud.PersistentFlags().StringVar(&options.User, "oraclecloud-user", "", "Oracle Cloud user") | ||
| OracleCloud.PersistentFlags().StringVar(&options.Region, "oraclecloud-region", "us-ashburn-1", "Oracle Cloud fingerprint") | ||
| OracleCloud.PersistentFlags().StringVar(&options.PrivateKey, "oraclecloud-private-key", "", "Oracle Cloud private key") | ||
| OracleCloud.PersistentFlags().StringVar(&options.PrivateKeyPassphrase, "oraclecloud-private-key-passphrase", "", "Oracle Cloud private key passphrase") | ||
| OracleCloud.PersistentFlags().StringVar(&options.Fingerprint, "oraclecloud-fingerprint", "", "Oracle Cloud fingerprint") | ||
| OracleCloud.PersistentFlags().StringVar(&options.CompartmentID, "oraclecloud-compartment-id", "", "Oracle Cloud Infrastructure compartment OCID") | ||
| } | ||
|
|
||
| func preflightCheck(cmd *cobra.Command, args []string) error { | ||
| options.Options = &platform.Options{Board: imageBoard} | ||
|
|
||
| a, err := oraclecloudapi.New(&options) | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "could not create Oracle Cloud Infrastructure API client: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| api = a | ||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.