Repository: istio/istio
File: pkg/test/framework/components/istio/kube.go (Go)

Code before:
		// TODO
		// values:               iop.Spec.Values.Fields,
		installer:            newInstaller(ctx, workDir),
		meshConfig:           &meshConfig{configMap: *newConfigMap(ctx, cfg.SystemNamespace, revisions)},
		injectConfig:         &injectConfig{configMap: *newConfigMap(ctx, cfg.SystemNamespace, revisions)},
		iopFiles:             iopFiles,
		ingress:              map[string]map[string]ingress.Instance{},
		istiod:               map[string]istiokube.PortForwarder{},
		externalControlPlane: ctx.AllClusters().IsExternalControlPlane(),
	}

	t0 := time.Now()
	defer func() {
		ctx.RecordTraceEvent("istio-deploy", time.Since(t0).Seconds())
	}()
	i.id = ctx.TrackResource(i)

	// Execute External Control Plane Installer Script
	if cfg.ControlPlaneInstaller != "" && !cfg.DeployIstio {
		scopes.Framework.Infof("=== BEGIN: Execute Control Plane Installer ===")
		cmd := exec.Command(cfg.ControlPlaneInstaller, "install", workDir)
		if output, err := cmd.CombinedOutput(); err != nil {
			scopes.Framework.Errorf("Execute Control Plane Installer failed on: %v\nInstaller output:\n%s", err, string(output))
			scopes.Framework.Infof("=== FAILED: Execute Control Plane Installer ===")
			return nil, err
		} else {
			scopes.Framework.Debugf("Control Plane Installer output:\n%s", string(output))
			scopes.Framework.Infof("=== DONE: Execute Control Plane Installer ===")
		}
	}

	if !cfg.DeployIstio {
		scopes.Framework.Info("skipping deployment as specified in the config")
		return i, nil
	}

	// For multicluster, create and push the CA certs to all clusters to establish a shared root of trust.
	if i.env.IsMultiCluster() {
		if err := i.deployCACerts(); err != nil {
			return nil, err
		}
	}

	// First install remote-config clusters.
	// We do this first because the external istiod needs to read the config cluster at startup.
	for _, c := range ctx.Clusters().Configs().Remotes() {
		if err = i.installConfigCluster(c); err != nil {
			return i, err
		}
	}


Review comment (bug):
The `else` here doesn't really required, as if the `if` condition would not met, it will reach the "scopes.Framework.Debugf" and "scopes.Framework.Infof" in any case.

Code after:
		// TODO
		// values:               iop.Spec.Values.Fields,
		installer:            newInstaller(ctx, workDir),
		meshConfig:           &meshConfig{configMap: *newConfigMap(ctx, cfg.SystemNamespace, revisions)},
		injectConfig:         &injectConfig{configMap: *newConfigMap(ctx, cfg.SystemNamespace, revisions)},
		iopFiles:             iopFiles,
		ingress:              map[string]map[string]ingress.Instance{},
		istiod:               map[string]istiokube.PortForwarder{},
		externalControlPlane: ctx.AllClusters().IsExternalControlPlane(),
	}

	t0 := time.Now()
	defer func() {
		ctx.RecordTraceEvent("istio-deploy", time.Since(t0).Seconds())
	}()
	i.id = ctx.TrackResource(i)

	// Execute External Control Plane Installer Script
	if cfg.ControlPlaneInstaller != "" && !cfg.DeployIstio {
		scopes.Framework.Infof("=== BEGIN: Execute Control Plane Installer ===")
		cmd := exec.Command(cfg.ControlPlaneInstaller, "install", workDir)
		output, err := cmd.CombinedOutput()
		if err != nil {
			scopes.Framework.Errorf("Execute Control Plane Installer failed on: %v\nInstaller output:\n%s", err, string(output))
			scopes.Framework.Infof("=== FAILED: Execute Control Plane Installer ===")
			return nil, err
		}
		scopes.Framework.Debugf("Control Plane Installer output:\n%s", string(output))
		scopes.Framework.Infof("=== DONE: Execute Control Plane Installer ===")
	}

	if !cfg.DeployIstio {
		scopes.Framework.Info("skipping deployment as specified in the config")
		return i, nil
	}

	// For multicluster, create and push the CA certs to all clusters to establish a shared root of trust.
	if i.env.IsMultiCluster() {
		if err := i.deployCACerts(); err != nil {
			return nil, err
		}
	}

	// First install remote-config clusters.
	// We do this first because the external istiod needs to read the config cluster at startup.
	for _, c := range ctx.Clusters().Configs().Remotes() {
		if err = i.installConfigCluster(c); err != nil {
			return i, err
		}
	}