Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kube): apply deployment with 0 expose provided #134

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions cluster/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ type deploymentApplies struct {
ns builder.NS
netPol builder.NetPol
cmanifest builder.Manifest
services []deploymentService
services []*deploymentService
}

func (c *client) Deploy(ctx context.Context, deployment ctypes.IDeployment) (err error) {
Expand Down Expand Up @@ -237,7 +237,7 @@ func (c *client) Deploy(ctx context.Context, deployment ctypes.IDeployment) (err
group := cdeployment.ManifestGroup()

applies := deploymentApplies{
services: make([]deploymentService, 0, len(group.Services)),
services: make([]*deploymentService, 0, len(group.Services)),
}

defer func() {
Expand Down Expand Up @@ -272,7 +272,7 @@ func (c *client) Deploy(ctx context.Context, deployment ctypes.IDeployment) (err

service := &group.Services[svcIdx]

svc := deploymentService{}
svc := &deploymentService{}

persistent := false
for i := range service.Resources.Storage {
Expand All @@ -288,15 +288,15 @@ func (c *client) Deploy(ctx context.Context, deployment ctypes.IDeployment) (err
svc.deployment = builder.NewDeployment(workload)
}

applies.services = append(applies.services, svc)

if len(service.Expose) == 0 {
c.log.Debug("no services", "lease", lid, "service", service.Name)
c.log.Debug("lease does not have services (no expose configuration provided)", "lease", lid, "service", service.Name)
continue
}

svc.localService = builder.BuildService(workload, false)
svc.globalService = builder.BuildService(workload, true)

applies.services = append(applies.services, svc)
}

if err := applyNS(ctx, c.kc, applies.ns); err != nil {
Expand All @@ -321,7 +321,7 @@ func (c *client) Deploy(ctx context.Context, deployment ctypes.IDeployment) (err
}

for svcIdx := range group.Services {
applyObjs := &applies.services[svcIdx]
applyObjs := applies.services[svcIdx]
service := &group.Services[svcIdx]

if applyObjs.statefulSet != nil {
Expand All @@ -338,15 +338,15 @@ func (c *client) Deploy(ctx context.Context, deployment ctypes.IDeployment) (err
}
}

if applyObjs.localService.Any() {
if err = applyService(ctx, c.kc, applyObjs.localService); err != nil {
if lsvc := applyObjs.localService; lsvc != nil && lsvc.Any() {
if err = applyService(ctx, c.kc, lsvc); err != nil {
c.log.Error("applying local service", "err", err, "lease", lid, "service", service.Name)
return err
}
}

if applyObjs.globalService.Any() {
if err = applyService(ctx, c.kc, applyObjs.globalService); err != nil {
if gsvc := applyObjs.globalService; gsvc != nil && gsvc.Any() {
if err = applyService(ctx, c.kc, gsvc); err != nil {
c.log.Error("applying global service", "err", err, "lease", lid, "service", service.Name)
return err
}
Expand Down
Loading