Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

System Field Discovery via Operations Manager #3858

Merged
merged 30 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8e3ef9b
initial implem
dragobt Apr 30, 2024
48879fc
Update values.yaml
kaloyanspiridonov Apr 30, 2024
d2ff502
Merge branch 'main' into CMP-5505
kaloyanspiridonov Apr 30, 2024
de82ae0
adjust configuration and make linter happy
dragobt Apr 30, 2024
b17da25
fix secret and linter again
dragobt Apr 30, 2024
13957a0
revert values
dragobt May 2, 2024
f6d10d2
adjust api to work
dragobt May 7, 2024
c9b577b
fix
kaloyanspiridonov May 7, 2024
b5a02ed
fix
kaloyanspiridonov May 8, 2024
6b3d6f5
update values.yaml
kaloyanspiridonov May 9, 2024
c390fe4
fix some bugs and improove code
kaloyanspiridonov May 10, 2024
a27f298
add some more improvements
kaloyanspiridonov May 10, 2024
4681a5b
Merge branch 'main' into CMP-5505
kaloyanspiridonov May 10, 2024
357c776
Add some unit-tests and mocks
kaloyanspiridonov May 10, 2024
62dfb94
add some more unit tests and fix imports
kaloyanspiridonov May 14, 2024
6eec7f6
revert chart changes
kaloyanspiridonov May 14, 2024
4677b5f
Merge branch 'main' into CMP-5505
kaloyanspiridonov May 14, 2024
efacc52
fix linter issues
kaloyanspiridonov May 14, 2024
fce1ac0
rename the migration
kaloyanspiridonov May 14, 2024
2d1c42f
fix linter
kaloyanspiridonov May 14, 2024
a126480
Merge branch 'main' into CMP-5505
kaloyanspiridonov May 15, 2024
b36f48f
Update migration timestamp
kaloyanspiridonov May 15, 2024
13ba87b
Merge branch 'main' into CMP-5505
kaloyanspiridonov May 16, 2024
3625da7
apply review comments
kaloyanspiridonov May 16, 2024
e243759
Update run.sh
kaloyanspiridonov May 16, 2024
a20ea5b
merge
kaloyanspiridonov May 16, 2024
d360751
Fix
kaloyanspiridonov May 16, 2024
e4589cb
Merge branch 'main' into CMP-5505
kaloyanspiridonov May 17, 2024
09e5c45
Merge branch 'main' into CMP-5505
dragobt May 21, 2024
65dabfc
add missing value for directors run.sh
dragobt May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions chart/compass/charts/director/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ spec:
value: {{ .Values.global.director.selfRegister.saasAppNameLabelKey }}
- name: APP_SELF_REGISTER_SAAS_APP_NAME_PATH
value: {{ .Values.global.director.selfRegister.saasAppNamePath }}
- name: APP_SELF_REGISTER_SAAS_REGISTRY_URL_PATH
value: {{ .Values.global.director.selfRegister.saasRegistryURLPath }}
- name: APP_SELF_REGISTER_PATH
value: {{ .Values.global.director.selfRegister.path }}
- name: APP_SELF_REGISTER_NAME_QUERY_PARAM
Expand Down Expand Up @@ -325,6 +323,12 @@ spec:
value: {{ .Values.global.systemFetcher.client.timeout }}
- name: APP_SYSTEM_FETCHER_SKIP_SSL_VALIDATION
value: {{ $.Values.global.http.client.skipSSLValidation | quote }}
- name: APP_SYSTEM_FIELD_DISCOVERY_ENGINE_SAAS_REGISTRY_API
value: "https://{{ .Values.global.gateway.tls.secure.internal.host }}.{{ .Values.global.ingress.domainName }}{{ .Values.global.tenantFetcher.prefix }}{{ .Values.global.systemFieldDiscoveryEngine.discoveryEndpoint }}"
- name: APP_SYSTEM_FIELD_DISCOVERY_ENGINE_CLIENT_TIMEOUT
value: {{ .Values.global.systemFieldDiscoveryEngine.client.timeout }}
- name: APP_SYSTEM_FIELD_DISCOVERY_ENGINE_SKIP_SSL_VALIDATION
value: {{ $.Values.global.http.client.skipSSLValidation | quote }}
- name: APP_SUBJECT_CONSUMER_MAPPING_CONFIG
value: {{ .Values.global.hydrator.subjectConsumerMappingConfig | quote }}
livenessProbe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
type: Opaque
data:
{{- $appNamePath := .Values.global.director.selfRegister.saasAppNamePath }}
{{- $saasRegURLPath := .Values.global.director.selfRegister.saasRegistryURLPath }}
{{- $saasRegURLPath := .Values.global.systemFieldDiscoveryEngine.saasRegistryURLPath }}
{{- $clientIDPath := .Values.global.director.selfRegister.clientIdPath }}
{{- $clientSecretPath := .Values.global.director.selfRegister.clientSecretPath }}
{{- $urlPath := .Values.global.director.selfRegister.urlPath }}
Expand Down
20 changes: 20 additions & 0 deletions chart/compass/charts/tenant-fetcher/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ spec:
- name: {{ .Values.global.portieris.imagePullSecretName }}
{{ end }}
volumes:
- name: self-reg-app-names-volume
secret:
secretName: {{ .Values.global.systemFieldDiscoveryEngine.secrets.saasAppNameCfg.name }}
- name: credentials-secret
secret:
secretName: {{ .Values.global.tenantFetcher.k8sSecret.name }}
Expand Down Expand Up @@ -92,6 +95,18 @@ spec:
value: {{.Values.global.tenantFetcher.tenantProvider.consumerTenantIdProperty }}
- name: APP_TENANT_PROVIDER_SUBSCRIPTION_PROVIDER_APP_NAME_PROPERTY
value: {{.Values.global.tenantFetcher.tenantProvider.subscriptionProviderAppNameProperty }}
- name: APP_SYSTEM_FIELD_DISCOVERY_SAAS_APP_SECRET_PATH
value: "{{ .Values.global.systemFieldDiscoveryEngine.secrets.saasAppNameCfg.path }}/{{ .Values.global.systemFieldDiscoveryEngine.secrets.saasAppNameCfg.key }}"
- name: APP_SYSTEM_FIELD_DISCOVERY_OAUTH_TOKEN_PATH
value: {{ .Values.global.systemFieldDiscoveryEngine.oauthTokenPath }}
- name: APP_SYSTEM_FIELD_DISCOVERY_INSTANCE_CLIENT_ID_PATH
value: {{ .Values.global.systemFieldDiscoveryEngine.clientIdPath }}
- name: APP_SYSTEM_FIELD_DISCOVERY_CLIENT_SECRET_PATH
value: {{ .Values.global.systemFieldDiscoveryEngine.clientSecretPath }}
- name: APP_SYSTEM_FIELD_DISCOVERY_URL_PATH
value: {{ .Values.global.systemFieldDiscoveryEngine.urlPath }}
- name: APP_SYSTEM_FIELD_DISCOVERY_SAAS_REGISTRY_URL_PATH
value: {{ .Values.global.systemFieldDiscoveryEngine.saasRegistryURLPath }}
- name: APP_LOG_FORMAT
value: {{.Values.global.log.format | quote }}
- name: APP_ADDRESS
Expand All @@ -118,6 +133,8 @@ spec:
value: {{ .Values.global.tenantFetcher.requiredAuthScope | quote }}
- name: APP_FETCH_TENANT_ON_DEMAND_SCOPE
value: {{ .Values.global.tenantFetcher.fetchTenantAuthScope | quote }}
- name: APP_SYSTEM_FIELD_DISCOVERY_SCOPE
value: {{ .Values.global.tenantFetcher.systemFieldDiscoveryAuthScope | quote }}
- name: APP_DIRECTOR_GRAPHQL_ENDPOINT
value: "https://{{ $.Values.global.gateway.tls.secure.internal.host }}.{{ $.Values.global.ingress.domainName }}{{ $.Values.global.director.prefix }}/graphql"
- name: APP_SELF_REGISTER_DISTINGUISH_LABEL_KEY
Expand Down Expand Up @@ -401,6 +418,9 @@ spec:
timeoutSeconds: {{ .Values.global.readinessProbe.timeoutSeconds }}
periodSeconds: {{.Values.global.readinessProbe.periodSeconds }}
volumeMounts:
- name: self-reg-app-names-volume
mountPath: {{ .Values.global.systemFieldDiscoveryEngine.secrets.saasAppNameCfg.path }}
readOnly: true
- name: dependencies-config
mountPath: "{{ .Values.global.tenantFetcher.dependenciesConfig.path }}"
readOnly: true
Expand Down
22 changes: 18 additions & 4 deletions chart/compass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ global:
name: compass-pairing-adapter
director:
dir: dev/incubator/
version: "PR-3852"
version: "PR-3858"
name: compass-director
hydrator:
dir: dev/incubator/
Expand Down Expand Up @@ -211,7 +211,7 @@ global:
name: compass-ord-service
schema_migrator:
dir: dev/incubator/
version: "PR-3857"
version: "PR-3858"
name: compass-schema-migrator
system_broker:
dir: prod/incubator/
Expand Down Expand Up @@ -352,7 +352,6 @@ global:
requestBodyPattern: '{"key": "%s"}'
saasAppNameLabelKey: "CMPSaaSAppName"
saasAppNamePath: "localSaaSAppNamePath"
saasRegistryURLPath: "localSaaSRegistryPath"
clientIDHeaderKey: client_user
suggestTokenHeaderKey: suggest_token
runtimeTypeLabelKey: "runtimeType"
Expand Down Expand Up @@ -757,7 +756,7 @@ global:
path: "/oauth2/certs"
idTokenConfig:
claims: '{"scopes": "{{ print .Extra.scope }}","tenant": "{{ .Extra.tenant }}", "consumerID": "{{ print .Extra.consumerID}}", "consumerType": "{{ print .Extra.consumerType }}", "flow": "{{ print .Extra.flow }}", "onBehalfOf": "{{ print .Extra.onBehalfOf }}", "region": "{{ print .Extra.region }}", "tokenClientID": "{{ print .Extra.tokenClientID }}", "subject": "{{ print .Extra.subject }}"}'
internalClaims: '{"scopes": "application:read application:write application.webhooks:read application.application_template:read application_template.webhooks:read webhooks.auth:read runtime:write runtime:read tenant:read tenant:write tenant_subscription:write ory_internal fetch_tenant application_template:read destinations_sensitive_data:read destinations:sync ord_aggregator:sync system_fetcher:sync certificate_subject_mapping:read certificate_subject_mapping:write bundle_instance_auth:write bundle.instance_auths:read","tenant":"{ {{ if .Header.Tenant }} \"consumerTenant\":\"{{ print (index .Header.Tenant 0) }}\", {{ end }} \"externalTenant\":\"\"}", "consumerType": "Internal Component", "flow": "Internal"}'
internalClaims: '{"scopes": "application:read application:write application.webhooks:read application.application_template:read application_template.webhooks:read webhooks.auth:read runtime:write runtime:read tenant:read tenant:write tenant_subscription:write ory_internal fetch_tenant system_field_discovery application_template:read destinations_sensitive_data:read destinations:sync ord_aggregator:sync system_fetcher:sync certificate_subject_mapping:read certificate_subject_mapping:write bundle_instance_auth:write bundle.instance_auths:read","tenant":"{ {{ if .Header.Tenant }} \"consumerTenant\":\"{{ print (index .Header.Tenant 0) }}\", {{ end }} \"externalTenant\":\"\"}", "consumerType": "Internal Component", "flow": "Internal"}'
mutators:
authenticationMappingServices:
nsadapter:
Expand Down Expand Up @@ -920,6 +919,7 @@ global:
omitDependenciesParamValue: ""
requiredAuthScope: Callback
fetchTenantAuthScope: fetch_tenant
systemFieldDiscoveryAuthScope: system_field_discovery
authentication:
jwksEndpoint: "http://ory-stack-oathkeeper-api.ory.svc.cluster.local:4456/.well-known/jwks.json"
tenantProvider:
Expand Down Expand Up @@ -1146,6 +1146,20 @@ global:
maintainOperationsJobInterval: 60m
operationProcessorsQuietPeriod: 5s
asyncRequestProcessors: 100
systemFieldDiscoveryEngine:
discoveryEndpoint: /system-field-discovery
oauthTokenPath: "/cert/token"
clientIdPath: "clientId"
clientSecretPath: "clientSecret"
urlPath: "url"
saasRegistryURLPath: "localSaaSRegistryPath"
secrets:
saasAppNameCfg:
name: "saas-app-names"
key: "appNameConfig"
path: "/tmp/appNameConfig"
client:
timeout: "30s"
tenantFetchers:
job1:
enabled: false
Expand Down
10 changes: 5 additions & 5 deletions components/director/cmd/director/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/kyma-incubator/compass/components/hydrator/pkg/certsubjmapping"

