-
Notifications
You must be signed in to change notification settings - Fork 83
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
Handle k8s service events and trigger SE generation #238
Conversation
admiral/pkg/clusters/registry.go
Outdated
|
||
if err != nil { | ||
return fmt.Errorf(" Error with GlobalTrafficController controller init: %v", err) | ||
return fmt.Errorf(" Error with ServiceController controller init: %v", err) |
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.
nitpick: space before Error
admiral/pkg/clusters/registry.go
Outdated
|
||
if err != nil { | ||
return fmt.Errorf(" Error with DeploymentController controller init: %v", err) | ||
return fmt.Errorf(" Error with GlobalTrafficController controller init: %v", err) |
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.
nitpick: space before Error
admiral/pkg/clusters/types.go
Outdated
log.Infof(LogFormat, "Added", "service", obj.Name, sh.ClusterID, "received") | ||
err := HandleEventForService(obj, sh.RemoteRegistry, sh.ClusterID) | ||
if err != nil { | ||
log.Infof(err.Error()) |
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.
Should we use Warnf or Errorf instead? (same comment for other related methods)
admiral/pkg/clusters/types.go
Outdated
HandleEventForDeployment(admiral.Update, &deployment, remoteRegistry, clusterName) | ||
} | ||
if common.GetAdmiralParams().ArgoRolloutsEnabled { | ||
rollouts := remoteRegistry.RemoteControllers[clusterName].RolloutController.GetRolloutBySelectorInNamespace(svc.Spec.Selector, svc.Namespace) |
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.
We could check for nil objects for remoteRegistry
for lkey, lvalue := range serviceSelector { | ||
// Rollouts controller adds a dynamic label with name rollouts-pod-template-hash to both active and passive replicasets. | ||
// This dynamic label is not available on the rollout template. Hence ignoring the label with name rollouts-pod-template-hash | ||
if lkey == common.ROLLOUT_POD_HASH_LABEL { |
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.
nitpick: ROLLOUT_POD_HASH_LABEL
-> RolloutPodHashLabel
if lkey == common.ROLLOUT_POD_HASH_LABEL { | ||
continue | ||
} | ||
value, ok := rollout.Spec.Selector.MatchLabels[lkey] |
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.
We could check for nil object.
if !cmp.Equal(serviceCache.Get("ns").Service["ns"][service.Name], service) { | ||
t.Errorf("Incorrect service fount. Diff: %v", cmp.Diff(serviceCache.Get("ns").Service["ns"], service)) | ||
if !cmp.Equal(serviceCache.Get("ns")[0], service) { | ||
t.Errorf("Incorrect service fount. Diff: %v", cmp.Diff(serviceCache.Get("ns")[0], service)) |
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.
typo: fount
-> found
Codecov Report
@@ Coverage Diff @@
## master #238 +/- ##
==========================================
- Coverage 75.00% 74.15% -0.86%
==========================================
Files 27 27
Lines 2613 2647 +34
==========================================
+ Hits 1960 1963 +3
- Misses 530 561 +31
Partials 123 123
Continue to review full report at Codecov.
|
admiral/pkg/clusters/handler_test.go
Outdated
@@ -693,12 +693,11 @@ func TestGetServiceForRolloutCanary(t *testing.T) { | |||
selectorMap["app"] = "test" | |||
|
|||
service := &coreV1.Service{ | |||
ObjectMeta: v12.ObjectMeta{Name: SERVICENAME, Namespace: NAMESPACE, CreationTimestamp: v12.NewTime(time.Now())}, |
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.
nitpick: ServiceName, Namespace
admiral/pkg/clusters/handler_test.go
Outdated
@@ -711,15 +710,15 @@ func TestGetServiceForRolloutCanary(t *testing.T) { | |||
service.Spec.Ports = ports | |||
|
|||
stableService := &coreV1.Service{ | |||
ObjectMeta: v12.ObjectMeta{Name: STABLESERVICENAME, Namespace: NAMESPACE}, | |||
ObjectMeta: v12.ObjectMeta{Name: STABLESERVICENAME, Namespace: NAMESPACE, CreationTimestamp: v12.NewTime(time.Now().Add(time.Duration(-15)))}, |
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.
nitpick: StableServiceName
admiral/pkg/clusters/handler_test.go
Outdated
Spec: coreV1.ServiceSpec{ | ||
Selector: selectorMap, | ||
Ports: ports, | ||
}, | ||
} | ||
|
||
canaryService := &coreV1.Service{ | ||
ObjectMeta: v12.ObjectMeta{Name: CANARYSERVICENAME, Namespace: NAMESPACE}, | ||
ObjectMeta: v12.ObjectMeta{Name: CANARYSERVICENAME, Namespace: NAMESPACE, CreationTimestamp: v12.NewTime(time.Now().Add(time.Duration(-15)))}, |
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.
Nitpick: CanaryServiceName
var filteredDeployments = make([]k8sAppsV1.Deployment, 0) | ||
|
||
for _, deployment := range matchedDeployments.Items { | ||
if deployment.Spec.Selector == nil || deployment.Spec.Selector.MatchLabels == nil { |
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.
We could check for nil values for .Selector
and .MatchLabels
if lkey == common.RolloutPodHashLabel { | ||
continue | ||
} | ||
value, ok := rollout.Spec.Selector.MatchLabels[lkey] |
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.
We can use the labelSelector parameter in the list option to find deployments matching given labels.
AdmiralIgnoreAnnotation = "admiral.io/ignore" | ||
AdmiralCnameCaseSensitive = "admiral.io/cname-case-sensitive" | ||
BlueGreenRolloutPreviewPrefix = "preview" | ||
RolloutPodHashLabel string = "rollouts-pod-template-hash" |
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.
I think the formatting is off starting line 29.
Signed-off-by: sa <[email protected]>
Signed-off-by: sa <[email protected]>
Changes include: