Skip to content

Commit f88e933

Browse files
authored
Merge pull request #6 from mNi-Cloud/add_ionscale
update: logic
2 parents 70ccbab + 0b32206 commit f88e933

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

internal/controller/connector_controller.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,20 @@ func (r *ConnectorReconciler) reconcileDeployment(ctx context.Context, cr *v1alp
472472

473473
// Determine if Deployment needs updates by comparing specs
474474
needsUpdate := false
475-
if !reflect.DeepEqual(deploy.Spec.Template.Spec.Containers[0].Env, found.Spec.Template.Spec.Containers[0].Env) {
475+
desiredContainer := deploy.Spec.Template.Spec.Containers[0]
476+
currentContainer := found.Spec.Template.Spec.Containers[0]
477+
478+
if desiredContainer.Image != currentContainer.Image {
479+
needsUpdate = true
480+
logger.Info("Container image needs update", "current", currentContainer.Image, "desired", desiredContainer.Image)
481+
}
482+
483+
if !reflect.DeepEqual(desiredContainer.Env, currentContainer.Env) {
476484
needsUpdate = true
477485
logger.Info("Environment variables need update")
478486
}
479487

480-
if !reflect.DeepEqual(deploy.Spec.Template.Spec.Containers[0].Resources, found.Spec.Template.Spec.Containers[0].Resources) {
488+
if !reflect.DeepEqual(desiredContainer.Resources, currentContainer.Resources) {
481489
needsUpdate = true
482490
logger.Info("Resources need update")
483491
}
@@ -487,8 +495,10 @@ func (r *ConnectorReconciler) reconcileDeployment(ctx context.Context, cr *v1alp
487495
logger.Info("Updating Deployment", "Name", found.Name)
488496
// Create a copy to update
489497
updatedDeploy := found.DeepCopy()
490-
updatedDeploy.Spec.Template.Spec.Containers[0].Env = deploy.Spec.Template.Spec.Containers[0].Env
491-
updatedDeploy.Spec.Template.Spec.Containers[0].Resources = deploy.Spec.Template.Spec.Containers[0].Resources
498+
updatedContainer := &updatedDeploy.Spec.Template.Spec.Containers[0]
499+
updatedContainer.Image = desiredContainer.Image
500+
updatedContainer.Env = desiredContainer.Env
501+
updatedContainer.Resources = desiredContainer.Resources
492502

493503
if err = r.Update(ctx, updatedDeploy); err != nil {
494504
// If conflict occurred, log but don't return error

internal/controller/tailnet_controller.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,21 +493,18 @@ func deriveControlServerEndpoint(controlServer *kodiakv1alpha1.ControlServer) (s
493493
disableTLS := controlServer.Spec.Config.TLS != nil && controlServer.Spec.Config.TLS.Disable
494494
skipVerify := false
495495

496-
if !disableTLS && strings.HasPrefix(endpoint, "https://") {
496+
if disableTLS {
497+
return endpoint, false
498+
}
499+
500+
if strings.HasPrefix(endpoint, "https://") {
497501
host := endpoint[len("https://"):]
498502
if idx := strings.Index(host, "/"); idx >= 0 {
499503
host = host[:idx]
500504
}
501505
if strings.Contains(host, ".svc.") || strings.Contains(host, ".cluster.local") {
502506
skipVerify = true
503507
}
504-
if controlServer.Spec.Config.TLS != nil && controlServer.Spec.Config.TLS.CertSecretName != "" {
505-
skipVerify = true
506-
}
507-
}
508-
509-
if disableTLS {
510-
skipVerify = false
511508
}
512509

513510
return endpoint, skipVerify

0 commit comments

Comments
 (0)