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

Update: enable OS_DEBUG #1246

Merged

Conversation

till
Copy link
Contributor

@till till commented May 13, 2021

  • when TF_LOG is debug/trace
  • enable this by default (person probably wants it)

Resolves: #1203

@theopenlab-ci
Copy link

theopenlab-ci bot commented May 13, 2021

Build succeeded.

@@ -403,6 +406,13 @@ func Provider() terraform.ResourceProvider {
return configureProvider(d, terraformVersion)
}

// enforce OS_DEBUG when TF_LOG is 'DEBUG' or 'TRACE'
Copy link
Member

Choose a reason for hiding this comment

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

The idea is nice but I don't like the implementation when we rewrite some environment variables in the system to change the behaviour of the gophercloud/utils library.

I think that we need to configure logger in that library when we have DEBUG or TRACE loglevel.

https://github.com/gophercloud/utils/blob/master/terraform/auth/config.go#L182

There should be a way to configure it. Or maybe we need a PR to gophercloud/utils to configure logger (or using &osClient.DefaultLogger{} programmatically, without dealing with env variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't think I was "rewriting" it as I am setting it when it's not set. But I'll have a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ozerovandrei I made a PR over there: gophercloud/utils#153 — is this what you were thinking? I am not sure what the release cycle is, but I can re-work this PR when there is a release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ozerovandrei Can I just update the dependency in this PR?

Copy link
Member

Choose a reason for hiding this comment

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

Sure, you can update the dependency here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ozerovandrei reworked my approach, rebased and then also updated gophercloud/utils with go get github.com/gophercloud/utils@latest. Can you have a look again?

till added a commit to hostwithquantum/gophercloud-utils that referenced this pull request May 22, 2021
Hopefully didn't change much and kept all BC. The idea is to allow
the terraform openstack provider to enable logging using the
configuration struct, vs. using environment variables.

Related:
terraform-provider-openstack/terraform-provider-openstack#1246
jtopjian pushed a commit to gophercloud/utils that referenced this pull request May 30, 2021
Hopefully didn't change much and kept all BC. The idea is to allow
the terraform openstack provider to enable logging using the
configuration struct, vs. using environment variables.

Related:
terraform-provider-openstack/terraform-provider-openstack#1246
@theopenlab-ci
Copy link

theopenlab-ci bot commented Jun 5, 2021

Build failed.

@till
Copy link
Contributor Author

till commented Jun 5, 2021

On both builds, devstack fails on ubuntu-bionic:

2021-06-05 13:04:36.324892 | ubuntu-bionic | + echo 'Running devstack'
2021-06-05 13:04:36.324965 | ubuntu-bionic | Running devstack
2021-06-05 13:04:36.324977 | ubuntu-bionic | + echo '... this takes 10 - 15 minutes (logs in logs/devstacklog.txt.gz)'
2021-06-05 13:04:36.324987 | ubuntu-bionic | ... this takes 10 - 15 minutes (logs in logs/devstacklog.txt.gz)
2021-06-05 13:04:36.325106 | ubuntu-bionic | ++ date +%s
2021-06-05 13:04:36.326529 | ubuntu-bionic | + start=1622898276
2021-06-05 13:04:36.326555 | ubuntu-bionic | + /tmp/ansible/bin/ansible primary -f 5 -i /home/zuul/workspace/inventory -m shell -a 'cd '\''/opt/stack/new/devstack'\'' && sudo -H -u stack DSTOOLS_VERSION=0.4.0 stdbuf -oL -eL ./stack.sh 2>&1 executable=/bin/bash'
2021-06-05 13:04:40.083227 | ubuntu-bionic | ERROR: the main setup script run by this job failed - exit code: 2
2021-06-05 13:04:40.083324 | ubuntu-bionic |     please look at the relevant log files to determine the root cause
2021-06-05 13:04:40.083339 | ubuntu-bionic | Running devstack worlddump.py
2021-06-05 13:04:41.251973 | ubuntu-bionic | Cleaning up host
2021-06-05 13:04:41.252030 | ubuntu-bionic | ... this takes 3 - 4 minutes (logs at logs/devstack-gate-cleanup-host.txt.gz)
2021-06-05 13:05:08.322827 | ubuntu-bionic |  [WARNING]: No hosts matched, nothing to do
2021-06-05 13:05:11.342189 | ubuntu-bionic | Done.
2021-06-05 13:05:12.925314 | ubuntu-bionic | *** FAILED with status: 2
2021-06-05 13:05:23.455488 | ubuntu-bionic | ERROR
2021-06-05 13:05:23.455854 | ubuntu-bionic | {
2021-06-05 13:05:23.455951 | ubuntu-bionic |   "delta": "0:04:04.849504",
2021-06-05 13:05:23.456039 | ubuntu-bionic |   "end": "2021-06-05 13:05:12.926319",
2021-06-05 13:05:23.456106 | ubuntu-bionic |   "msg": "non-zero return code",
2021-06-05 13:05:23.456173 | ubuntu-bionic |   "rc": 2,
2021-06-05 13:05:23.456238 | ubuntu-bionic |   "start": "2021-06-05 13:01:08.076815"
2021-06-05 13:05:23.456303 | ubuntu-bionic | }
2021-06-05 13:05:23.497499 | 
2021-06-05 13:05:23.497616 | PLAY RECAP
2021-06-05 13:05:23.497718 | ubuntu-bionic | ok: 16 changed: 13 unreachable: 0 failed: 1 skipped: 15 rescued: 0 ignored: 1

Probably (hopefully) not related.

I had a look though:
https://logs.openlabtesting.org/logs/46/1246/5c77f96edec77bde7a3d76609a559177183198d4/check/terraform-provider-openstack-acceptance-test-admin/e9b5f2f/logs/devstack-gate-cleanup-host.txt

I can't tell exactly where it fails, so there is a command not found in the middle and it's grep'ing for too many things that don't exist. Nothing looks related to what I did. 🤷🏼

@till till requested a review from ozerovandrei June 5, 2021 13:33
openstack/provider.go Outdated Show resolved Hide resolved
@frittentheke
Copy link

@till this is really a nice feature.
Could you maybe rebase this once more and work in the changes @ozerovandrei asked for?

@till
Copy link
Contributor Author

till commented Jun 29, 2021

@frittentheke yes, will do — I hope I get to it all by Friday or earlier. Maybe during the ⚽ game tonight. :D

@till till force-pushed the chore-os_debug branch 2 times, most recently from 048a90a to 8e8ecc7 Compare July 27, 2021 11:50
@till
Copy link
Contributor Author

till commented Jul 27, 2021

@frittentheke @ozerovandrei hope I addressed everything. Let me know!

@till
Copy link
Contributor Author

till commented Aug 3, 2021

Can anyone take a look? 👀

@frittentheke
Copy link

frittentheke commented Aug 4, 2021

Can anyone take a look? eyes

Sorry @till for picking this up just now and thanks for keeping at it!

I built and tested the provider and things work just as expected.

But you are lacking the change to go.mod (bumping the dependency to github.com/gophercloud/utils containing your MR gophercloud/utils#153) ... I pulled in latest and it should look like this:

diff --git a/go.mod b/go.mod
index 0f37754e..711ddf1d 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.15
 
 require (
        github.com/gophercloud/gophercloud v0.17.1-0.20210517213536-0be823b69be8
-       github.com/gophercloud/utils v0.0.0-20210216074907-f6de111f2eae
+       github.com/gophercloud/utils v0.0.0-20210720165645-8a3ad2ad9e70
        github.com/hashicorp/terraform-plugin-sdk v1.17.2
        github.com/mitchellh/go-homedir v1.1.0
        github.com/stretchr/testify v1.7.0

@till
Copy link
Contributor Author

till commented Aug 9, 2021

@frittentheke Sorry, probably screwed up my rebase. Will fix.

@frittentheke
Copy link

@till I just remembered this PR when digging into an issue (#1307).

Could you maybe get this change rebased to finally close #1203 ?

 - when TF_LOG is debug/trace (and OS_DEBUG is not set)
 - enable this by default (person probably wants it)

Resolves: terraform-provider-openstack#1203
@till
Copy link
Contributor Author

till commented Jan 23, 2022

@frittentheke I tried my best to rebase it again. Can you or anyone else see if this can get integrated soon? Otherwise, feel free to pick the commits from my fork. I am also happy if this lands in the official code and I can stop patching it. :)

@theopenlab-ci
Copy link

theopenlab-ci bot commented Jan 23, 2022

@frittentheke
Copy link

@ozerovandrei could you kindly take an other look at this. I quite like the change and usually do exactly that manually anyways.

@till
Copy link
Contributor Author

till commented Feb 1, 2022

@ozerovandrei sorry to bug, but can you take a look this week? Or is there someone else who can?

Copy link
Member

@ozerovandrei ozerovandrei left a comment

Choose a reason for hiding this comment

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

LGTM thank you @till

@ozerovandrei ozerovandrei merged commit be44786 into terraform-provider-openstack:main Feb 6, 2022
@till
Copy link
Contributor Author

till commented Feb 6, 2022

Thanks very much!

@till till deleted the chore-os_debug branch February 6, 2022 16:38
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.

OS_DEBUG=1 and TF_LOG=DEBUG
3 participants