Skip to content

Commit e89bbce

Browse files
authored
feat: add EnableIstio configuration to OperatorConfig and update DeploymentSubroutine to utilize it (#88)
On-behalf-of: @SAP [email protected] Signed-off-by: Angel Kafazov <[email protected]>
1 parent 2d65fa7 commit e89bbce

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

internal/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type OperatorConfig struct {
1717
Enabled bool `mapstructure:"subroutines-deployment-enabled" default:"true"`
1818
AuthorizationWebhookSecretName string `mapstructure:"authorization-webhook-secret-name" default:"kcp-webhook-secret"`
1919
AuthorizationWebhookSecretCAName string `mapstructure:"authorization-webhook-secret-ca-name" default:"rebac-authz-webhook-cert"`
20+
EnableIstio bool `mapstructure:"subroutines-deployment-enable-istio" default:"true"`
2021
} `mapstructure:",squash"`
2122
KcpSetup struct {
2223
Enabled bool `mapstructure:"subroutines-kcp-setup-enabled" default:"true"`

pkg/subroutines/deployment.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ type DeploymentSubroutine struct {
3232
client client.Client
3333
cfg *pmconfig.CommonServiceConfig
3434
workspaceDirectory string
35+
cfgOperator *config.OperatorConfig
3536
}
3637

3738
func NewDeploymentSubroutine(client client.Client, cfg *pmconfig.CommonServiceConfig, operatorCfg *config.OperatorConfig) *DeploymentSubroutine {
3839
sub := &DeploymentSubroutine{
3940
cfg: cfg,
4041
client: client,
4142
workspaceDirectory: filepath.Join(operatorCfg.WorkspaceDir, "/manifests/k8s/"),
43+
cfgOperator: operatorCfg,
4244
}
4345

4446
return sub
@@ -58,7 +60,7 @@ func (r *DeploymentSubroutine) Finalizers() []string { // coverage-ignore
5860

5961
func (r *DeploymentSubroutine) Process(ctx context.Context, runtimeObj runtimeobject.RuntimeObject) (ctrl.Result, errors.OperatorError) {
6062
inst := runtimeObj.(*v1alpha1.PlatformMesh)
61-
log := logger.LoadLoggerFromContext(ctx)
63+
log := logger.LoadLoggerFromContext(ctx).ChildLogger("subroutine", r.GetName())
6264
operatorCfg := pmconfig.LoadConfigFromContext(ctx).(config.OperatorConfig)
6365

6466
// Create DeploymentComponents Version
@@ -113,23 +115,24 @@ func (r *DeploymentSubroutine) Process(ctx context.Context, runtimeObj runtimeob
113115
return ctrl.Result{}, oErr
114116
}
115117

116-
// Wait for istiod release to be ready before continuing
117-
rel, err := getHelmRelease(ctx, r.client, "istio-istiod", "default")
118-
if err != nil {
119-
log.Error().Err(err).Msg("Failed to get istio-istiod Release")
120-
return ctrl.Result{}, errors.NewOperatorError(err, false, true)
121-
}
122-
123-
if !MatchesCondition(rel, "Ready") {
124-
log.Info().Msg("istio-istiod Release is not ready.. Retry in 5 seconds")
125-
return ctrl.Result{RequeueAfter: 5 * time.Second}, nil
126-
}
127-
128118
// Check if istio-proxy is injected
129119
// At he boostrap time of the cluster the operator will install istio. Later in the Process the operator needs
130120
// to communicate via the proxy with KCP. Once Istio is up and running the operator will be restarted to ensure
131121
// this communication will work
132-
if !r.cfg.IsLocal {
122+
if r.cfgOperator.Subroutines.Deployment.EnableIstio {
123+
124+
// Wait for istiod release to be ready before continuing
125+
rel, err := getHelmRelease(ctx, r.client, "istio-istiod", "default")
126+
if err != nil {
127+
log.Error().Err(err).Msg("Failed to get istio-istiod Release")
128+
return ctrl.Result{}, errors.NewOperatorError(err, false, true)
129+
}
130+
131+
if !MatchesCondition(rel, "Ready") {
132+
log.Info().Msg("istio-istiod Release is not ready.. Retry in 5 seconds")
133+
return ctrl.Result{RequeueAfter: 5 * time.Second}, nil
134+
}
135+
133136
hasProxy, pod, err := r.hasIstioProxyInjected(ctx, "platform-mesh-operator", "platform-mesh-system")
134137
if err != nil {
135138
log.Error().Err(err).Msg("Failed to check if istio-proxy is injected")

0 commit comments

Comments
 (0)