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

Validation period start/end time generation doesn't work on MacOS #73

Closed
Nuttymoon opened this issue Jun 20, 2023 · 6 comments · Fixed by #75
Closed

Validation period start/end time generation doesn't work on MacOS #73

Nuttymoon opened this issue Jun 20, 2023 · 6 comments · Fixed by #75
Labels
bug Something isn't working help wanted Extra attention is needed macos

Comments

@Nuttymoon
Copy link
Contributor

Nuttymoon commented Jun 20, 2023

When adding a validator to a Subnet, we use date to generate subnet_validator_start_time and subnet_validator_end_time:

subnet_validator_start_time: '{{ lookup("pipe", "date -d ''2 minutes'' --rfc-3339=seconds").replace(" ", "T") }}' # in 2 minutes
subnet_validator_end_time: '{{ lookup("pipe", "date -d ''1 week'' --rfc-3339=seconds").replace(" ", "T") }}' # in 1 week

subnet_validator_start_time: '{{ lookup("pipe", "date -d ''2 minutes'' --rfc-3339=seconds").replace(" ", "T") }}' # in 2 minutes
subnet_validator_end_time: '{{ lookup("pipe", "date -d ''1 week'' --rfc-3339=seconds").replace(" ", "T") }}' # in 1 week

A user reported that the default command doesn't work on MacOS.

I see 2 solutions:

  • If possible we can try to find a command that works both on Linux and MacOS.
  • Otherwise, we can template the variable based on the current OS.

Help wanted: We don't have Macs at our disposal for testing, so we need a MacOS user to find the right date command to obtain a string in RFC 3339 format, e.g. 2023-06-20T11:28:28+02:00. Note that extra Jinja filters can be used to adapt the format (see replace() usage above).

@Nuttymoon Nuttymoon added bug Something isn't working help wanted Extra attention is needed macos labels Jun 20, 2023
@pedro-sys
Copy link

You can try with
subnet_validator_start_time: "{{ lookup('pipe', "date -v+2M '+%Y-%m-%dT%H:%M:%SZ'") }}"
subnet_validator_end_time: "{{ lookup('pipe', "date -v+1w '+%Y-%m-%dT%H:%M:%SZ'") }}"

@leopaul36
Copy link
Contributor

You can try with subnet_validator_start_time: "{{ lookup('pipe', "date -v+2M '+%Y-%m-%dT%H:%M:%SZ'") }}" subnet_validator_end_time: "{{ lookup('pipe', "date -v+1w '+%Y-%m-%dT%H:%M:%SZ'") }}"

Unfortunately date -v+2M '+%Y-%m-%dT%H:%M:%SZ' does not seem to be working on Linux, I guess we will have to template a different command depending on the OS.

@Nuttymoon
Copy link
Contributor Author

You can try with subnet_validator_start_time: "{{ lookup('pipe', "date -v+2M '+%Y-%m-%dT%H:%M:%SZ'") }}" subnet_validator_end_time: "{{ lookup('pipe', "date -v+1w '+%Y-%m-%dT%H:%M:%SZ'") }}"

Unfortunately date -v+2M '+%Y-%m-%dT%H:%M:%SZ' does not seem to be working on Linux, I guess we will have to template a different command depending on the OS.

Yes I think we can do that by using the os_family fact.

@leopaul36
Copy link
Contributor

Implemented in #75

Would you be able to try this PR @pedro-sys ? Ansible should now pick the good MacOS command seamlessly.

@pedro-sys
Copy link

hello
It work perfectly !!

@leopaul36
Copy link
Contributor

hello It work perfectly !!

Great! Thanks for testing @pedro-sys.

I'll let @Nuttymoon review and then merge to main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed macos
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants