-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Operator Postflight check- db migration check (#382)
* postflight db-migration-check implemented, docs updated * fixed typo: changed kube-version to k8s-version
- Loading branch information
1 parent
ec8a937
commit 1c0ded7
Showing
20 changed files
with
1,566 additions
and
914 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/logrusorgru/aurora" | ||
ansi "github.com/mattn/go-colorable" | ||
"github.com/qlik-oss/sense-installer/pkg/api" | ||
postflight "github.com/qlik-oss/sense-installer/pkg/postflight" | ||
"github.com/qlik-oss/sense-installer/pkg/qliksense" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func postflightCmd(q *qliksense.Qliksense) *cobra.Command { | ||
postflightOpts := &postflight.PostflightOptions{} | ||
var postflightCmd = &cobra.Command{ | ||
Use: "postflight", | ||
Short: "perform postflight checks on the cluster", | ||
Long: `perform postflight checks on the cluster`, | ||
Example: `qliksense postflight <postflight_check_to_run>`, | ||
} | ||
f := postflightCmd.Flags() | ||
f.BoolVarP(&postflightOpts.Verbose, "verbose", "v", false, "verbose mode") | ||
return postflightCmd | ||
} | ||
|
||
func pfMigrationCheck(q *qliksense.Qliksense) *cobra.Command { | ||
out := ansi.NewColorableStdout() | ||
postflightOpts := &postflight.PostflightOptions{} | ||
var postflightMigrationCmd = &cobra.Command{ | ||
Use: "db-migration-check", | ||
Short: "check mongodb migration status on the cluster", | ||
Long: `check mongodb migration status on the cluster`, | ||
Example: `qliksense postflight db-migration-check`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
pf := &postflight.QliksensePostflight{Q: q, P: postflightOpts, CG: &api.ClientGoUtils{Verbose: postflightOpts.Verbose}} | ||
|
||
// Postflight db_migration_check | ||
namespace, kubeConfigContents, err := pf.CG.LoadKubeConfigAndNamespace() | ||
if err != nil { | ||
fmt.Fprintf(out, "%s\n", Red("Postflight db_migration_check FAILED")) | ||
fmt.Printf("Error: %v\n", err) | ||
return nil | ||
} | ||
if namespace == "" { | ||
namespace = "default" | ||
} | ||
if err = pf.DbMigrationCheck(namespace, kubeConfigContents); err != nil { | ||
fmt.Fprintf(out, "%s\n", Red("Postflight db_migration_check FAILED")) | ||
fmt.Printf("Error: %v\n", err) | ||
return nil | ||
} | ||
fmt.Fprintf(out, "%s\n", Green("Postflight db_migration_check completed")) | ||
return nil | ||
}, | ||
} | ||
f := postflightMigrationCmd.Flags() | ||
f.BoolVarP(&postflightOpts.Verbose, "verbose", "v", false, "verbose mode") | ||
return postflightMigrationCmd | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Postflight checks | ||
Postflight checks are performed after qliksense is installed on the cluster and during normal operating mode of the product. Such checks can range from validating certain conditions to checking the status of certain operations or entities on the kubernetes cluster. | ||
|
||
Run the following command to view help about the commands supported by postflight at any moment: | ||
``` | ||
$ qliksense postflight | ||
perform postflight checks on the cluster | ||
Usage: | ||
qliksense postflight [command] | ||
Examples: | ||
qliksense postflight <postflight_check_to_run> | ||
Available Commands: | ||
db-migration-check check mongodb migration status on the cluster | ||
Flags: | ||
-h, --help help for postflight | ||
-v, --verbose verbose mode | ||
``` | ||
|
||
### DB migration check | ||
This command checks init containers for successful database migrarion completions, and reports failure, if any to the user. | ||
|
||
An example run of this check produces an output as shown below: | ||
|
||
```shell | ||
$ qliksense postflight db-migration-check | ||
Logs from pod: qliksense-users-6977cb7788-cxxwh | ||
{"caller":"main.go:39","environment":"qseok","error":"error parsing uri: scheme must be \"mongodb\" or \"mongodb+srv\"","level":"error","message":"failed to connect to ","timestamp":"2020-06-01T01:07:18.4170507Z","version":""} | ||
Postflight db_migration_check completed | ||
``` |
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
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.