-
Notifications
You must be signed in to change notification settings - Fork 1
fix: update the target service deployment spec after the plugin execution #57
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,6 @@ import ( | |
"kardinal.kontrol-service/plugins" | ||
"kardinal.kontrol-service/types/cluster_topology/resolved" | ||
"kardinal.kontrol-service/types/flow_spec" | ||
|
||
v1 "k8s.io/api/apps/v1" | ||
) | ||
|
||
// CreateDevFlow creates a dev flow from the given topologies | ||
|
@@ -56,7 +54,7 @@ func CreateDevFlow( | |
if err != nil { | ||
return nil, err | ||
} | ||
_, err = applyPatch(pluginRunner, topologyRef, clusterGraph, flowID, targetService, servicePatch.DeploymentSpec) | ||
_, err = applyPatch(pluginRunner, topologyRef, clusterGraph, flowID, targetService, servicePatch.Image) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -147,7 +145,7 @@ func applyPatch( | |
clusterGraph graph.Graph[resolved.ServiceHash, *resolved.Service], | ||
flowID string, | ||
targetService *resolved.Service, | ||
deploymentSpec *v1.DeploymentSpec, | ||
newImage string, | ||
) (*resolved.ClusterTopology, error) { | ||
// Find downstream stateful services | ||
statefulPaths := findAllDownstreamStatefulPaths(targetService, clusterGraph, topology) | ||
|
@@ -167,7 +165,7 @@ func applyPatch( | |
|
||
externalPaths := findAllDownstreamExternalPaths(targetService, clusterGraph, topology) | ||
externalServices := make([]*resolved.Service, 0) | ||
alreadyHandledExternalServices := make([]string, 0) | ||
|
||
for _, path := range externalPaths { | ||
externalServiceHash, err := lo.Last(path) | ||
if externalServiceHash == "" || err != nil { | ||
|
@@ -206,7 +204,8 @@ func applyPatch( | |
} | ||
|
||
modifiedTargetService := DeepCopyService(targetService) | ||
modifiedTargetService.DeploymentSpec = deploymentSpec | ||
// TODO: find a better way to update deploymentSpec, this assumes there is only container in the pod | ||
modifiedTargetService.DeploymentSpec.Template.Spec.Containers[0].Image = newImage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the target service deployment spec could have been updated when executing the external plugins before these lines, for instance, there could be some env vars overwriting that we need to keep in the deployment spec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we should think on a |
||
modifiedTargetService.Version = flowID | ||
err := topology.UpdateWithService(modifiedTargetService) | ||
if err != nil { | ||
|
@@ -266,7 +265,7 @@ func applyPatch( | |
} | ||
|
||
// if the service is an external service of the target service, it was already handled above | ||
if lo.Contains(externalServices, service) && !lo.Contains(alreadyHandledExternalServices, service.ServiceID) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "alreadyHandledExternalServices" is never filled. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this still true after the new gateway support? let me check it |
||
if lo.Contains(externalServices, service) { | ||
// assume there's only one parent service for now but eventually we'll likely need to account for multiple parents to external service | ||
parentServices := topology.FindImmediateParents(service) | ||
if len(parentServices) == 0 { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
package flow_spec | ||
|
||
import v1 "k8s.io/api/apps/v1" | ||
|
||
type FlowPatch struct { | ||
FlowId string | ||
ServicePatches []ServicePatch | ||
} | ||
|
||
type ServicePatch struct { | ||
Service string | ||
DeploymentSpec *v1.DeploymentSpec | ||
Service string | ||
Image string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use the image instead of the spec?