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

Feature/support skip create image #99

Merged

Conversation

newbieJerry
Copy link
Contributor

Overview of the Issue

Have a flag that allows user to skip the image creation, this can be useful for test builds and rapid validation.

Reproduction Steps

  1. create a packer script with "skip_create_image":"true"
  2. run the packer build

Plugin and Packer Version

  1. Packer v1.8.3
  2. packer-plugin-alicloud v1.0.5

Simplified Packer Buildfile

{
   "variables": {
     "access_key": "{{env `LTAI5tCzUL*********Z1iFQ`}}",
     "secret_key": "{{env `fwVAFD6UWC*********wgmilEhG6Td`}}"
   },
   "builders": [{
     "type":"alicloud-ecs",
     "access_key":"{{user `access_key`}}",
     "secret_key":"{{user `secret_key`}}",
     "region":"cn-beijing",
     "image_name":"packer_basic_2",
     "source_image":"ubuntu_20_04_x64_20G_alibase_20220824.vhd",
     "associate_public_ip_address":"true",
     "skip_create_image":"true",
     "ssh_username":"root",
     "instance_type":"ecs.n1.tiny",
     "internet_charge_type":"PayByTraffic",
     "io_optimized":"true"
   }],
   "provisioners": [{
     "type": "shell",
     "inline": ["echo foo"]
   }]
 }

Operating system and Environment details

macOS Monterey 12.6

Log Fragments and crash.log files

alicloud-ecs: Starting instance: i-2ze1xwqv0qz5fn3xpctk
==> alicloud-ecs: Using SSH communicator to connect: 39.105.44.173
==> alicloud-ecs: Waiting for SSH to become available...
==> alicloud-ecs: Connected to SSH!
==> alicloud-ecs: Provisioning with shell script: /var/folders/70/qctp4fb506l7yr9jxj2ctqx80000gp/T/packer-shell2504466809
alicloud-ecs: foo
==> alicloud-ecs: Stopping instance: i-2ze1xwqv0qz5fn3xpctk
==> alicloud-ecs: Waiting instance stopped: i-2ze1xwqv0qz5fn3xpctk
==> alicloud-ecs: Image build stopped because: you set skip_create_image true
alicloud-ecs: Detach keypair packer_6386b559-8cbe-66d6-8d95-e38bce34772c from instance: i-2ze1xwqv0qz5fn3xpctk
==> alicloud-ecs: Deleting EIP because of cancellation or error...
==> alicloud-ecs: Deleting instance because of cancellation or error...
==> alicloud-ecs: Deleting security group because of cancellation or error...

@newbieJerry newbieJerry requested a review from a team as a code owner December 17, 2022 06:23
@hashicorp-cla
Copy link

hashicorp-cla commented Dec 17, 2022

CLA assistant check
All committers have signed the CLA.

@newbieJerry newbieJerry force-pushed the feature/support_skip_create_image branch from 58f7eeb to 52ed287 Compare December 17, 2022 06:32
@newbieJerry newbieJerry reopened this Dec 17, 2022
@newbieJerry
Copy link
Contributor Author

@nywilken Sorry for my novice behavior, I resubmit a PR to sign the CLA, and change the code according to your suggestion here, please review my code, thx 😄

@newbieJerry
Copy link
Contributor Author

@nywilken, would you please review this code and get this PR merged?

@newbieJerry
Copy link
Contributor Author

newbieJerry commented Jan 17, 2023

@lbajolet-hashicorp Could I trouble you to review this PR 😄?

Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

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

Hi @newbieJerry, sorry for the long wait, reviewing this now.

Aside from my comments, the code looks good to me, when you've addressed them, we can merge this PR.

Pre-approving for merge later.

.gitignore Outdated
packer-plugin-alicloud
/.idea/
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks redundant with the .idea below, is it voluntary?

Copy link
Contributor Author

@newbieJerry newbieJerry Jan 19, 2023

Choose a reason for hiding this comment

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

/.idea/ is deleted in the latest commit

@@ -117,6 +117,10 @@ const (
mediumRetryTimes = 360
)

const (
SkipCreateImage = "you set skip_create_image true"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see this constant used anywhere, is this still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, redundant constants are defined, which have been deleted in the latest commit.

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

@newbieJerry @lbajolet-hashicorp thanks for pushing this forward. This looks good to me as well. I added a commit to address the conflict with the .gitignore file. But this is good to go.

@nywilken nywilken merged commit 3c6b2be into hashicorp:main Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants