Skip to content

fix: add DiffSuppressFunc to compare lists in GPU configuration#502

Merged
kasia-kujawa merged 1 commit intomasterfrom
kkujawa_add_DiffSuppressFunc
Jun 12, 2025
Merged

fix: add DiffSuppressFunc to compare lists in GPU configuration#502
kasia-kujawa merged 1 commit intomasterfrom
kkujawa_add_DiffSuppressFunc

Conversation

@kasia-kujawa
Copy link
Copy Markdown
Contributor

@kasia-kujawa kasia-kujawa commented Jun 12, 2025

Following issue was observed:
image
Terraform read a state as zero values but they were nils, and then changes were visible even when no changes were added in NodeTemplate.
In such old and new values were the same internally:

 old ([]interface {}) (len=1 cap=1) {
	 (map[string]interface {}) (len=3) {
	  (string) (len=19) "enable_time_sharing": (bool) false,
	  (string) (len=30) "default_shared_clients_per_gpu": (int) 0,
	  (string) (len=21) "sharing_configuration": ([]interface {}) {
	  }
	 }
	}
new ([]interface {}) (len=1 cap=1) {
	 (map[string]interface {}) (len=3) {
	  (string) (len=19) "enable_time_sharing": (bool) false,
	  (string) (len=30) "default_shared_clients_per_gpu": (int) 0,
	  (string) (len=21) "sharing_configuration": ([]interface {}) {
	  }
	 }
	}

but Terraform presented it differently.

  • In Terraform nil values for optional attributes are serialized as zero values.
  • When you read the state, the value is shown as 0, but it's actually unset; Terraform treats missing or unset optional attributes as zero values by default.
  • There is general problem with detecting changes in Terraform lists, this merge requests add custom comparison of lists, example issue in Terraform SDK: DiffSuppressFunc doesn't work for list-type attributes hashicorp/terraform-plugin-sdk#477

I removed changes gpu configuration from basic test as this test without gpu configuration will detect if any changes remains after applying the configuration when gpu is not configured.

@kasia-kujawa kasia-kujawa force-pushed the kkujawa_add_DiffSuppressFunc branch from e3e2d1a to bf3337c Compare June 12, 2025 07:16
@kasia-kujawa kasia-kujawa marked this pull request as ready for review June 12, 2025 07:54
@kasia-kujawa kasia-kujawa requested a review from a team as a code owner June 12, 2025 07:54
@kasia-kujawa kasia-kujawa merged commit dbe98ff into master Jun 12, 2025
10 checks passed
@kasia-kujawa kasia-kujawa deleted the kkujawa_add_DiffSuppressFunc branch June 12, 2025 11:48
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.

2 participants