-
Notifications
You must be signed in to change notification settings - Fork 13
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
Transitioning to buildscript is handled explicitly #3199
Conversation
# Conflicts: # internal/locale/locales/en-us.yaml # internal/runbits/refresh.go # internal/runbits/runtime/runtime.go # internal/runners/deploy/deploy.go # internal/runners/exec/exec.go # internal/runners/prepare/prepare.go # internal/runners/reset/reset.go # internal/scriptrun/scriptrun.go # pkg/platform/runtime/runtime.go
If I opt into buildscripts and then attempt to checkout a project, it will immediately fail:
If I prepend
Apparently I need to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a large PR so I tried to provide some higher level feedback. Overall the migration implementation looks good to me and makes sense.
if err != nil { | ||
return errs.Wrap(err, "Could not solve runtime") | ||
} | ||
if strings.ToLower(os.Getenv(constants.DisableRuntime)) != "true" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It's unfortunate that we have to have this here. Currently, outside of tests, this environment variable is only checked in the runtime
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah agreed, but I don't see a way to address this without significant refactoring, which is what we're already planning on, just not for this story.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, I didn't want to tag this as anything other than a nit because I know we have the refactor coming.
// If updating failed due to unidentified errors, and the user is not authenticated, add a tip suggesting that they authenticate as | ||
// this may be a private project. | ||
// Note since we cannot assert the actual error type we do not wrap this as user-facing, as we do not know what we're | ||
// dealing with so the localized underlying errors are more appropriate. | ||
case isUpdateErr && !auth.Authenticated(): | ||
case !auth.Authenticated(): // MUST BE LAST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is not asserting an error, it's decorating an unknown error. And all the other assertions are for asserting an error.
I've updated the code with a comment and some protection against accidental refactoring.
Note the original implementation was bugged:
It was ignoring errors if those non-error assertions were evaluated. We really should void using rationalizers to do anything that's not error assertion related.
internal/runbits/runtime/refresh.go
Outdated
|
||
const ( | ||
OptNone Opts = 1 << iota | ||
OptMinimalUI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be something that is set in the outputter
or in some sort of output layer? From reading just this file I'm not sure what this means and why it's coupled with the order changing, at least in terms of options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add comments. I have no intention of using this outside of this package, or even beyond the runtime refactor. This is effectively a temporary workaround to get around the increasingly lacking architecture.
err = runtime.RefreshRuntime(r.auth, r.out, r.analytics, r.project, commitID, true, target.TriggerReset, r.svcModel, r.cfg) | ||
// Ensure the buildscript exists. Normally we should never do this, but reset is used for resetting from a corrupted | ||
// state, so it is appropriate. | ||
if r.cfg.GetBool(constants.OptinBuildscriptsConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we considered centralizing the check of this config option to the buildscript
package? Similar to how the DisableRuntime
environment variable has worked before. It looks like every use, at least in this PR is followed by a call out to that package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really the same thing, the runtime instance is still getting called regardless of the env var, it just behaves differently. In this case we're not doing anything with the buildscript outside of this one call. Add to that the fact that we have some commands like commit and eval that do not care about this config, and it just makes more sense to have it in the runner.
@@ -266,39 +282,51 @@ func (b *BuildPlanByProject) CommitID() (strfmt.UUID, error) { | |||
} | |||
|
|||
type BuildPlanByCommit struct { | |||
Commit *Commit `json:"commit"` | |||
commit *Commit `json:"commit"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that by making this field private the encoding/json
package will not be able to access it so marhsalling/unmarshalling may fail. Maybe that's changed but I remember getting caught by this before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Urgh you're right, thanks for catching!
if project.ConfigVersion > ConfigVersion { | ||
return nil, locale.NewInputError("err_projectfile_version_too_high") | ||
} | ||
updatedConfigVersion, errMigrate := migrator(project, ConfigVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will lose this error if anything on line 483 fails. We may want to log it in that case if this could be valuable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Perfect job for errs.Pack()
.
pkg/projectfile/yamlfield.go
Outdated
return &yamlField{field: field, value: value} | ||
} | ||
|
||
func (y *yamlField) Save(path string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this feels low level enough to have a unit test.
# Conflicts: # internal/locale/locales/en-us.yaml # internal/runners/packages/list.go # internal/runners/swtch/switch.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Just left a couple of minor comments, not meant to hold up the PR.
if _, ok := artifactsDone[m.ArtifactID]; ok { | ||
multilog.Critical("buildlogstreamer sent duplicate ArtifactSucceededMessage for artifact %s", m.ArtifactID.String()) | ||
break | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to be a part of another story?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, yeah.. I had run git reset
, not sure why this is still in :\
This is addressing several things:
state reset
.state reset LOCAL