-
Notifications
You must be signed in to change notification settings - Fork 15
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
Check if PV/PVC Access Modes are Supported by the Volume Provider #139
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
6eead06
WIP: Check PVC access mode
rrpolanco 3ac07a8
Still WIP
rrpolanco 3ef7e7d
More WIP
rrpolanco aa01da4
Adding tests
rrpolanco 61bc196
Add more unit test
rrpolanco 00a0a86
Passing UT
rrpolanco 7f3aabb
Add option to skip validation
rrpolanco d02b37c
Export PVCError
rrpolanco 304e3d8
correctly return map
rrpolanco 5f1f4a8
print when there are validation errors
rrpolanco 0a40686
don't overwrite status for non-pending pvcs
rrpolanco 24a161e
revert previous change
rrpolanco 834ee8a
fix events and tab writer output
rrpolanco 8c6683d
Add more unit test
rrpolanco b44e097
Add pod ready timeout out for volume validation pods
rrpolanco bacfe88
convert pod ready timeout to second units
rrpolanco 26ab28b
accept an int for timeout instead of duration
rrpolanco 59f1f05
specify PVC copy operation timeout in seconds
rrpolanco a44c4ba
rename flag
rrpolanco ee23c2c
Refactor WIP
rrpolanco efe96f3
WIP: PR Review Refactor
rrpolanco 8333438
WIP: More PR review refactor
rrpolanco 87666f5
Map all failures to exit code 1
rrpolanco a556650
Address Ethan's PR review comments and suggestions
rrpolanco ff3ea81
tweak Test_pvcForStorageClass test
rrpolanco f2b558b
convert podready timeout to correct unit
rrpolanco de8c668
allow os signals to context
rrpolanco 0313d4a
fix pod and pvc cleanup
rrpolanco cf84ac3
simplify table output
rrpolanco 7c8d9e5
speed up pod deletion
rrpolanco 9e2f86c
validate storage class resource is present in the cluster
rrpolanco 263427f
Change output message
rrpolanco 0659ab5
Add todo
rrpolanco 573e996
Update flags and README
rrpolanco 9d3323d
Update text for pod-ready-timeout flag
rrpolanco 25f7358
Add Ethan's suggestion
rrpolanco b8382ca
--skip-source-validation works with preflight validation
rrpolanco 92cb2b7
Simplify deleteTmpPVC()
rrpolanco 726a160
Update README with --delete-pv-timeout flag
rrpolanco 54ba092
fix timeout flags
rrpolanco df71c22
log name of the tempt pvc and not the struct
rrpolanco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,16 +1,88 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/signal" | ||
"time" | ||
|
||
"github.com/replicatedhq/pvmigrate/pkg/migrate" | ||
"github.com/replicatedhq/pvmigrate/pkg/preflight" | ||
"github.com/replicatedhq/pvmigrate/pkg/version" | ||
k8sclient "k8s.io/client-go/kubernetes" | ||
_ "k8s.io/client-go/plugin/pkg/client/auth" // this allows accessing a larger array of cloud providers | ||
"sigs.k8s.io/controller-runtime/pkg/client/config" | ||
) | ||
|
||
func main() { | ||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) | ||
defer stop() | ||
|
||
fmt.Printf("Running pvmigrate build:\n") | ||
version.Print() | ||
|
||
migrate.Cli() | ||
// Cli uses CLI options to run Migrate | ||
var options migrate.Options | ||
var skipPreflightValidation bool | ||
var preflightValidationOnly bool | ||
var podReadyTimeout int | ||
var deletePVTimeout int | ||
flag.StringVar(&options.SourceSCName, "source-sc", "", "storage provider name to migrate from") | ||
flag.StringVar(&options.DestSCName, "dest-sc", "", "storage provider name to migrate to") | ||
flag.StringVar(&options.RsyncImage, "rsync-image", "eeacms/rsync:2.3", "the image to use to copy PVCs - must have 'rsync' on the path") | ||
flag.StringVar(&options.Namespace, "namespace", "", "only migrate PVCs within this namespace") | ||
flag.BoolVar(&options.SetDefaults, "set-defaults", false, "change default storage class from source to dest") | ||
flag.BoolVar(&options.VerboseCopy, "verbose-copy", false, "show output from the rsync command used to copy data between PVCs") | ||
flag.BoolVar(&options.SkipSourceValidation, "skip-source-validation", false, "migrate from PVCs using a particular StorageClass name, even if that StorageClass does not exist") | ||
flag.IntVar(&podReadyTimeout, "pod-ready-timeout", 60, "length of time to wait (in seconds) for validation pod(s) to go into Ready phase") | ||
flag.IntVar(&deletePVTimeout, "delete-pv-timeout", 300, "length of time to wait (in seconds) for backing PV to be removed when temporary PVC is deleted") | ||
flag.BoolVar(&skipPreflightValidation, "skip-preflight-validation", false, "skip preflight migration validation on the destination storage provider") | ||
flag.BoolVar(&preflightValidationOnly, "preflight-validation-only", false, "skip the migration and run preflight validation only") | ||
|
||
flag.Parse() | ||
|
||
// update options with flag values | ||
options.PodReadyTimeout = time.Duration(podReadyTimeout) * time.Second | ||
options.DeletePVTimeout = time.Duration(deletePVTimeout) * time.Second | ||
|
||
// setup logger | ||
logger := log.New(os.Stderr, "", 0) // this has no time prefix etc | ||
|
||
// setup k8s | ||
cfg, err := config.GetConfig() | ||
if err != nil { | ||
logger.Printf("failed to get config: %s", err) | ||
os.Exit(1) | ||
} | ||
|
||
clientset, err := k8sclient.NewForConfig(cfg) | ||
if err != nil { | ||
logger.Printf("failed to create kubernetes clientset: %s", err) | ||
os.Exit(1) | ||
} | ||
|
||
if !skipPreflightValidation { | ||
failures, err := preflight.Validate(ctx, logger, clientset, options) | ||
if err != nil { | ||
logger.Printf("failed to run preflight validation checks") | ||
os.Exit(1) | ||
} | ||
|
||
if len(failures) != 0 { | ||
preflight.PrintValidationFailures(os.Stdout, failures) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
// start the migration | ||
if !preflightValidationOnly { | ||
err = migrate.Migrate(ctx, logger, clientset, options) | ||
if err != nil { | ||
logger.Printf("migration failed: %s", err) | ||
os.Exit(1) | ||
} | ||
} | ||
} |
This file contains 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.
should this be stderr?
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.
I decided to separate the output of the validation failures to go to
stdout
and program errors tostderr
.