Skip to content

Identity v2&v3: add RequestOpts.OmitHeaders, remove blank header#2315

Merged
EmilienM merged 1 commit intogophercloud:masterfrom
freedywu:master
May 30, 2022
Merged

Identity v2&v3: add RequestOpts.OmitHeaders, remove blank header#2315
EmilienM merged 1 commit intogophercloud:masterfrom
freedywu:master

Conversation

@freedywu
Copy link
Copy Markdown
Contributor

Fixes #2314

Comment on lines +330 to +333
// OmitHeaders specifies the HTTP headers which should be omitted.
OmitHeaders []string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In your implementation, OmitHeaders takes precedence over MoreHeaders. Please mention that in the docstring.

}
}

for _, v := range options.OmitHeaders {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: please update the comment on lines 399-400

}

for _, v := range options.OmitHeaders {
req.Header.Del(v)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there any concern that the headers from client.AuthenticatedHeaders() will override this setting (line 420-422)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before commit 29581a2, client.AuthenticatedHeaders() is prior to options.MoreHeaders. In my case, options.OmitHeaders makes up for the previous options.MoreHeaders and should inherit the original order

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah, we expected that something could be broken, see #2215 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure that something is broken yet, though. I think there needs to be some investigation and comparison to @freedywu's use-case that is triggering this and the basic acceptance test that passes without changes required.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any concern that the headers from client.AuthenticatedHeaders() will override this setting

I think it should be okay given that the order of the existing code has MoreHeaders first adding an empty X-Auth-Token and then client.AuthenticatedHeaders adds headers on top of it. Definitely warrants running this PR through the Keystone suite of acceptance tests, though.

@coveralls
Copy link
Copy Markdown

coveralls commented Jan 10, 2022

Coverage Status

Coverage decreased (-0.005%) to 79.904% when pulling 613261b on freedywu:master into a166250 on gophercloud:master.

@freedywu
Copy link
Copy Markdown
Contributor Author

@pierreprinetti

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Jan 10, 2022

Build succeeded.

@jtopjian
Copy link
Copy Markdown
Contributor

Per discussion in #2314, it looks like the root cause is a very old version of Keystone triggering this issue.

In my opinion, if the Keystone suite of acceptance tests passes with this PR, it should be fine to merge. It's not a lot of work to help get this functionality fixed and adds a feature that may be useful in other areas. And right now, the only place OmitHeaders is used is in the token creation functions, so that limits the scope of what's being modified.

@EmilienM
Copy link
Copy Markdown
Contributor

@freedywu could you please rebase on master, so we get the new CI job for Keystone? Thanks

@freedywu
Copy link
Copy Markdown
Contributor Author

@freedywu could you please rebase on master, so we get the new CI job for Keystone? Thanks

Sure, thanks for noticing.

@freedywu
Copy link
Copy Markdown
Contributor Author

Hi @EmilienM , my commit has been rebased, could you have a look at it?

Copy link
Copy Markdown
Contributor

@mandre mandre left a comment

Choose a reason for hiding this comment

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

LGTM, the code looks safe, and the identity acceptance tests worked as expected.
Any objection to merge?

@EmilienM EmilienM merged commit c0c8d2a into gophercloud:master May 30, 2022
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.

OpenStack V2 Authentication Failed since RequestOpts.MoreHeaders does not make sense

7 participants