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
Variable preview is misleading when a variable is scoped to a role other than the one on the step. #6944
Comments
@donnybell What is the result you expect?
In your scenario the step role is |
The ranking code is:
Environment = So the scores for
Despite the |
The variable preview is misleading (internal reproduction) When a specific deployment target is selected, it should take the target's roles into account: If you select the |
Proposed solution
Alternate
|
Hi, this was my bug so thought I'd share my thoughts if that's ok. Firstly there's two ways of previewing what would happen aren't there. The 'Preview' under Variables was not great as the scoping only allows single selection, so making it multi would of helped. I ended up using the 'All' under Variables and filtering the list down as it allowed multi selection. With what you've put above as a solution, does it actually solve the issue as I can't see it say in the ranking code that it uses the TargetRole(s) of the Step, which should then obviously filter out the other variables. Not my code, so apologies if it does and I'm wrong! Re-reading it, is it the first bullet in 'Alternate'? I thought that was for the Preview not ranking code, so not sure :) |
@gurufordy Re-reading the ranking code I can see the confusion. Paul's blog post does a good job of covering the reasons behind this quirk. |
Thanks @droyad, thanks for the link and yeah that does read right now 👍 I'm not sure the Role and Deployment Target filters are mutually exclusive though are they? I assumed the Role is there in place of the Step Role that a deployment would have? Also if most of the changes are around the preview, is there an actual fix for the deployment evaluation? |
The step role can be determined from the selected step
Given the scenario described in the first section of this issue, it is working as intended (and described in the docs/blog) I think. |
Actually looking over the example and relating it back to my actual issue, you may be right that it's not an issue. I guess it's a misunderstanding, but I thought having an extra scoping to a different role, would only use that value on a step with the matching role, i.e. Donny's example I expect it to evaluate to 1 as the scoping for value 3 is ignored due to not a matching role. So in short the scoping of a variable does not always work on an exact match basis(?) |
I would put it that scoping of a variables to roles is based on the target's roles and that the step role is only used as a tie breaker. |
Would the tie breaker not be needed in this example though as without the step role it's got two different values for the variable? Sorry to keep probing, but this is a little counter-intuitive to me. Are there any other scoping values that are not used explicitly like the step role? |
In this scenario there is no tie to break. The Tenant Tags scope would work in the same way. The tags on the tenant only are considered, not those on the step or any prior selection. The way I think of it is that the scope is applied to the thing. i.e. the Environment, or the target or tenant. Doing it this way does let you specify say a proxy value or subnet gateway to a group of targets independent of the step role. |
Release Note: Remove role input from variable preview, instead retrieve role scope based on the deployment target selected |
🎉 The fix for this issue has been released in:
|
Original report preserved for context, see the thread for the problem
Prerequisites
The bug
Variables are not honoring Step Role Scoping in certain situations
What I expected to happen
Variable evaluations should honor the scope specificity and take the Step Role into consideration first.
https://octopus.com/docs/projects/variables#Scopingvariables-Scopespecificity
Steps to reproduce
write-host $variable1
Run on each deployment target
Dev
variable1
with the following values:1
scoped toDev
Environment2
scoped toTest
Environment#{variable2}
scoped toExtra
Rolevariable2
with the following values:3
scoped toDev
Environment andExtra
Role4
scoped toTest
Environment andExtra
RoleDev
Environment withDev
andExtra
Roles3
Screen capture
Step 1
Step 2 and 3
Step 4
Variable Preview
Task Log
Affected versions
Confirmed on 2021.1.7469
Workarounds
None
Links
Internal Link
The text was updated successfully, but these errors were encountered: