Skip to content

Commit

Permalink
Fix service raw configuration (#203)
Browse files Browse the repository at this point in the history
* remove hardcoded images

* fix image

* Update examples/janus-cr-with-app-configs.yaml

Co-authored-by: Armel Soro <armel@rm3l.org>

* change lookup

* Update config/manager/default-config/db-statefulset.yaml

Co-authored-by: Armel Soro <armel@rm3l.org>

* Update config/manager/default-config/deployment.yaml

Co-authored-by: Armel Soro <armel@rm3l.org>

* change lookup

* change lookup

* Update config/manager/default-config/deployment.yaml

Co-authored-by: Armel Soro <armel@rm3l.org>

* add generated files

* fix image

* fix service raw config

---------

Co-authored-by: Armel Soro <armel@rm3l.org>
  • Loading branch information
gazarenkov and rm3l committed Feb 16, 2024
1 parent 05a4fe9 commit 505f72e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions controllers/backstage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ func (r *BackstageReconciler) readConfigMapOrDefault(ctx context.Context, name s
val, ok := cm.Data[key]
if !ok {
// key not found, default
lg.V(1).Info("custom configuration configMap and data exists, trying to apply it", "configMap", cm.Name, "key", key)
lg.V(1).Info("custom configuration configMap exists but no such key, applying default config", "configMap", cm.Name, "key", key)
err := readYamlFile(defFile(key), object)
if err != nil {
return fmt.Errorf("failed to read YAML file: %w", err)
}
} else {
lg.V(1).Info("custom configuration configMap exists but no such key, applying default config", "configMap", cm.Name, "key", key)
lg.V(1).Info("custom configuration configMap and data exists, trying to apply it", "configMap", cm.Name, "key", key)
err := readYaml([]byte(val), object)
if err != nil {
return fmt.Errorf("failed to read YAML: %w", err)
Expand Down
7 changes: 7 additions & 0 deletions controllers/backstage_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ func (r *BackstageReconciler) reconcileBackstageService(ctx context.Context, bac
Namespace: ns,
},
}

if _, err := controllerutil.CreateOrUpdate(ctx, r.Client, service, r.serviceObjectMutFun(ctx, service, *backstage,
backstage.Spec.RawRuntimeConfig.BackstageConfigName, "service.yaml", service.Name, service.Name)); err != nil {

if errors.IsConflict(err) {
return retryReconciliation(err)
}
msg := fmt.Sprintf("failed to deploy Backstage Service: %s", err)

setStatusCondition(backstage, bs.ConditionDeployed, metav1.ConditionFalse, bs.DeployFailed, msg)
return fmt.Errorf("%s %w", msg, err)
}

return nil
}

Expand All @@ -49,6 +54,7 @@ func (r *BackstageReconciler) reconcileBackstageService(ctx context.Context, bac
func (r *BackstageReconciler) serviceObjectMutFun(ctx context.Context, targetService *corev1.Service, backstage bs.Backstage,
configName, configKey, serviceName, label string) controllerutil.MutateFn {
return func() error {

service := &corev1.Service{}
targetService.ObjectMeta.DeepCopyInto(&service.ObjectMeta)

Expand All @@ -75,6 +81,7 @@ func (r *BackstageReconciler) serviceObjectMutFun(ctx context.Context, targetSer

service.ObjectMeta.DeepCopyInto(&targetService.ObjectMeta)
service.Spec.DeepCopyInto(&targetService.Spec)

return nil
}
}
Expand Down
1 change: 1 addition & 0 deletions controllers/local_db_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (r *BackstageReconciler) reconcilePsqlService(ctx context.Context, backstag
}
msg := fmt.Sprintf("failed to deploy database service: %s", err)
setStatusCondition(backstage, bs.ConditionDeployed, metav1.ConditionFalse, bs.DeployFailed, msg)
return fmt.Errorf("%s %w", msg, err)
}
return nil
}

0 comments on commit 505f72e

Please sign in to comment.