Skip to content

Conversation

@dm3ch
Copy link
Contributor

@dm3ch dm3ch commented Jan 12, 2023

what

  • Add support for AutoTune

why

  • Provide support of AutoTune feature

references

@dm3ch dm3ch requested review from a team as code owners January 12, 2023 17:59
@goruha
Copy link
Member

goruha commented Feb 16, 2023

/test all

variables.tf Outdated
default = null
}

variable "auto_tune_cron_schedule" {
Copy link
Member

Choose a reason for hiding this comment

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

@dm3ch
pls add here the default value; otherwise, this is a required variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These values are not used by default (if auto_tune_enabled = false), so requiring them is not a best option.
And there's no default value in provider as far as I remember.

So I see 2 possible options how it can be done:

  • Add some default value, which we would think optimal
  • Try to add a validation rule that would check if auto_tune_enabled = true and require variable in this case

What do you think would be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I remember validation condition can't refer to other vars, so the second option is impossible. :(

So to be honest I don't know how to better workaround this. Do you have any thoughts?

variables.tf Outdated
description = "A cron expression specifying the recurrence pattern for an Auto-Tune maintenance schedule."
}

variable "auto_tune_duration" {
Copy link
Member

Choose a reason for hiding this comment

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

@dm3ch
pls add here the default value; otherwise, this is a required variable.

@goruha goruha self-assigned this Feb 16, 2023
dm3ch and others added 2 commits February 16, 2023 18:04
Co-authored-by: Igor Rodionov  <goruha@gmail.com>
Co-authored-by: Igor Rodionov  <goruha@gmail.com>
@goruha goruha mentioned this pull request Feb 17, 2023
@goruha
Copy link
Member

goruha commented Feb 17, 2023

/test all

dm3ch and others added 3 commits February 17, 2023 14:35
@dm3ch
Copy link
Contributor Author

dm3ch commented Feb 17, 2023

@goruha Reworked input variable for auto tune to an object to be able to validate values if auto tune is enabled to not add default values (cause provider doesn't have default values for that).

Could you please re-review?

@dm3ch dm3ch requested review from goruha and removed request for RothAndrew and florian0410 February 17, 2023 11:53
@goruha
Copy link
Member

goruha commented Feb 17, 2023

/test all

@goruha
Copy link
Member

goruha commented Feb 17, 2023

@dm3ch

tests still failed

First reason - terraform lint

not ok 8 check if terraform code is valid
# (from function `setup' in test file test/.test-harness/test/terraform/validate.bats, line 7)
#   `terraform init >/dev/null' failed
# There are some problems with the configuration, described below.
#
# The Terraform configuration must be valid before initialization so that
# Terraform can determine which modules and providers need to be installed.
# 
# Error: Invalid reference in variable validation
#
#   on variables.tf line 394, in variable "auto_tune":
#  394:     condition     = var.auto_tune.enabled == true && var.cron_schedule != null
# 
# The condition for variable "auto_tune" can only refer to the variable itself,
# using var.auto_tune.
# 
# 
# Error: Invalid validation error message
#
#   on variables.tf line [39](https://github.com/cloudposse/actions/actions/runs/4203523341/jobs/7293033803#step:8:40)5, in variable "auto_tune":
#  395:     error_message = "var.auto_tune.cron_schedule should be set if var.auto_tune.enabled == true"
# 
# Validation error message must be at least one full English sentence starting
# with an uppercase letter and ending with a period or question mark.
# 
# 
# Error: Invalid reference in variable validation
#
#   on variables.tf line 399, in variable "auto_tune":
#  399:     condition     = var.auto_tune.enabled == true && var.duration != null
# 
# The condition for variable "auto_tune" can only refer to the variable itself,
# using var.auto_tune.
# 
# 
# Error: Invalid validation error message
#
#   on variables.tf line [40](https://github.com/cloudposse/actions/actions/runs/4203523341/jobs/7293033803#step:8:41)0, in variable "auto_tune":
#  400:     error_message = "var.auto_tune.duration should be set if var.auto_tune.enabled == true"
# 
# Validation error message must be at least one full English sentence starting
# with an uppercase letter and ending with a period or question mark.
# 
# 
# Error: Invalid validation error message
#
#   on variables.tf line 405, in variable "auto_tune":
#  405:     error_message = "var.auto_tune.rollback_on_disable valid values: DEFAULT_ROLLBACK or NO_ROLLBACK."
# 
# Validation error message must be at least one full English sentence starting
# with an uppercase letter and ending with a period or question mark.
#

The second reason - is, please, rebase the latest changes from the master branch - it looks like you lost it when did there rewrite

@dm3ch
Copy link
Contributor Author

dm3ch commented Feb 17, 2023

Seems to be done. But haven't try to run terraform lint locally

@goruha
Copy link
Member

goruha commented Feb 17, 2023

/test all

@goruha
Copy link
Member

goruha commented Feb 17, 2023

@dm3ch

Tests failed

Test: check if terraform code is valid
File: validate.bats
---------------------------------

Error: Invalid value for variable

  on ../../variables.tf line 367:
 367: variable "auto_tune" {

Variable auto_tune.cron_schedule should be set if var.auto_tune.enabled ==
true.

This was checked by the validation rule at ../../variables.tf:393,3-13.


Error: Invalid value for variable

  on ../../variables.tf line 367:
 367: variable "auto_tune" {

Variable auto_tune.duration should be set if var.auto_tune.enabled == true.

This was checked by the validation rule at ../../variables.tf:398,3-13.

Gime 5 minutes I will suggest fixes

@goruha
Copy link
Member

goruha commented Feb 17, 2023

@dm3ch check my suggestions

Co-authored-by: Igor Rodionov  <goruha@gmail.com>
@dm3ch
Copy link
Contributor Author

dm3ch commented Feb 17, 2023

@goruha Yep, TY, missed it.

Co-authored-by: Igor Rodionov  <goruha@gmail.com>
@dm3ch
Copy link
Contributor Author

dm3ch commented Feb 17, 2023

One more tests run?

Let's hope it would be final.

@goruha
Copy link
Member

goruha commented Feb 17, 2023

/test all

@goruha
Copy link
Member

goruha commented Feb 17, 2023

@dm3ch LGTM

@goruha goruha merged commit 7f83b65 into cloudposse:master Feb 17, 2023
matteomallus pushed a commit to matteomallus/terraform-aws-opensearch that referenced this pull request Dec 18, 2023
* Added AutoTune support

* Auto Format

* Update variables.tf

Co-authored-by: Igor Rodionov  <goruha@gmail.com>

* Update variables.tf

Co-authored-by: Igor Rodionov  <goruha@gmail.com>

* Update variables.tf

Co-authored-by: Igor Rodionov  <goruha@gmail.com>

* Auto Format

* Rework auto_tune variables to single object

* Try to fix variables.tf lint

* Auto Format

* Update variables.tf

Co-authored-by: Igor Rodionov  <goruha@gmail.com>

* Update variables.tf

Co-authored-by: Igor Rodionov  <goruha@gmail.com>

---------

Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>
Co-authored-by: Igor Rodionov  <goruha@gmail.com>
(cherry picked from commit 7f83b65)
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.

No support for autotune

3 participants