-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
hcp: reject iteration with diff template types #12132
Conversation
This cannot be merged as-is, as it needs an SDK update before we can consider that. |
0dc642c
to
9b9c61e
Compare
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 looks good to me. I tested with a locally generated SDK. Once the SDK is released we can get this merged in. I left a question about storing the template type on the Iteration type. Doesn't seem like it is need at this moment.
@@ -318,12 +322,12 @@ func (b *Bucket) createIteration() (*models.HashicorpCloudPackerIteration, error | |||
return createIterationResp.Payload.Iteration, nil | |||
} | |||
|
|||
func (b *Bucket) initializeIteration(ctx context.Context) error { | |||
func (b *Bucket) initializeIteration(ctx context.Context, templateType models.HashicorpCloudPackerIterationTemplateType) 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.
Do we want to persist the templateType on the actual iteration, like we do the Fingerprint and other related info?
In the Packer change log we need to call out the tracking of template types in HCP Packer registry as the PR title is more on rejecting the continuation of builds using a different template type. |
Yes, this should be highlighted in the changelog. In addition to this, we could also change the title of the PR if you prefer to highlight this change? |
9b9c61e
to
a2dbaa2
Compare
The grpc_gateway v2 changes had some repercussions in the payloads of the API calls, making the current code non-functional against the latest SDK.
In order to ensure users keep the same templates between two packer invocations for a single iteration, we start tracking the type of template used when building images.
As a follow-up to tracking the template type for an iteration, we actively check that it remains consistent between two invocations of packer, and reject the update if it is not the case.
a2dbaa2
to
eea22b9
Compare
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Right now if someone starts an HCP build, which doesn't end with full completion for any reason (cancellation, only/except, etc.), and starts building the same iteration again with a template that is different in its type (HCL2/JSON), we let them do, which makes for some unpredictable behaviour, as the naming scheme for the two types are different.
To prevent this issue, we check-in the template type when we create the iteration, and reject any subsequent builds with a template that is of a different type.