Skip to content

Commit

Permalink
Clean up manifest apply output (istio#457)
Browse files Browse the repository at this point in the history
* Clean up manifest apply output

* Restore warning for special case
  • Loading branch information
ostromart authored and istio-testing committed Oct 25, 2019
1 parent 65ddc15 commit ff92502
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions cmd/mesh/manifest-apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ func manifestApplyCmd(rootArgs *rootArgs, maArgs *manifestApplyArgs) *cobra.Comm
Run: func(cmd *cobra.Command, args []string) {
// Passing cmd.OutOrStdXXX() allows capturing command output for e2e tests.
l := newLogger(rootArgs.logToStdErr, cmd.OutOrStdout(), cmd.OutOrStderr())
if !maArgs.skipConfirmation && maArgs.kubeConfigPath == "" && maArgs.context == "" {
if !confirm("Do you want to proceed? (y/N)", cmd.OutOrStdout()) {
// Warn a user if they type `mesh manifest apply` without any config args.
if maArgs.inFilename == "" && len(maArgs.set) == 0 && !maArgs.skipConfirmation {
if !confirm("This will install the default Istio profile into the cluster. Proceed? (y/N)", cmd.OutOrStdout()) {
cmd.Print("Cancelled.\n")
os.Exit(1)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/mesh/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,18 @@ func genApplyManifests(setOverlay []string, inFilename string, dryRun bool, verb
for cn := range manifests {
if out[cn].Err != nil {
cs := fmt.Sprintf("Component %s failed install:", cn)
l.logAndPrintf("\n%s\n%s\n", cs, strings.Repeat("=", len(cs)))
l.logAndPrintf("\n%s\n%s", cs, strings.Repeat("=", len(cs)))
l.logAndPrint("Error: ", out[cn].Err, "\n")
} else {
cs := fmt.Sprintf("Component %s installed successfully:", cn)
l.logAndPrintf("\n%s\n%s\n", cs, strings.Repeat("=", len(cs)))
l.logAndPrintf("\n%s\n%s", cs, strings.Repeat("=", len(cs)))
}

if strings.TrimSpace(out[cn].Stderr) != "" {
l.logAndPrint("Error detail:\n", out[cn].Stderr, "\n")
}
if strings.TrimSpace(out[cn].Stdout) != "" {
l.logAndPrint("Stdout:\n", out[cn].Stdout, "\n")
l.logAndPrint(out[cn].Stdout, "\n")
}
}
return nil
Expand Down
12 changes: 6 additions & 6 deletions pkg/manifest/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func ApplyAll(manifests name.ManifestMap, version version.Version, opts *Install
for c := range manifests {
logAndPrint("- %s", c)
}
logAndPrint("Component dependencies tree: \n%s", installTreeString())
log.Infof("Component dependencies tree: \n%s", installTreeString())
if err := initK8SRestClient(opts.Kubeconfig, opts.Context); err != nil {
return nil, err
}
Expand All @@ -239,15 +239,15 @@ func applyRecursive(manifests name.ManifestMap, version version.Version, opts *I
wg.Add(1)
go func() {
if s := dependencyWaitCh[c]; s != nil {
logAndPrint("%s is waiting on parent dependency...", c)
logAndPrint("%s is waiting on a prerequisite...", c)
<-s
logAndPrint("Parent dependency for %s has unblocked, proceeding.", c)
logAndPrint("Prerequisite for %s has completed, proceeding with install.", c)
}
out[c] = applyManifest(c, m, version, opts)

// Signal all the components that depend on us.
for _, ch := range componentDependencies[c] {
logAndPrint("unblocking child dependency %s.", ch)
log.Infof("unblocking child %s.", ch)
dependencyWaitCh[ch] <- struct{}{}
}
wg.Done()
Expand Down Expand Up @@ -313,7 +313,7 @@ func applyManifest(componentName name.ComponentName, manifestStr string, version
extraArgs = append(extraArgs, "--prune", "--selector", componentLabel)
}

logAndPrint("kubectl applying manifest for component %s", componentName)
logAndPrint("Applying manifest for component %s", componentName)

crdObjects := cRDKindObjects(objects)
if len(crdObjects) > 0 {
Expand Down Expand Up @@ -348,7 +348,7 @@ func applyManifest(componentName name.ComponentName, manifestStr string, version
}
}
stdout, stderr, err = kubectl.Apply(opts.DryRun, opts.Verbose, opts.Kubeconfig, opts.Context, namespace, m, extraArgs...)
logAndPrint("finished applying manifest for component %s", componentName)
logAndPrint("Finished applying manifest for component %s", componentName)
ym, _ := objects.YAMLManifest()
return &ComponentApplyOutput{
Stdout: stdoutCRD + "\n" + stdout,
Expand Down

0 comments on commit ff92502

Please sign in to comment.