Skip to content

Commit 5003f7d

Browse files
authored
remove unnecessary execution env vars (#4806)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Removed environment variable tracking for `NODE_ID`, `JOB_NAME`, and `JOB_NAMESPACE` in job execution. - Updated test cases to remove node-specific verifications and focus on partition-specific outputs. - Adjusted expected outputs in tests to reflect changes in environment variable priorities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 7bd50cc commit 5003f7d

File tree

3 files changed

+5
-32
lines changed

3 files changed

+5
-32
lines changed

pkg/compute/envvars.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ func GetExecutionEnvVars(execution *models.Execution) map[string]string {
2525
// Build system environment variables
2626
sysEnv := make(map[string]string)
2727
sysEnv[models.EnvVarPrefix+"EXECUTION_ID"] = execution.ID
28-
sysEnv[models.EnvVarPrefix+"NODE_ID"] = envvar.Sanitize(execution.NodeID)
2928

3029
// Add job-related environment variables if job exists
3130
if execution.Job != nil {
3231
sysEnv[models.EnvVarPrefix+"JOB_ID"] = execution.JobID
33-
sysEnv[models.EnvVarPrefix+"JOB_NAME"] = envvar.Sanitize(execution.Job.Name)
34-
sysEnv[models.EnvVarPrefix+"JOB_NAMESPACE"] = envvar.Sanitize(execution.Job.Namespace)
3532
sysEnv[models.EnvVarPrefix+"JOB_TYPE"] = execution.Job.Type
3633

3734
// Add partition-related environment variables

pkg/compute/envvars_test.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ func TestGetExecutionEnvVars(t *testing.T) {
2929
},
3030
want: map[string]string{
3131
"BACALHAU_EXECUTION_ID": "exec-1",
32-
"BACALHAU_NODE_ID": "node-1",
3332
},
3433
},
3534
{
@@ -53,10 +52,7 @@ func TestGetExecutionEnvVars(t *testing.T) {
5352
},
5453
want: map[string]string{
5554
"BACALHAU_EXECUTION_ID": "exec-1",
56-
"BACALHAU_NODE_ID": "node-1",
5755
"BACALHAU_JOB_ID": "job-1",
58-
"BACALHAU_JOB_NAME": "test-job",
59-
"BACALHAU_JOB_NAMESPACE": "default",
6056
"BACALHAU_JOB_TYPE": "batch",
6157
"BACALHAU_PARTITION_INDEX": "0",
6258
"BACALHAU_PARTITION_COUNT": "3",
@@ -77,9 +73,9 @@ func TestGetExecutionEnvVars(t *testing.T) {
7773
{
7874
Name: "task-1",
7975
Env: map[string]string{
80-
"MY_VAR": "my-value",
81-
"BACALHAU_NODE_ID": "should-not-override", // Should not override system env
82-
"OTHER_VAR": "other-value",
76+
"MY_VAR": "my-value",
77+
"BACALHAU_JOB_TYPE": "should-not-override", // Should not override system env
78+
"OTHER_VAR": "other-value",
8379
},
8480
},
8581
},
@@ -88,10 +84,7 @@ func TestGetExecutionEnvVars(t *testing.T) {
8884
},
8985
want: map[string]string{
9086
"BACALHAU_EXECUTION_ID": "exec-1",
91-
"BACALHAU_NODE_ID": "node-1", // System value takes precedence
9287
"BACALHAU_JOB_ID": "job-1",
93-
"BACALHAU_JOB_NAME": "test-job",
94-
"BACALHAU_JOB_NAMESPACE": "default",
9588
"BACALHAU_JOB_TYPE": "batch",
9689
"BACALHAU_PARTITION_INDEX": "0",
9790
"BACALHAU_PARTITION_COUNT": "3",
@@ -120,10 +113,7 @@ func TestGetExecutionEnvVars(t *testing.T) {
120113
},
121114
want: map[string]string{
122115
"BACALHAU_EXECUTION_ID": "exec-1",
123-
"BACALHAU_NODE_ID": "node-1",
124116
"BACALHAU_JOB_ID": "job-1",
125-
"BACALHAU_JOB_NAME": "test_job_with_spaces", // Sanitized
126-
"BACALHAU_JOB_NAMESPACE": "test_namespace", // Sanitized
127117
"BACALHAU_JOB_TYPE": "batch",
128118
"BACALHAU_PARTITION_INDEX": "0",
129119
"BACALHAU_PARTITION_COUNT": "1",

pkg/test/devstack/partitioning_test.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ func (s *PartitionSuite) TestSinglePartition() {
6262
[]string{
6363
"BACALHAU_EXECUTION_ID=",
6464
"BACALHAU_JOB_ID=",
65-
"BACALHAU_JOB_NAME=" + s.T().Name(),
66-
"BACALHAU_JOB_NAMESPACE=default",
6765
"BACALHAU_JOB_TYPE=batch",
68-
"BACALHAU_NODE_ID=node-0",
6966
"BACALHAU_PARTITION_COUNT=1",
7067
"BACALHAU_PARTITION_INDEX=0",
7168
},
@@ -98,7 +95,7 @@ func (s *PartitionSuite) TestMultiplePartitions() {
9895
Name: s.T().Name(),
9996
Engine: dockmodels.NewDockerEngineBuilder("busybox:1.37.0").
10097
WithEntrypoint("sh", "-c",
101-
"echo Node=${BACALHAU_NODE_ID} Partition=${BACALHAU_PARTITION_INDEX} of ${BACALHAU_PARTITION_COUNT}",
98+
"echo Partition=${BACALHAU_PARTITION_INDEX} of ${BACALHAU_PARTITION_COUNT}",
10299
).
103100
MustBuild(),
104101
Publisher: publisher_local.NewSpecConfig(),
@@ -116,16 +113,6 @@ func (s *PartitionSuite) TestMultiplePartitions() {
116113
},
117114
-1,
118115
),
119-
// Verify they run on the nodes
120-
scenario.FileContains(
121-
"stdout",
122-
[]string{
123-
"Node=node-0",
124-
"Node=node-1",
125-
"Node=node-2",
126-
},
127-
-1,
128-
),
129116
),
130117
JobCheckers: []scenario.StateChecks{
131118
scenario.WaitForSuccessfulCompletion(),
@@ -155,9 +142,8 @@ func (s *PartitionSuite) TestPartitionRetry() {
155142
ExternalHooks: noop.ExecutorConfigExternalHooks{
156143
JobHandler: func(ctx context.Context, execContext noop.ExecutionContext) (*models.RunCommandResult, error) {
157144
partition := execContext.Env["BACALHAU_PARTITION_INDEX"]
158-
nodeID := execContext.Env["BACALHAU_NODE_ID"]
159145

160-
output := fmt.Sprintf("Running partition %s on node %s\n", partition, nodeID)
146+
output := fmt.Sprintf("Running partition %s\n", partition)
161147

162148
// Only increment attempt counter for partition 1
163149
var currentAttempt int32

0 commit comments

Comments
 (0)