Skip to content

Commit

Permalink
chore: rename EnvVarsFromDockerFile > EnvFromContainerRuntime
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirdavid1 committed Dec 22, 2024
1 parent 57ff741 commit 68967e0
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 46 deletions.
4 changes: 2 additions & 2 deletions api/config/crd/bases/odigos.io_instrumentationconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ spec:
type: string
criErrorMessage:
type: string
envVars:
envFromContainerRuntime:
items:
properties:
name:
Expand All @@ -444,7 +444,7 @@ spec:
- value
type: object
type: array
envVarsFromDockerFile:
envVars:
items:
properties:
name:
Expand Down
4 changes: 2 additions & 2 deletions api/config/crd/bases/odigos.io_instrumentedapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ spec:
type: string
criErrorMessage:
type: string
envVars:
envFromContainerRuntime:
items:
properties:
name:
Expand All @@ -104,7 +104,7 @@ spec:
- value
type: object
type: array
envVarsFromDockerFile:
envVars:
items:
properties:
name:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions api/odigos/v1alpha1/instrumentedapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ const (

// +kubebuilder:object:generate=true
type RuntimeDetailsByContainer struct {
ContainerName string `json:"containerName"`
Language common.ProgrammingLanguage `json:"language"`
RuntimeVersion string `json:"runtimeVersion,omitempty"`
EnvVars []EnvVar `json:"envVars,omitempty"`
OtherAgent *OtherAgent `json:"otherAgent,omitempty"`
LibCType *common.LibCType `json:"libCType,omitempty"`
CriErrorMessage *string `json:"criErrorMessage,omitempty"`
EnvVarsFromDockerFile []EnvVar `json:"envVarsFromDockerFile,omitempty"`
RuntimeUpdateState *ProcessingState `json:"runtimeUpdateState,omitempty"` // Tracks whether the new runtime detection process has been executed. If empty, the process has not been executed.
ContainerName string `json:"containerName"`
Language common.ProgrammingLanguage `json:"language"`
RuntimeVersion string `json:"runtimeVersion,omitempty"`
EnvVars []EnvVar `json:"envVars,omitempty"`
OtherAgent *OtherAgent `json:"otherAgent,omitempty"`
LibCType *common.LibCType `json:"libCType,omitempty"`
CriErrorMessage *string `json:"criErrorMessage,omitempty"`
EnvFromContainerRuntime []EnvVar `json:"envFromContainerRuntime,omitempty"`
RuntimeUpdateState *ProcessingState `json:"runtimeUpdateState,omitempty"` // Tracks whether the new runtime detection process has been executed. If empty, the process has not been executed.
}

// +kubebuilder:object:generate=true
Expand Down
4 changes: 2 additions & 2 deletions api/odigos/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ spec:
type: string
criErrorMessage:
type: string
envVars:
envFromContainerRuntime:
items:
properties:
name:
Expand All @@ -444,7 +444,7 @@ spec:
- value
type: object
type: array
envVarsFromDockerFile:
envVars:
items:
properties:
name:
Expand Down Expand Up @@ -479,8 +479,6 @@ spec:
type: string
type: object
runtimeUpdateState:
description: Tracks whether the new runtime detection process
has been executed. If empty, the process has not been executed.
type: string
runtimeVersion:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ spec:
type: string
criErrorMessage:
type: string
envVars:
envFromContainerRuntime:
items:
properties:
name:
Expand All @@ -104,7 +104,7 @@ spec:
- value
type: object
type: array
envVarsFromDockerFile:
envVars:
items:
properties:
name:
Expand Down Expand Up @@ -139,8 +139,6 @@ spec:
type: string
type: object
runtimeUpdateState:
description: Tracks whether the new runtime detection process
has been executed. If empty, the process has not been executed.
type: string
runtimeVersion:
type: string
Expand Down
18 changes: 9 additions & 9 deletions odiglet/pkg/kube/runtime_details/inspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func runtimeInspection(ctx context.Context, pods []corev1.Pod, ignoredContainers
}

if criClient != nil { // CriClient passed as nil in cases that will be deprecated in the future [InstrumentedApplication]
updateRuntimeDetailsWithDockerFileEnvs(ctx, *criClient, pod, container, programLanguageDetails, &resultsMap)
updateRuntimeDetailsWithContainerRuntimeEnvs(ctx, *criClient, pod, container, programLanguageDetails, &resultsMap)
}

}
Expand All @@ -183,9 +183,9 @@ func runtimeInspection(ctx context.Context, pods []corev1.Pod, ignoredContainers
return results, nil
}

// updateRuntimeDetailsWithDockerFileEnvs checks if relevant environment variables are set in the Dockerfile
// updateRuntimeDetailsWithContainerRuntimeEnvs checks if relevant environment variables are set in the Runtime
// and updates the RuntimeDetailsByContainer accordingly.
func updateRuntimeDetailsWithDockerFileEnvs(ctx context.Context, criClient criwrapper.CriClient, pod corev1.Pod, container corev1.Container,
func updateRuntimeDetailsWithContainerRuntimeEnvs(ctx context.Context, criClient criwrapper.CriClient, pod corev1.Pod, container corev1.Container,
programLanguageDetails common.ProgramLanguageDetails, resultsMap *map[string]odigosv1.RuntimeDetailsByContainer) {
// Retrieve environment variable names for the specified language
envVarNames, exists := envOverwrite.EnvVarsForLanguage[programLanguageDetails.Language]
Expand All @@ -194,17 +194,17 @@ func updateRuntimeDetailsWithDockerFileEnvs(ctx context.Context, criClient criwr
}

// Verify if environment variables already exist in the container manifest.
// If they exist, there's no need to fetch them from the Dockerfile, and we will just append our additions in the webhook.
// If they exist, there's no need to fetch them from the Container Runtime, and we will just append our additions in the webhook.
if envsExistsInManifest := checkEnvVarsInContainerManifest(container, envVarNames); envsExistsInManifest {
return
}

// Environment variables do not exist in the manifest; fetch them from the container's Dockerfile
fetchAndSetEnvVarsFromDockerfile(ctx, criClient, pod, container, envVarNames, resultsMap)
// Environment variables do not exist in the manifest; fetch them from the container's Runtime
fetchAndSetEnvFromContainerRuntime(ctx, criClient, pod, container, envVarNames, resultsMap)
}

// fetchAndSetEnvVarsFromDockerfile retrieves environment variables from the container's Dockerfile and updates the runtime details.
func fetchAndSetEnvVarsFromDockerfile(ctx context.Context, criClient criwrapper.CriClient, pod corev1.Pod, container corev1.Container,
// fetchAndSetEnvFromContainerRuntime retrieves environment variables from the container's runtime and updates the runtime details.
func fetchAndSetEnvFromContainerRuntime(ctx context.Context, criClient criwrapper.CriClient, pod corev1.Pod, container corev1.Container,
envVarKeys []string, resultsMap *map[string]odigosv1.RuntimeDetailsByContainer) {
containerID := getContainerID(pod.Status.ContainerStatuses, container.Name)
if containerID == "" {
Expand All @@ -225,7 +225,7 @@ func fetchAndSetEnvVarsFromDockerfile(ctx context.Context, criClient criwrapper.
state = odigosv1.ProcessingStateFailed
} else {
state = odigosv1.ProcessingStateSucceeded
runtimeDetailsByContainer.EnvVarsFromDockerFile = envVars
runtimeDetailsByContainer.EnvFromContainerRuntime = envVars
}

runtimeDetailsByContainer.RuntimeUpdateState = &state
Expand Down

0 comments on commit 68967e0

Please sign in to comment.