Skip to content

Commit

Permalink
Watch infrastructure and update AWS tags
Browse files Browse the repository at this point in the history
Signed-off-by: chiragkyal <[email protected]>
  • Loading branch information
chiragkyal committed Sep 23, 2024
1 parent 871b2b2 commit 8fb9b68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/operator/controller/ingress/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ func New(mgr manager.Manager, config Config) (controller.Controller, error) {
if err := c.Watch(source.Kind[client.Object](operatorCache, &configv1.Proxy{}, handler.EnqueueRequestsFromMapFunc(reconciler.ingressConfigToIngressController))); err != nil {
return nil, err
}
// Watch for changes to infrastructure config to update user defined tags
if err := c.Watch(source.Kind[client.Object](operatorCache, &configv1.Infrastructure{}, handler.EnqueueRequestsFromMapFunc(reconciler.ingressConfigToIngressController))); err != nil {
return nil, err
}
return c, nil
}

Expand Down
12 changes: 9 additions & 3 deletions pkg/operator/controller/ingress/load_balancer_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ var (
//
// https://cloud.ibm.com/docs/containers?topic=containers-vpc-lbaas
iksLBEnableFeaturesAnnotation,
//TODO
// awsLBAdditionalResourceTags,
)

// Azure and GCP support switching between internal and external
Expand All @@ -280,6 +282,7 @@ var (
// Always returns the current LB service if one exists (whether it already
// existed or was created during the course of the function).
func (r *reconciler) ensureLoadBalancerService(ci *operatorv1.IngressController, deploymentRef metav1.OwnerReference, platformStatus *configv1.PlatformStatus) (bool, *corev1.Service, error) {
log.Info("@chirag: Starting ensureLoadBalancerService()")
wantLBS, desiredLBService, err := desiredLoadBalancerService(ci, deploymentRef, platformStatus, r.config.IngressControllerLBSubnetsAWSEnabled, r.config.IngressControllerEIPAllocationsAWSEnabled)
if err != nil {
return false, nil, err
Expand Down Expand Up @@ -347,6 +350,7 @@ func isServiceOwnedByIngressController(service *corev1.Service, ic *operatorv1.I
// desired if the high availability type is Cloud. An LB service will declare an
// owner reference to the given deployment.
func desiredLoadBalancerService(ci *operatorv1.IngressController, deploymentRef metav1.OwnerReference, platform *configv1.PlatformStatus, subnetsAWSEnabled bool, eipAllocationsAWSEnabled bool) (bool, *corev1.Service, error) {
log.Info("@chirag: Starting desiredLoadBalancerService()")
if ci.Status.EndpointPublishingStrategy.Type != operatorv1.LoadBalancerServiceStrategyType {
return false, nil, nil
}
Expand Down Expand Up @@ -446,6 +450,7 @@ func desiredLoadBalancerService(ci *operatorv1.IngressController, deploymentRef
}

if platform.AWS != nil && len(platform.AWS.ResourceTags) > 0 {
log.Info("@chirag: platform.AWS.ResourceTags", "tags", platform.AWS.ResourceTags)
var additionalTags []string
for _, userTag := range platform.AWS.ResourceTags {
if len(userTag.Key) > 0 {
Expand All @@ -454,6 +459,7 @@ func desiredLoadBalancerService(ci *operatorv1.IngressController, deploymentRef
}
if len(additionalTags) > 0 {
service.Annotations[awsLBAdditionalResourceTags] = strings.Join(additionalTags, ",")
log.Info("@chirag: service.Annotations", "tags", service.Annotations[awsLBAdditionalResourceTags])
}
}

Expand Down Expand Up @@ -751,10 +757,10 @@ func IsServiceInternal(service *corev1.Service) bool {
return false
}

// loadBalancerServiceTagsModified verifies that none of the managedAnnotations have been changed and also the AWS tags annotation
// loadBalancerServiceTagsModified verifies that none of the managedAnnotations have been changed
func loadBalancerServiceTagsModified(current, expected *corev1.Service) (bool, *corev1.Service) {
ignoredAnnotations := managedLoadBalancerServiceAnnotations.Union(sets.NewString(awsLBAdditionalResourceTags))
return loadBalancerServiceAnnotationsChanged(current, expected, ignoredAnnotations)
// ignoredAnnotations := managedLoadBalancerServiceAnnotations.Union(sets.NewString(awsLBAdditionalResourceTags))
return loadBalancerServiceAnnotationsChanged(current, expected, managedLoadBalancerServiceAnnotations)
}

// loadBalancerServiceIsUpgradeable returns an error value indicating if the
Expand Down

0 comments on commit 8fb9b68

Please sign in to comment.