Skip to content
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

feat: remove OdigosConfig CRD #1405

Merged
merged 23 commits into from
Aug 16, 2024
Merged

feat: remove OdigosConfig CRD #1405

merged 23 commits into from
Aug 16, 2024

Conversation

rauno56
Copy link
Contributor

@rauno56 rauno56 commented Jul 29, 2024

This will remove usage of odigosconfigurations.odigos.io CRD and replace it with a plain ConfigMap to remove race conditions when installing named CRD and CR at the same time during the install process. New ConfigMap will look as following:

[...]
data:
  config.yaml: { ... serialized JSON of odigosconfiguration.spec ... }
[...]

With the exception of removal of SupportedSDKs(as per @blumamir request to remove it from CM) the contents of config.yaml value and the Spec field are identical and serialize from the same string and parse to the same object.

Installs now just install ConfigMap instead of the CR of OdigosConfiguration, Helm upgrades are unchanged, as they used to just overwrite the CR anyway. CLI parses the old config unless there's already a ConfigMap and creates it as a ConfigMap.

The old CRD is left there unused for now to be able to keep on using the API for it(for migration) - can be removed when we feel we are ready to remove the migration path.

@rauno56 rauno56 force-pushed the feat/remove-odigosconfig-crd branch 7 times, most recently from a186284 to f2eaeff Compare July 31, 2024 10:31
@rauno56 rauno56 force-pushed the feat/remove-odigosconfig-crd branch 8 times, most recently from a23cd00 to d33d26d Compare August 12, 2024 19:36
@rauno56 rauno56 marked this pull request as ready for review August 12, 2024 19:48
@rauno56 rauno56 force-pushed the feat/remove-odigosconfig-crd branch 3 times, most recently from f3ce9f3 to 252d0ea Compare August 13, 2024 10:39
.goreleaser.yaml Show resolved Hide resolved
cli/cmd/resources/applyresources.go Outdated Show resolved Hide resolved
Comment on lines +46 to 56
func GetCurrentConfig(ctx context.Context, client *kube.Client, ns string) (*common.OdigosConfiguration, error) {
configMap, err := client.CoreV1().ConfigMaps(ns).Get(ctx, consts.OdigosConfigurationName, metav1.GetOptions{})
if err != nil {
return nil, err
}
var odigosConfig common.OdigosConfiguration
if err := yaml.Unmarshal([]byte(configMap.Data[consts.OdigosConfigurationFileName]), &odigosConfig); err != nil {
return nil, err
}
return &odigosConfig, nil
}
Copy link
Collaborator

@blumamir blumamir Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is also defined in autoscaler, frontent, instrumentor, odiglet and maybe other places.

WDYT about moving it to k8sutils module use this function in all places?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored the use cases in controllers. Left the others intact.

helm/odigos/templates/ui/clusterrole.yaml Show resolved Hide resolved
common/consts/consts.go Show resolved Hide resolved
@edeNFed
Copy link
Contributor

edeNFed commented Aug 15, 2024

looks great. In addition to Amir's great comments:

  • Will we need a similar PR in odigos-enterprise repo?
  • Update e2e tests assertion to validate ConfigMap is created during installation
  • Today we have a retry loop in e2e tests for helm install to avoid the OdigosConfig CRD bug, can we delete it after this?

@rauno56
Copy link
Contributor Author

rauno56 commented Aug 15, 2024

Although Amir's comments about the permissions are technically correct about being too broad. I'll leave the those the same for now - the current implementation mimics exactly what OdigosConfig had.

I will narrow down the permissions in a future PR.

Will we need a similar PR in odigos-enterprise repo?

I will check that out.

No. odigos-enterprise never references the configuration type nor the k8s resource.

Update e2e tests assertion to validate ConfigMap is created during installation

I have a feeling it wasn't there previously because there's just no way that anything works if the services cannot find the config. Added it!

Today we have a retry loop in e2e tests for helm install to avoid the OdigosConfig CRD bug, can we delete it after this?

I will remove it in this PR - the expectation is that the install will not fail and that workaround is not required.

@rauno56 rauno56 force-pushed the feat/remove-odigosconfig-crd branch from 3bb702c to 829cf69 Compare August 15, 2024 12:24
@rauno56 rauno56 force-pushed the feat/remove-odigosconfig-crd branch from c3c7e5d to ce3c385 Compare August 15, 2024 13:17
@rauno56
Copy link
Contributor Author

rauno56 commented Aug 15, 2024

@blumamir, @edeNFed, I really appreciate your comments. I think I've now addressed all of them.

Copy link
Collaborator

@blumamir blumamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a lot of places to follow and clean up, Thank you @rauno56 for the thorough work

so happy to have this fixed 🎉

Left just one comment about deleting the old resource to keep the cluster clean and consistent with helm. other than this, I think we can merge

fmt.Println("Odigos upgrade failed - unable to read the current Odigos configuration.")
os.Exit(1)
}
config = odigosConfig.ToCommonConfig()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also delete the deprecated object from k8s so that we keep only the one we need in the cluster?

common/consts/consts.go Show resolved Hide resolved
"sigs.k8s.io/yaml"
)

func GetCurrentConfig(ctx context.Context, k8sClient client.Client) (common.OdigosConfiguration, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "Config" can mean few things, perhaps we can rename it GetCurrentOdigosConfig so that it communicate what is being returned in the function name

@rauno56 rauno56 merged commit 59b25a1 into main Aug 16, 2024
19 checks passed
@rauno56 rauno56 deleted the feat/remove-odigosconfig-crd branch August 16, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants