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 odigosVersion from odigos config #1457

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion api/odigos/v1alpha1/odigosconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func (odigosConfig *OdigosConfiguration) ToCommonConfig() *common.OdigosConfigur
}
}
return &common.OdigosConfiguration{
OdigosVersion: odigosConfig.Spec.OdigosVersion,
ConfigVersion: odigosConfig.Spec.ConfigVersion,
TelemetryEnabled: odigosConfig.Spec.TelemetryEnabled,
OpenshiftEnabled: odigosConfig.Spec.OpenshiftEnabled,
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ This command will install k8s components that will auto-instrument your applicat
createKubeResourceWithLogging(ctx, fmt.Sprintf("> Creating namespace %s", ns),
client, cmd, ns, createNamespace)

resourceManagers := resources.CreateResourceManagers(client, ns, odigosTier, &odigosProToken, &config)
resourceManagers := resources.CreateResourceManagers(client, ns, odigosTier, &odigosProToken, &config, versionFlag)
err = resources.ApplyResourceManagers(ctx, client, resourceManagers, "Creating")
if err != nil {
fmt.Printf("\033[31mERROR\033[0m Failed to install Odigos: %s\n", err)
Expand Down Expand Up @@ -223,7 +223,6 @@ func createOdigosConfig(odigosTier common.OdigosTier) common.OdigosConfiguration
}

return common.OdigosConfiguration{
OdigosVersion: versionFlag,
ConfigVersion: 1, // config version starts at 1 and incremented on every config change
TelemetryEnabled: telemetryEnabled,
OpenshiftEnabled: openshiftEnabled,
Expand Down
8 changes: 7 additions & 1 deletion cli/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func updateApiKey(cmd *cobra.Command, args []string) {
os.Exit(1)
}

currentOdigosVersion, err := getOdigosVersionInClusterFromConfigMap(ctx, client, ns)
if err != nil {
fmt.Println("Odigos cloud login failed - unable to read the current Odigos version.")
os.Exit(1)
}

config, err := resources.GetCurrentConfig(ctx, client, ns)
if err != nil {
fmt.Println("Odigos cloud login failed - unable to read the current Odigos configuration.")
Expand Down Expand Up @@ -92,7 +98,7 @@ func updateApiKey(cmd *cobra.Command, args []string) {
}
isPrevOdigosCloud := currentTier == common.CloudOdigosTier

resourceManagers := resources.CreateResourceManagers(client, ns, common.CloudOdigosTier, &odigosCloudApiKeyFlag, config)
resourceManagers := resources.CreateResourceManagers(client, ns, common.CloudOdigosTier, &odigosCloudApiKeyFlag, config, currentOdigosVersion)
err = resources.ApplyResourceManagers(ctx, client, resourceManagers, "Updating")
if err != nil {
fmt.Println("Odigos cloud login failed - unable to apply Odigos resources.")
Expand Down
8 changes: 7 additions & 1 deletion cli/cmd/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ var logoutCmd = &cobra.Command{
os.Exit(1)
}

currentOdigosVersion, err := getOdigosVersionInClusterFromConfigMap(ctx, client, ns)
if err != nil {
fmt.Println("Odigos cloud login failed - unable to read the current Odigos version.")
os.Exit(1)
}

currentTier, err := odigospro.GetCurrentOdigosTier(ctx, client, ns)
if err != nil {
fmt.Println("Odigos cloud login failed - unable to read the current Odigos tier.")
Expand Down Expand Up @@ -68,7 +74,7 @@ var logoutCmd = &cobra.Command{
config.ConfigVersion += 1

emptyApiKey := ""
resourceManagers := resources.CreateResourceManagers(client, ns, common.CommunityOdigosTier, &emptyApiKey, config)
resourceManagers := resources.CreateResourceManagers(client, ns, common.CommunityOdigosTier, &emptyApiKey, config, currentOdigosVersion)
err = resources.ApplyResourceManagers(ctx, client, resourceManagers, "Updating")
if err != nil {
fmt.Println("Odigos cloud logout failed - unable to apply Odigos resources.")
Expand Down
13 changes: 7 additions & 6 deletions cli/cmd/resources/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,14 @@ func NewAutoscalerDeployment(ns string, version string, imagePrefix string, imag
}

type autoScalerResourceManager struct {
client *kube.Client
ns string
config *common.OdigosConfiguration
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosVersion string
}

func NewAutoScalerResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration) resourcemanager.ResourceManager {
return &autoScalerResourceManager{client: client, ns: ns, config: config}
func NewAutoScalerResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosVersion string) resourcemanager.ResourceManager {
return &autoScalerResourceManager{client: client, ns: ns, config: config, odigosVersion: odigosVersion}
}

func (a *autoScalerResourceManager) Name() string { return "AutoScaler" }
Expand All @@ -533,7 +534,7 @@ func (a *autoScalerResourceManager) InstallFromScratch(ctx context.Context) erro
NewAutoscalerClusterRole(),
NewAutoscalerClusterRoleBinding(a.ns),
NewAutoscalerLeaderElectionRoleBinding(a.ns),
NewAutoscalerDeployment(a.ns, a.config.OdigosVersion, a.config.ImagePrefix, a.config.AutoscalerImage),
NewAutoscalerDeployment(a.ns, a.odigosVersion, a.config.ImagePrefix, a.config.AutoscalerImage),
}
return a.client.ApplyResources(ctx, a.config.ConfigVersion, resources)
}
18 changes: 10 additions & 8 deletions cli/cmd/resources/instrumentor.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,16 +340,18 @@ func ptrbool(b bool) *bool {
}

type instrumentorResourceManager struct {
client *kube.Client
ns string
config *common.OdigosConfiguration
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosVersion string
}

func NewInstrumentorResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration) resourcemanager.ResourceManager {
func NewInstrumentorResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosVersion string) resourcemanager.ResourceManager {
return &instrumentorResourceManager{
client: client,
ns: ns,
config: config,
client: client,
ns: ns,
config: config,
odigosVersion: odigosVersion,
}
}

Expand All @@ -361,7 +363,7 @@ func (a *instrumentorResourceManager) InstallFromScratch(ctx context.Context) er
NewInstrumentorRoleBinding(a.ns),
NewInstrumentorClusterRole(),
NewInstrumentorClusterRoleBinding(a.ns),
NewInstrumentorDeployment(a.ns, a.config.OdigosVersion, a.config.TelemetryEnabled, a.config.ImagePrefix, a.config.InstrumentorImage),
NewInstrumentorDeployment(a.ns, a.odigosVersion, a.config.TelemetryEnabled, a.config.ImagePrefix, a.config.InstrumentorImage),
}
return a.client.ApplyResources(ctx, a.config.ConfigVersion, resources)
}
16 changes: 8 additions & 8 deletions cli/cmd/resources/managers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
// set apiKey to nil for no-op.
// set to empty string for "no api key" (non odigos cloud mode).
// set to a valid api key for odigos cloud mode.
func CreateResourceManagers(client *kube.Client, odigosNs string, odigosTier common.OdigosTier, proTierToken *string, config *common.OdigosConfiguration) []resourcemanager.ResourceManager {
func CreateResourceManagers(client *kube.Client, odigosNs string, odigosTier common.OdigosTier, proTierToken *string, config *common.OdigosConfiguration, odigosVersion string) []resourcemanager.ResourceManager {

// Note - the order of resource managers is important.
// If resource B depends on resource A, then B must be installed after A.
resourceManagers := []resourcemanager.ResourceManager{
NewOdigosDeploymentResourceManager(client, odigosNs, config, odigosTier),
NewOdigosDeploymentResourceManager(client, odigosNs, config, odigosTier, odigosVersion),
NewOdigosConfigResourceManager(client, odigosNs, config, odigosTier),
}

Expand All @@ -25,13 +25,13 @@ func CreateResourceManagers(client *kube.Client, odigosNs string, odigosTier com

// odigos core components are installed for all tiers.
resourceManagers = append(resourceManagers, []resourcemanager.ResourceManager{
NewOwnTelemetryResourceManager(client, odigosNs, config, odigosTier),
NewOwnTelemetryResourceManager(client, odigosNs, config, odigosTier, odigosVersion),
NewDataCollectionResourceManager(client, odigosNs, config),
NewInstrumentorResourceManager(client, odigosNs, config),
NewSchedulerResourceManager(client, odigosNs, config),
NewOdigletResourceManager(client, odigosNs, config, odigosTier),
NewAutoScalerResourceManager(client, odigosNs, config),
NewUIResourceManager(client, odigosNs, config),
NewInstrumentorResourceManager(client, odigosNs, config, odigosVersion),
NewSchedulerResourceManager(client, odigosNs, config, odigosVersion),
NewOdigletResourceManager(client, odigosNs, config, odigosTier, odigosVersion),
NewAutoScalerResourceManager(client, odigosNs, config, odigosVersion),
NewUIResourceManager(client, odigosNs, config, odigosVersion),
}...)

if odigosTier == common.CloudOdigosTier {
Expand Down
15 changes: 8 additions & 7 deletions cli/cmd/resources/odiglet.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,14 +665,15 @@ func ptrMountPropagationMode(p corev1.MountPropagationMode) *corev1.MountPropaga
}

type odigletResourceManager struct {
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosTier common.OdigosTier
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosTier common.OdigosTier
odigosVersion string
}

func NewOdigletResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosTier common.OdigosTier) resourcemanager.ResourceManager {
return &odigletResourceManager{client: client, ns: ns, config: config, odigosTier: odigosTier}
func NewOdigletResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosTier common.OdigosTier, odigosVersion string) resourcemanager.ResourceManager {
return &odigletResourceManager{client: client, ns: ns, config: config, odigosTier: odigosTier, odigosVersion: odigosVersion}
}

func (a *odigletResourceManager) Name() string { return "Odiglet" }
Expand Down Expand Up @@ -710,7 +711,7 @@ func (a *odigletResourceManager) InstallFromScratch(ctx context.Context) error {

// before creating the daemonset, we need to create the service account, cluster role and cluster role binding
resources = append(resources,
NewOdigletDaemonSet(a.ns, a.config.OdigosVersion, a.config.ImagePrefix, odigletImage, a.odigosTier, a.config.OpenshiftEnabled, a.config.GoAutoIncludeCodeAttributes))
NewOdigletDaemonSet(a.ns, a.odigosVersion, a.config.ImagePrefix, odigletImage, a.odigosTier, a.config.OpenshiftEnabled, a.config.GoAutoIncludeCodeAttributes))

return a.client.ApplyResources(ctx, a.config.ConfigVersion, resources)
}
15 changes: 8 additions & 7 deletions cli/cmd/resources/odigosdeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,22 @@ func NewLeaderElectionRole(ns string) *rbacv1.Role {
}

type odigosDeploymentResourceManager struct {
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosTier common.OdigosTier
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosTier common.OdigosTier
odigosVersion string
}

func NewOdigosDeploymentResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosTier common.OdigosTier) resourcemanager.ResourceManager {
return &odigosDeploymentResourceManager{client: client, ns: ns, config: config, odigosTier: odigosTier}
func NewOdigosDeploymentResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosTier common.OdigosTier, odigosVersion string) resourcemanager.ResourceManager {
return &odigosDeploymentResourceManager{client: client, ns: ns, config: config, odigosTier: odigosTier, odigosVersion: odigosVersion}
}

func (a *odigosDeploymentResourceManager) Name() string { return "OdigosDeployment" }

func (a *odigosDeploymentResourceManager) InstallFromScratch(ctx context.Context) error {
resources := []client.Object{
NewOdigosDeploymentConfigMap(a.ns, a.config.OdigosVersion),
NewOdigosDeploymentConfigMap(a.ns, a.odigosVersion),
NewLeaderElectionRole(a.ns),
}

Expand Down
15 changes: 8 additions & 7 deletions cli/cmd/resources/owntelemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,15 @@ func int64Ptr(n int64) *int64 {
}

type ownTelemetryResourceManager struct {
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosTier common.OdigosTier
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosTier common.OdigosTier
odigosVersion string
}

func NewOwnTelemetryResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosTier common.OdigosTier) resourcemanager.ResourceManager {
return &ownTelemetryResourceManager{client: client, ns: ns, config: config, odigosTier: odigosTier}
func NewOwnTelemetryResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosTier common.OdigosTier, odigosVersion string) resourcemanager.ResourceManager {
return &ownTelemetryResourceManager{client: client, ns: ns, config: config, odigosTier: odigosTier, odigosVersion: odigosVersion}
}

func (a *ownTelemetryResourceManager) Name() string { return "OwnTelemetry Pipeline" }
Expand All @@ -267,7 +268,7 @@ func (a *ownTelemetryResourceManager) InstallFromScratch(ctx context.Context) er
var resources []client.Object
if a.odigosTier == common.CloudOdigosTier {
resources = []client.Object{
NewOwnTelemetryConfigMapOtlpGrpc(a.ns, a.config.OdigosVersion),
NewOwnTelemetryConfigMapOtlpGrpc(a.ns, a.odigosVersion),
NewOwnTelemetryCollectorConfigMap(a.ns),
NewOwnTelemetryCollectorDeployment(a.ns),
NewOwnTelemetryCollectorService(a.ns),
Expand Down
13 changes: 7 additions & 6 deletions cli/cmd/resources/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,14 @@ func NewSchedulerDeployment(ns string, version string, imagePrefix string) *apps
}

type schedulerResourceManager struct {
client *kube.Client
ns string
config *common.OdigosConfiguration
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosVersion string
}

func NewSchedulerResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration) resourcemanager.ResourceManager {
return &schedulerResourceManager{client: client, ns: ns, config: config}
func NewSchedulerResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosVersion string) resourcemanager.ResourceManager {
return &schedulerResourceManager{client: client, ns: ns, config: config, odigosVersion: odigosVersion}
}

func (a *schedulerResourceManager) Name() string { return "Scheduler" }
Expand All @@ -316,7 +317,7 @@ func (a *schedulerResourceManager) InstallFromScratch(ctx context.Context) error
NewSchedulerRoleBinding(a.ns),
NewSchedulerClusterRole(),
NewSchedulerClusterRoleBinding(a.ns),
NewSchedulerDeployment(a.ns, a.config.OdigosVersion, a.config.ImagePrefix),
NewSchedulerDeployment(a.ns, a.odigosVersion, a.config.ImagePrefix),
}
return a.client.ApplyResources(ctx, a.config.ConfigVersion, resources)
}
20 changes: 11 additions & 9 deletions cli/cmd/resources/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
rbacv1 "k8s.io/api/rbac/v1"

"github.com/odigos-io/odigos/cli/pkg/containers"
"github.com/odigos-io/odigos/common/consts"
"github.com/odigos-io/odigos/common"
"github.com/odigos-io/odigos/common/consts"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -28,9 +28,10 @@ const (
)

type uiResourceManager struct {
client *kube.Client
ns string
config *common.OdigosConfiguration
client *kube.Client
ns string
config *common.OdigosConfiguration
odigosVersion string
}

func (u *uiResourceManager) Name() string {
Expand Down Expand Up @@ -294,16 +295,17 @@ func (u *uiResourceManager) InstallFromScratch(ctx context.Context) error {
NewUIRoleBinding(u.ns),
NewUIClusterRole(),
NewUIClusterRoleBinding(u.ns),
NewUIDeployment(u.ns, u.config.OdigosVersion, u.config.ImagePrefix),
NewUIDeployment(u.ns, u.odigosVersion, u.config.ImagePrefix),
NewUIService(u.ns),
}
return u.client.ApplyResources(ctx, u.config.ConfigVersion, resources)
}

func NewUIResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration) resourcemanager.ResourceManager {
func NewUIResourceManager(client *kube.Client, ns string, config *common.OdigosConfiguration, odigosVersion string) resourcemanager.ResourceManager {
return &uiResourceManager{
client: client,
ns: ns,
config: config,
client: client,
ns: ns,
config: config,
odigosVersion: odigosVersion,
}
}
3 changes: 1 addition & 2 deletions cli/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ and apply any required migrations and adaptations.`,
}

// update the config on upgrade
config.OdigosVersion = versionFlag
config.ConfigVersion += 1

// make sure the current system namespaces is in the ignored in config
Expand All @@ -118,7 +117,7 @@ and apply any required migrations and adaptations.`,
fmt.Println("Odigos cloud login failed - unable to read the current Odigos tier.")
os.Exit(1)
}
resourceManagers := resources.CreateResourceManagers(client, ns, currentTier, nil, config)
resourceManagers := resources.CreateResourceManagers(client, ns, currentTier, nil, config, versionFlag)
err = resources.ApplyResourceManagers(ctx, client, resourceManagers, operation)
if err != nil {
fmt.Println("Odigos upgrade failed - unable to apply Odigos resources.")
Expand Down
25 changes: 12 additions & 13 deletions common/odigos_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ type CollectorGatewayConfiguration struct {

// OdigosConfiguration defines the desired state of OdigosConfiguration
type OdigosConfiguration struct {
OdigosVersion string `json:"odigosVersion"`
ConfigVersion int `json:"configVersion"`
TelemetryEnabled bool `json:"telemetryEnabled,omitempty"`
OpenshiftEnabled bool `json:"openshiftEnabled,omitempty"`
IgnoredNamespaces []string `json:"ignoredNamespaces,omitempty"`
IgnoredContainers []string `json:"ignoredContainers,omitempty"`
Psp bool `json:"psp,omitempty"`
ImagePrefix string `json:"imagePrefix,omitempty"`
OdigletImage string `json:"odigletImage,omitempty"`
InstrumentorImage string `json:"instrumentorImage,omitempty"`
AutoscalerImage string `json:"autoscalerImage,omitempty"`
DefaultSDKs map[ProgrammingLanguage]OtelSdk `json:"defaultSDKs,omitempty"`
CollectorGateway *CollectorGatewayConfiguration `json:"collectorGateway,omitempty"`
ConfigVersion int `json:"configVersion"`
TelemetryEnabled bool `json:"telemetryEnabled,omitempty"`
OpenshiftEnabled bool `json:"openshiftEnabled,omitempty"`
IgnoredNamespaces []string `json:"ignoredNamespaces,omitempty"`
IgnoredContainers []string `json:"ignoredContainers,omitempty"`
Psp bool `json:"psp,omitempty"`
ImagePrefix string `json:"imagePrefix,omitempty"`
OdigletImage string `json:"odigletImage,omitempty"`
InstrumentorImage string `json:"instrumentorImage,omitempty"`
AutoscalerImage string `json:"autoscalerImage,omitempty"`
DefaultSDKs map[ProgrammingLanguage]OtelSdk `json:"defaultSDKs,omitempty"`
CollectorGateway *CollectorGatewayConfiguration `json:"collectorGateway,omitempty"`

// this is internal currently, and is not exposed on the CLI / helm
// used for odigos enterprise
Expand Down
1 change: 0 additions & 1 deletion helm/odigos/templates/odigos-config-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data:
{{- end }}
{{- end }}
instrumentorImage: {{ .Values.instrumentor.image.repository }}
odigosVersion: {{ .Values.image.tag | default .Chart.AppVersion }}
telemetryEnabled: {{ .Values.telemetry.enabled }}
openshiftEnabled: {{ .Values.openshift.enabled }}
psp: {{ .Values.psp.enabled }}
Expand Down
Loading