ordapiclient "github.com/kyma-incubator/compass/components/director/internal/open_resource_discovery/apiclient"
systemfielddiscoveryapiclient "github.com/kyma-incubator/compass/components/director/internal/system-field-discovery-engine/apiclient"
sfapiclient "github.com/kyma-incubator/compass/components/director/internal/systemfetcher/apiclient"

"github.com/kyma-incubator/compass/components/director/internal/domain/certsubjectmapping"
Expand Down Expand Up @@ -165,8 +166,6 @@ type config struct {

SelfRegConfig configprovider.SelfRegConfig

SystemFieldDiscoveryEngineConfig configprovider.SystemFieldDiscoveryEngineConfig

OperationsNamespace string `envconfig:"default=compass-system"`

DisableAsyncMode bool `envconfig:"default=false"`
Expand Down Expand Up @@ -194,8 +193,9 @@ type config struct {

SkipSSLValidation bool `envconfig:"default=false,APP_HTTP_CLIENT_SKIP_SSL_VALIDATION"`

OrdAggregatorClientConfig ordapiclient.OrdAggregatorClientConfig
SystemFetcherSyncClientConfig sfapiclient.SystemFetcherSyncClientConfig
OrdAggregatorClientConfig ordapiclient.OrdAggregatorClientConfig
SystemFetcherSyncClientConfig sfapiclient.SystemFetcherSyncClientConfig
SystemFieldDiscoveryClientConfig systemfielddiscoveryapiclient.SystemFieldDiscoveryEngineClientConfig

ORDWebhookMappings string `envconfig:"APP_ORD_WEBHOOK_MAPPINGS"`
TenantMappingConfigPath string `envconfig:"APP_TENANT_MAPPING_CONFIG_PATH"`
Expand Down Expand Up @@ -323,7 +323,6 @@ func main() {
securedHTTPClient,
mtlsHTTPClient,
cfg.SelfRegConfig,
cfg.SystemFieldDiscoveryEngineConfig,
cfg.OneTimeToken.Length,
adminURL,
accessStrategyExecutorProvider,
Expand All @@ -336,6 +335,7 @@ func main() {
cfg.DestinationCreatorConfig,
cfg.OrdAggregatorClientConfig,
cfg.SystemFetcherSyncClientConfig,
cfg.SystemFieldDiscoveryClientConfig,
certSubjects,
)
exitOnError(err, "Failed to initialize root resolver")
Expand Down
2 changes: 1 addition & 1 deletion components/director/cmd/ordaggregator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func main() {
}()

go func() {
if err := operationsManager.StartRescheduleOperationsJob(ctx); err != nil {
if err := operationsManager.StartRescheduleOperationsJob(ctx, []string{"COMPLETED", "FAILED"}); err != nil {
kaloyanspiridonov marked this conversation as resolved.
Show resolved Hide resolved
log.C(ctx).WithError(err).Error("Failed to run RescheduleOperationsJob. Stopping app...")
cancel()
}
Expand Down
2 changes: 1 addition & 1 deletion components/director/cmd/systemfetcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func main() {
}()

go func() {
if err := operationsManager.StartRescheduleOperationsJob(ctx); err != nil {
if err := operationsManager.StartRescheduleOperationsJob(ctx, []string{"COMPLETED", "FAILED"}); err != nil {
kaloyanspiridonov marked this conversation as resolved.
Show resolved Hide resolved
log.C(ctx).WithError(err).Error("Failed to run RescheduleOperationsJob. Stopping app...")
cancel()
}
Expand Down
Loading