diff --git a/docs/content/developers/konnector/controllers/cluster/apiservicebinding.md b/docs/content/developers/konnector/controllers/cluster/apiservicebinding.md index 64f76a1c9..32d9aa9e9 100644 --- a/docs/content/developers/konnector/controllers/cluster/apiservicebinding.md +++ b/docs/content/developers/konnector/controllers/cluster/apiservicebinding.md @@ -14,18 +14,43 @@ flowchart TD start@{ shape: start } stop@{ shape: stop } - enqueue_reconcile(["Enqueue reconcile call for APIServiceBinding"]) + enqueue_reconcile(["Enqueue reconcile call + for APIServiceBinding"]) is_apiservicebinding_owned{"binding
owned?"} - set_apiservicebinding_condition_connected_to_true(["Set condition 'Connected' to true"]) - set_apiservicebinding_condition_connected_to_false(["Set condition 'Connected' to false"]) - set_apiservicebinding_condition_schemainsync_to_true(["Set condition 'SchemaInSync' to true"]) - set_apiservicebinding_condition_schemainsync_to_false(["Set condition 'SchemaInSync' to false"]) - - get_apiserviceexport(["Get APIServiceExport"]) - convert_apiserviceexport_to_crd(["Convert APIServiceExport to CRD"]) + set_apiservicebinding_condition_connected_to_true(["Set condition + 'Connected' + to true"]) + set_apiservicebinding_condition_connected_to_true2(["Set condition 'Connected' + to true"]) + + set_apiservicebinding_condition_connected_to_false(["Set condition 'Connected' + to false"]) + set_apiservicebinding_condition_connected_to_false2(["Set condition 'Connected' + to false"]) + + set_apiservicebinding_condition_schemainsync_to_true(["Set condition 'SchemaInSync' + to true"]) + + get_apiserviceexport(["Get provider + APIServiceExport"]) is_apiserviceexport_present{"export
exists?"} - is_apiserviceexport_valid{"export
valid?"} + + get_apiserviceexportrequest(["Get provider + APIServiceExportRequest"]) + is_apiserviceexportrequest_in_failed_state{"Is APIServiceExportRequest
in failed state?"} + + get_bound_schemas(["Get provider + BoundSchemas referenced in + APIServiceExport"]) + bound_schema_fetch_successful(["Fetching BoundSchemas + succeed?"]) + reference_bound_schema(["Reference BoundSchema + in APIServiceBinding + status"]) + convert_boundschema_to_crd(["Convert BoundSchema + to CRD"]) + get_crd(["Get CRD"]) create_crd(["Create CRD"]) @@ -42,29 +67,35 @@ flowchart TD is_apiservicebinding_owned --> |yes| get_apiserviceexport get_apiserviceexport --> is_apiserviceexport_present - is_apiserviceexport_present --> |yes| set_apiservicebinding_condition_connected_to_true - is_apiserviceexport_present --> |no| set_apiservicebinding_condition_connected_to_false - set_apiservicebinding_condition_connected_to_true --> convert_apiserviceexport_to_crd + is_apiserviceexport_present --> |yes| set_apiservicebinding_condition_connected_to_true2 + is_apiserviceexport_present --> |no| get_apiserviceexportrequest + get_apiserviceexportrequest --> is_apiserviceexportrequest_in_failed_state + is_apiserviceexportrequest_in_failed_state --> |yes| set_apiservicebinding_condition_connected_to_false2 + is_apiserviceexportrequest_in_failed_state --> |no| set_apiservicebinding_condition_connected_to_false2 + + set_apiservicebinding_condition_connected_to_false2 --> stop + set_apiservicebinding_condition_connected_to_true2 --> get_bound_schemas + get_bound_schemas --> bound_schema_fetch_successful + bound_schema_fetch_successful --> |yes| reference_bound_schema + bound_schema_fetch_successful --> |no| set_apiservicebinding_condition_connected_to_false + reference_bound_schema --> convert_boundschema_to_crd set_apiservicebinding_condition_connected_to_false --> stop - convert_apiserviceexport_to_crd --> is_apiserviceexport_valid - is_apiserviceexport_valid --> |yes| get_crd - is_apiserviceexport_valid --> |no| set_apiservicebinding_condition_schemainsync_to_false + convert_boundschema_to_crd --> get_crd get_crd --> is_crd_present is_crd_present --> |no| create_crd is_crd_present --> |yes| is_crd_owned - update_crd --> set_apiservicebinding_condition_schemainsync_to_true - create_crd --> set_apiservicebinding_condition_schemainsync_to_true + create_crd --> update_crd + + update_crd --> set_apiservicebinding_condition_connected_to_true + set_apiservicebinding_condition_connected_to_true --> set_apiservicebinding_condition_schemainsync_to_true is_crd_owned --> |yes| update_crd - is_crd_owned --> |no| set_apiservicebinding_condition_schemainsync_to_false + is_crd_owned --> |no| set_apiservicebinding_condition_connected_to_false set_apiservicebinding_condition_schemainsync_to_true --> get_clusterbinding - set_apiservicebinding_condition_schemainsync_to_false --> get_clusterbinding - get_clusterbinding --> set_apiservicebinding_provider_name - is_apiservicebinding_owned --> |no| stop set_apiservicebinding_provider_name --> stop ``` diff --git a/docs/content/developers/konnector/controllers/cluster/apiserviceexport.md b/docs/content/developers/konnector/controllers/cluster/apiserviceexport.md index 59c419668..c6faae788 100644 --- a/docs/content/developers/konnector/controllers/cluster/apiserviceexport.md +++ b/docs/content/developers/konnector/controllers/cluster/apiserviceexport.md @@ -29,19 +29,20 @@ flowchart TD for APIServiceExport"]) is_apiserviceexport_present{"APIServiceExport
exists?"} - get_crd(["Get referenced - CustomResourceDefinition"]) - get_crd2(["Get referenced - CustomResourceDefinition"]) - - is_crd_present{"CRD
exists?"} - is_crd_present2{"CRD
exists?"} + get_bound_schemas(["Get referenced + BoundSchemas"]) + get_bound_schemas2(["Get referenced + BoundSchemas"]) + is_bound_schema_present{"BoundSchema
exists?"} + update_bound_schema(["Update BoundSchema + status"]) stop_apiserviceexport_sync(["Stop APIServiceExport sync"]) get_binding(["Get referenced APIServiceBinding"]) - get_binding2(["Get referenced APIServiceBinding"]) + get_binding2(["Get referenced + APIServiceBinding"]) is_binding_present{"APIServiceBinding
exists?"} is_binding_present2{"APIServiceBinding
exists?"} @@ -59,6 +60,8 @@ to false"]) set_apiserviceexport_condition_consumerinsync_to_false(["Set condition 'ConsumerInSync' to false"]) + get_crd(["Get referenced + CustomResourceDefinition"]) copy_crd_conditions(["Copy CRD conditions to APIServiceExport conditions"]) @@ -71,17 +74,18 @@ to false"]) start --> enqueue_reconcile enqueue_reconcile --> is_apiserviceexport_present is_apiserviceexport_present --> |no| stop - is_apiserviceexport_present --> |yes| get_crd - get_crd --> is_crd_present - is_crd_present --> |yes| get_binding - is_crd_present --> |no| stop_apiserviceexport_sync - stop_apiserviceexport_sync --> stop + is_apiserviceexport_present --> |yes| get_binding get_binding --> is_binding_present - is_binding_present --> |yes| start_new_syncer + is_binding_present --> |yes| get_bound_schemas is_binding_present --> |no| stop_apiserviceexport_sync stop_apiserviceexport_sync --> stop + get_bound_schemas --> is_bound_schema_present + is_bound_schema_present --> |yes| start_new_syncer + is_bound_schema_present --> |no| stop_apiserviceexport_sync + stop_apiserviceexport_sync --> stop + start_new_syncer --> get_binding2 get_binding2 --> is_binding_present2 is_binding_present2 --> |yes| set_apiserviceexport_condition_connected_to_true @@ -89,13 +93,13 @@ to false"]) set_apiserviceexport_condition_connected_to_false --> set_apiserviceexport_condition_consumerinsync_to_false set_apiserviceexport_condition_connected_to_true --> is_binding_schemainsync is_binding_schemainsync --> |yes| set_apiserviceexport_condition_consumerinsync_to_true - set_apiserviceexport_condition_consumerinsync_to_true --> get_crd2 + set_apiserviceexport_condition_consumerinsync_to_true --> get_bound_schemas2 is_binding_schemainsync --> |no| set_apiserviceexport_condition_consumerinsync_to_false - set_apiserviceexport_condition_consumerinsync_to_false --> get_crd2 + set_apiserviceexport_condition_consumerinsync_to_false --> get_bound_schemas2 - get_crd2 --> is_crd_present2 - is_crd_present2 --> |no| stop - is_crd_present2 --> |yes| copy_crd_conditions + get_bound_schemas2 --> get_crd + get_crd --> copy_crd_conditions copy_crd_conditions --> set_summary_condition - set_summary_condition --> stop + set_summary_condition --> update_bound_schema + update_bound_schema --> stop ``` diff --git a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go index c3e37e623..b94c64f43 100644 --- a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go +++ b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go @@ -131,7 +131,7 @@ func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha2.A return nil // nothing we can do here } - // Get all APIResourceSchema objects referenced by the export + // Get all BoundSchema objects referenced by the export schemas, err := r.getSchemasFromExport(ctx, export) if err != nil { conditions.MarkFalse( @@ -148,7 +148,7 @@ func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha2.A // Process each schema for _, schema := range schemas { - if err := r.referenceBoundAPIResourceSchema(ctx, binding, schema.Name); err != nil { + if err := r.referenceBoundSchema(ctx, binding, schema.Name); err != nil { errs = append(errs, err) } @@ -166,7 +166,7 @@ func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha2.A return utilerrors.NewAggregate(errs) } -func (r *reconciler) referenceBoundAPIResourceSchema(ctx context.Context, binding *kubebindv1alpha2.APIServiceBinding, name string) error { +func (r *reconciler) referenceBoundSchema(ctx context.Context, binding *kubebindv1alpha2.APIServiceBinding, name string) error { boundSchema, err := r.getBoundSchema(ctx, name) if err != nil && !errors.IsNotFound(err) { return fmt.Errorf("failed to get BoundSchema %s: %w", name, err) diff --git a/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile.go b/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile.go index 1b8b0d692..c76301565 100644 --- a/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile.go +++ b/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile.go @@ -131,7 +131,7 @@ func (r *reconciler) ensureControllers(ctx context.Context, name string, export for _, res := range export.Spec.Resources { name := res.ResourceGroupName() - // Fetch the APIResourceSchema + // Fetch the BoundSchema schema, err := r.getRemoteBoundSchema(ctx, name) if err != nil { if errors.IsNotFound(err) {