Skip to content

Commit

Permalink
add empty string check for sidecar image name
Browse files Browse the repository at this point in the history
Signed-off-by: Mridul Gain <[email protected]>
  • Loading branch information
mridulgain committed Nov 5, 2024
1 parent de58858 commit 812bb8b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions controllers/slicegateway/slicegateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ import (
webhook "github.com/kubeslice/worker-operator/pkg/webhook/pod"
)

const (
DEFAULT_SIDECAR_IMG = "nexus.dev.aveshalabs.io/kubeslice/gw-sidecar:1.0.0"
)

var (
vpnClientFileName = "openvpn_client.ovpn"
gwSidecarImage = os.Getenv("AVESHA_GW_SIDECAR_IMAGE")
Expand Down Expand Up @@ -110,7 +114,7 @@ func (r *SliceGwReconciler) deploymentForGatewayServer(g *kubeslicev1beta1.Slice

var privileged = true

sidecarImg := "nexus.dev.aveshalabs.io/kubeslice/gw-sidecar:1.0.0"
sidecarImg := DEFAULT_SIDECAR_IMG
sidecarPullPolicy := corev1.PullAlways
vpnImg := "nexus.dev.aveshalabs.io/kubeslice/openvpn-server.ubuntu.18.04:1.0.0"
vpnPullPolicy := corev1.PullAlways
Expand Down Expand Up @@ -1376,6 +1380,11 @@ func (r *SliceGwReconciler) ReconcileGatewayDeployments(ctx context.Context, sli
}
}

sidecarImg := DEFAULT_SIDECAR_IMG
if len(gwSidecarImage) != 0 {
sidecarImg = gwSidecarImage
}

for gwInstance := 0; gwInstance < numGwInstances; gwInstance++ {
if !gwDeploymentIsPresent(sliceGwName, gwInstance, deployments) {
dep := r.deploymentForGateway(sliceGw, sliceGwName+"-"+fmt.Sprint(gwInstance)+"-"+"0", gwConfigKey)
Expand All @@ -1394,8 +1403,8 @@ func (r *SliceGwReconciler) ReconcileGatewayDeployments(ctx context.Context, sli
// update if gateway sidecar image has been changed in worker env vars
for j := range deployment.Spec.Template.Spec.Containers {
container := &deployment.Spec.Template.Spec.Containers[j]
if container.Name == "kubeslice-sidecar" && container.Image != gwSidecarImage {
container.Image = gwSidecarImage
if container.Name == "kubeslice-sidecar" && container.Image != sidecarImg {
container.Image = sidecarImg
log.Info("updating gw Deployment sidecar", "Name", deployment.Name, "image", gwSidecarImage)
err = r.Update(ctx, deployment)
if err != nil {
Expand Down

0 comments on commit 812bb8b

Please sign in to comment.