(CommandList children: [ (C {(set)} {(-o)} {(errexit)}) (C {(set)} {(-o)} {(nounset)}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} { (DQ (BracedVarSub token: <VSub_Name TARGET_STORAGE> suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [128 131] ) ) } {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("TARGET_STORAGE variable unset - unexpected failure"))}) (C {(exit)} {(1)}) ] spids: [-1 137] ) ] spids: [-1 151] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} { (DQ (BracedVarSub token: <VSub_Name TARGET_VERSION> suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [160 163] ) ) } {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("TARGET_VERSION variable unset - unexpected failure"))}) (C {(exit)} {(1)}) ] spids: [-1 169] ) ] spids: [-1 183] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} { (DQ (BracedVarSub token: <VSub_Name DATA_DIRECTORY> suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [192 195] ) ) } {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("DATA_DIRECTORY variable unset - unexpected failure"))}) (C {(exit)} {(1)}) ] spids: [-1 201] ) ] spids: [-1 215] ) (C {(echo)} { (DQ (CommandSubPart command_list: (CommandList children: [(C {(date)} {(Lit_Other "+") (SQ <"%Y-%m-%d %H:%M:%S">)})] ) left_token: <Left_CommandSub "$("> spids: [221 228] ) (" Detecting if migration is needed") ) } ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name TARGET_STORAGE))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (etcd2))} {(-a)} {(DQ (${ VSub_Name TARGET_STORAGE))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (etcd3))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("Not supported version of storage: ") (${ VSub_Name TARGET_STORAGE))}) (C {(exit)} {(1)}) ] spids: [-1 268] ) ] spids: [-1 285] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} { (DQ (BracedVarSub token: <VSub_Name DO_NOT_MOVE_BINARIES> suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [296 299] ) ) } {(KW_Bang "!") (Lit_Other "=")} {(DQ (true))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(cp)} {(DQ (/usr/local/bin/etcd-) (${ VSub_Name TARGET_VERSION))} {(DQ (/usr/local/bin/etcd))} ) (C {(cp)} {(DQ (/usr/local/bin/etcdctl-) (${ VSub_Name TARGET_VERSION))} {(DQ (/usr/local/bin/etcdctl))} ) ] spids: [-1 312] ) ] spids: [-1 342] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SUPPORTED_VERSIONS_STRING) op: Equal rhs: {(DQ ("2.2.1 2.3.7 3.0.17"))} spids: [354] ) ] spids: [354] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SUPPORTED_VERSIONS) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ (${ VSub_Name SUPPORTED_VERSIONS_STRING))}) (C {(tr)} {(DQ (" "))} {(DQ (EscapedLiteralPart token:<Lit_EscapedChar "\\n">))}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [360 380] ) } spids: [359] ) ] spids: [359] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:VERSION_FILE) op: Equal rhs: {(DQ (version.txt))} spids: [383] ) ] spids: [383] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CURRENT_STORAGE) op: Equal rhs: {(DQ (etcd2))} spids: [388] ) ] spids: [388] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CURRENT_VERSION) op: Equal rhs: {(DQ (2.2.1))} spids: [393] ) ] spids: [393] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-e)} {(DQ (${ VSub_Name DATA_DIRECTORY) (/) (${ VSub_Name VERSION_FILE))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:VERSION_CONTENTS) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(cat)} {(${ VSub_Name DATA_DIRECTORY) (/) (${ VSub_Name VERSION_FILE)} ) ] ) left_token: <Left_CommandSub "$("> spids: [422 432] ) ) } spids: [420] ) ] spids: [420] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CURRENT_VERSION) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$VERSION_CONTENTS")}) (C {(cut)} {(-d)} {(SQ </>)} {(-f)} {(1)}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [450 468] ) ) } spids: [448] ) ] spids: [448] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CURRENT_STORAGE) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$VERSION_CONTENTS")}) (C {(cut)} {(-d)} {(SQ </>)} {(-f)} {(2)}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [474 492] ) ) } spids: [472] ) ] spids: [472] ) ] spids: [-1 417] ) ] spids: [-1 495] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCD_DATA_PREFIX) op: Equal rhs: { (DQ (BracedVarSub token: <VSub_Name ETCD_DATA_PREFIX> suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(Lit_Slash /) (registry)}) spids: [499 504] ) ) } spids: [497] ) ] spids: [497] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-d)} {(DQ (${ VSub_Name DATA_DIRECTORY))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [(C {(mkdir)} {(-p)} {(DQ (${ VSub_Name DATA_DIRECTORY))})] spids: [-1 534] ) ] spids: [-1 547] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} { (DQ (CommandSubPart command_list: (CommandList children: [(C {(ls)} {(-A)} {(${ VSub_Name DATA_DIRECTORY)})] ) left_token: <Left_CommandSub "$("> spids: [556 564] ) ) } {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ (${ VSub_Name DATA_DIRECTORY) (" is empty - skipping migration"))}) (SimpleCommand words: [{(echo)} {(DQ (${ VSub_Name TARGET_VERSION) (/) (${ VSub_Name TARGET_STORAGE))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (${ VSub_Name DATA_DIRECTORY) (/) (${ VSub_Name VERSION_FILE))} spids: [595] ) ] ) (C {(exit)} {(0)}) ] spids: [-1 570] ) ] spids: [-1 612] ) (FuncDef name: start_etcd body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ETCD_PORT) op:Equal rhs:{(18629)} spids:[641])] spids: [641] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCD_PEER_PORT) op: Equal rhs: {(2380)} spids: [645] ) ] spids: [645] ) (Case to_match: {(DQ (${ VSub_Name DATA_DIRECTORY))} arms: [ (case_arm pat_list: [{(Lit_Other "*") (event) (Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCD_PORT) op: Equal rhs: {(18631)} spids: [670] ) ] spids: [670] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCD_PEER_PORT) op: Equal rhs: {(2381)} spids: [674] ) ] spids: [674] ) ] spids: [664 667 678 -1] ) ] spids: [653 661 681] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:ETCD_CMD) op: Equal rhs: { (DQ (BracedVarSub token: <VSub_Name ETCD> suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (usr) (Lit_Slash /) (local) (Lit_Slash /) (bin) (Lit_Slash /) (etcd-) (${ VSub_Name START_VERSION) } ) spids: [688 702] ) ) } spids: [686] ) ] spids: [684] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:ETCDCTL_CMD) op: Equal rhs: { (DQ (BracedVarSub token: <VSub_Name ETCDCTL> suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (usr) (Lit_Slash /) (local) (Lit_Slash /) (bin) (Lit_Slash /) (etcdctl-) (${ VSub_Name START_VERSION) } ) spids: [710 724] ) ) } spids: [708] ) ] spids: [706] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:API_VERSION) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(${ VSub_Name START_STORAGE)}) (C {(cut)} {(-c5-5)}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [732 744] ) ) } spids: [730] ) ] spids: [728] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name API_VERSION))} {(Lit_Other "=")} {(DQ (2))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCDCTL_CMD) op: Equal rhs: { (DQ (${ VSub_Name ETCDCTL_CMD) (" --debug --endpoint=http://127.0.0.1:") (${ VSub_Name ETCD_PORT) (" set") ) } spids: [770] ) ] spids: [770] ) ] spids: [-1 767] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCDCTL_CMD) op: Equal rhs: { (DQ (${ VSub_Name ETCDCTL_CMD) (" --endpoints=http://127.0.0.1:") (${ VSub_Name ETCD_PORT) (" put") ) } spids: [786] ) ] spids: [786] ) ] spids: [783 799] ) (Sentence child: (C {(${ VSub_Name ETCD_CMD)} {(--name) (Lit_Other "=") (DQ (etcd-) (CommandSubPart command_list: (CommandList children:[(C {(hostname)})]) left_token: <Left_CommandSub "$("> spids: [812 814] ) ) } {(--debug)} {(--data-dir) (Lit_Other "=") (${ VSub_Name DATA_DIRECTORY)} {(--listen-client-urls)} {(http) (Lit_Other ":") (//127.0.0.1) (Lit_Other ":") (${ VSub_Name ETCD_PORT)} {(--advertise-client-urls)} {(http) (Lit_Other ":") (//127.0.0.1) (Lit_Other ":") (${ VSub_Name ETCD_PORT)} {(--listen-peer-urls)} {(http) (Lit_Other ":") (//127.0.0.1) (Lit_Other ":") (${ VSub_Name ETCD_PEER_PORT)} {(--initial-advertise-peer-urls)} {(http) (Lit_Other ":") (//127.0.0.1) (Lit_Other ":") (${ VSub_Name ETCD_PEER_PORT)} ) terminator: <Op_Amp "&"> ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCD_PID) op: Equal rhs: {($ VSub_Bang "$!")} spids: [880] ) ] spids: [880] ) (ForEach iter_name: i iter_words: [ { (CommandSubPart command_list: (CommandList children:[(C {(seq)} {(240)})]) left_token: <Left_CommandSub "$("> spids: [894 898] ) } ] do_arg_iter: False body: (DoGroup children: [ (C {(sleep)} {(0.5)}) (SimpleCommand words: [ {(${ VSub_Name ETCDCTL_CMD)} {(SQ <etcd_version>)} {(${ VSub_Name START_VERSION)} ] more_env: [ (env_pair name: ETCDCTL_API val: {(DQ (${ VSub_Name API_VERSION))} spids: [909] ) ] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_QMark "$?"))} {(-eq)} {(DQ (0))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("Etcd on port ") (${ VSub_Name ETCD_PORT) (" is up."))}) (ControlFlow token: <ControlFlow_Return return> arg_word: {(0)} ) ] spids: [-1 946] ) ] spids: [-1 965] ) ] spids: [901 968] ) spids: [893 899] ) (C {(echo)} {(DQ ("Timeout while waiting for etcd on port ") (${ VSub_Name ETCD_PORT))}) (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] spids: [634] ) spids: [630 633] ) (FuncDef name: stop_etcd body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [ {(kill)} { (DQ (BracedVarSub token: <VSub_Name ETCD_PID> suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(SQ )}) spids: [1001 1004] ) ) } ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [1007] ) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[1010]) ] ) (C {(Lit_Other ":")}) ] op_id: Op_DPipe ) (AndOr children: [ (SimpleCommand words: [ {(wait)} { (DQ (BracedVarSub token: <VSub_Name ETCD_PID> suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(SQ )}) spids: [1021 1024] ) ) } ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [1027] ) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[1030]) ] ) (C {(Lit_Other ":")}) ] op_id: Op_DPipe ) ] spids: [995] ) spids: [991 994] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ATTACHLEASE) op: Equal rhs: { (DQ (BracedVarSub token: <VSub_Name ATTACHLEASE> suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (usr) (Lit_Slash /) (local) (Lit_Slash /) (bin) (Lit_Slash /) (attachlease) } ) spids: [1042 1053] ) ) } spids: [1040] ) ] spids: [1040] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ROLLBACK) op: Equal rhs: { (DQ (BracedVarSub token: <VSub_Name ROLLBACK> suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (usr) (Lit_Slash /) (local) (Lit_Slash /) (bin) (Lit_Slash /) (rollback) } ) spids: [1058 1069] ) ) } spids: [1056] ) ] spids: [1056] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BACKUP_DIR) op: Equal rhs: {(DQ (${ VSub_Name DATA_DIRECTORY) (/migration-backup))} spids: [1079] ) ] spids: [1079] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name CURRENT_VERSION))} {(Lit_Other "=")} {(DQ (2.2.1))} {(-a)} {(DQ (${ VSub_Name CURRENT_VERSION))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (${ VSub_Name TARGET_VERSION))} {(-a)} {(KW_Bang "!")} {(-d)} {(DQ (${ VSub_Name BACKUP_DIR))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("Backup etcd before starting migration"))}) (C {(mkdir)} {(${ VSub_Name BACKUP_DIR)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCDCTL_CMD) op: Equal rhs: {(DQ (/usr/local/bin/etcdctl-2.2.1))} spids: [1152] ) ] spids: [1152] ) (SimpleCommand words: [ {(${ VSub_Name ETCDCTL_CMD)} {(--debug)} {(backup)} {(--data-dir) (Lit_Other "=") (${ VSub_Name DATA_DIRECTORY)} {(--backup-dir) (Lit_Other "=") (${ VSub_Name BACKUP_DIR)} ] more_env: [(env_pair name:ETCDCTL_API val:{(2)} spids:[1158])] ) (C {(echo)} {(DQ ("Backup done in ") (${ VSub_Name BACKUP_DIR))}) ] spids: [-1 1135] ) ] spids: [-1 1193] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:SKIP_STEP) op:Equal rhs:{(true)} spids:[1220])] spids: [1220] ) (ForEach iter_name: step iter_words: [{(${ VSub_Name SUPPORTED_VERSIONS)}] do_arg_iter: False body: (DoGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name step))} {(Lit_Other "=")} {(DQ (${ VSub_Name CURRENT_VERSION))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SKIP_STEP) op: Equal rhs: {(false)} spids: [1261] ) ] spids: [1261] ) ] spids: [-1 1258] ) (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name SKIP_STEP))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (true))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:START_VERSION) op: Equal rhs: {(DQ (${ VSub_Name step))} spids: [1292] ) ] spids: [1292] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:START_STORAGE) op: Equal rhs: {(DQ (${ VSub_Name CURRENT_STORAGE))} spids: [1300] ) ] spids: [1300] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(start_etcd)})] negated:True) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("Starting etcd ") (${ VSub_Name step) (" failed"))}) (C {(exit)} {(1)}) ] spids: [-1 1315] ) ] spids: [-1 1338] ) (C {(stop_etcd)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CURRENT_VERSION) op: Equal rhs: {(${ VSub_Name step)} spids: [1348] ) ] spids: [1348] ) (SimpleCommand words: [ {(echo)} {(DQ (${ VSub_Name CURRENT_VERSION) (/) (${ VSub_Name CURRENT_STORAGE))} ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (${ VSub_Name DATA_DIRECTORY) (/) (${ VSub_Name VERSION_FILE))} spids: [1366] ) ] ) ] spids: [1265 1285] ) ] spids: [-1 1379] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(${ VSub_Name CURRENT_VERSION)}) (C {(cut)} {(-c1-2)}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [1387 1399] ) ) } {(Lit_Other "=")} {(DQ (3.))} {(-a)} {(DQ (${ VSub_Name CURRENT_VERSION))} {(Lit_Other "=")} {(DQ (${ VSub_Name step))} {(-a)} {(DQ (${ VSub_Name CURRENT_STORAGE))} {(Lit_Other "=")} {(DQ (etcd2))} {(-a)} {(DQ (${ VSub_Name TARGET_STORAGE))} {(Lit_Other "=")} {(DQ (etcd3))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("Performing etcd2 -> etcd3 migration"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:START_VERSION) op: Equal rhs: {(DQ (${ VSub_Name step))} spids: [1473] ) ] spids: [1473] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:START_STORAGE) op: Equal rhs: {(DQ (etcd3))} spids: [1481] ) ] spids: [1481] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCDCTL_CMD) op: Equal rhs: { (DQ (BracedVarSub token: <VSub_Name ETCDCTL> suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (usr) (Lit_Slash /) (local) (Lit_Slash /) (bin) (Lit_Slash /) (etcdctl-) (${ VSub_Name START_VERSION) } ) spids: [1489 1503] ) ) } spids: [1487] ) ] spids: [1487] ) (SimpleCommand words: [ {(${ VSub_Name ETCDCTL_CMD)} {(migrate)} {(--data-dir) (Lit_Other "=") (${ VSub_Name DATA_DIRECTORY)} ] more_env: [(env_pair name:ETCDCTL_API val:{(3)} spids:[1507])] ) (C {(echo)} {(DQ ("Attaching leases to TTL entries"))}) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(start_etcd)})] negated:True) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("Starting etcd ") (${ VSub_Name step) (" in v3 mode failed"))} ) (C {(exit)} {(1)}) ] spids: [-1 1549] ) ] spids: [-1 1568] ) (C {(${ VSub_Name ATTACHLEASE)} {(--etcd-address)} {(http) (Lit_Other ":") (//127.0.0.1) (Lit_Other ":") (${ VSub_Name ETCD_PORT)} {(--ttl-keys-prefix)} { (DQ (BracedVarSub token: <VSub_Name TTL_KEYS_DIRECTORY> suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(${ VSub_Name ETCD_DATA_PREFIX) (Lit_Slash /) (events)} ) spids: [1596 1604] ) ) } {(--lease-duration)} {(1h)} ) (C {(stop_etcd)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CURRENT_STORAGE) op: Equal rhs: {(DQ (etcd3))} spids: [1621] ) ] spids: [1621] ) (SimpleCommand words: [ {(echo)} {(DQ (${ VSub_Name CURRENT_VERSION) (/) (${ VSub_Name CURRENT_STORAGE))} ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (${ VSub_Name DATA_DIRECTORY) (/) (${ VSub_Name VERSION_FILE))} spids: [1639] ) ] ) ] spids: [-1 1455] ) ] spids: [-1 1652] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(${ VSub_Name CURRENT_VERSION)}) (C {(cut)} {(-c1-4)}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [1660 1672] ) ) } {(Lit_Other "=")} {(DQ (3.1.))} {(-a)} {(DQ (${ VSub_Name CURRENT_VERSION))} {(Lit_Other "=")} {(DQ (${ VSub_Name step))} {(-a)} {(DQ (${ VSub_Name CURRENT_STORAGE))} {(Lit_Other "=")} {(DQ (etcd3))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("Remove stale v2 data"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:START_VERSION) op: Equal rhs: {(DQ (${ VSub_Name step))} spids: [1736] ) ] spids: [1736] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:START_STORAGE) op: Equal rhs: {(DQ (etcd3))} spids: [1744] ) ] spids: [1744] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ETCDCTL_CMD) op: Equal rhs: { (DQ (BracedVarSub token: <VSub_Name ETCDCTL> suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (usr) (Lit_Slash /) (local) (Lit_Slash /) (bin) (Lit_Slash /) (etcdctl-) (${ VSub_Name START_VERSION) } ) spids: [1752 1766] ) ) } spids: [1750] ) ] spids: [1750] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(start_etcd)})] negated:True) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("Starting etcd ") (${ VSub_Name step) (" in v3 mode failed"))} ) (C {(exit)} {(1)}) ] spids: [-1 1777] ) ] spids: [-1 1796] ) (C {(${ VSub_Name ETCDCTL_CMD)} {(rm)} {(--recursive)} {(DQ (${ VSub_Name ETCD_DATA_PREFIX))} ) (C {(stop_etcd)}) (C {(echo)} {(DQ ("Successfully remove v2 data"))}) (C {(rm)} {(-rf)} {(DQ (${ VSub_Name BACKUP_DIR))}) ] spids: [-1 1714] ) ] spids: [-1 1843] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name CURRENT_VERSION))} {(Lit_Other "=")} {(DQ (${ VSub_Name TARGET_VERSION))} {(-a)} {(DQ (${ VSub_Name CURRENT_STORAGE))} {(Lit_Other "=")} {(DQ (${ VSub_Name TARGET_STORAGE))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [(ControlFlow token:<ControlFlow_Break break>)] spids: [-1 1883] ) ] spids: [-1 1889] ) ] spids: [1234 1891] ) spids: [1228 1232] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ (${ VSub_Name CURRENT_STORAGE))} {(Lit_Other "=")} {(DQ (etcd3))} {(-a)} {(DQ (${ VSub_Name TARGET_STORAGE))} {(Lit_Other "=")} {(DQ (etcd2))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(${ VSub_Name CURRENT_VERSION)}) (C {(cut)} {(-c1-4)}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [1944 1956] ) ) } {(KW_Bang "!") (Lit_Other "=")} {(DQ (3.0.))} {(-o)} {(DQ (${ VSub_Name TARGET_VERSION))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (2.2.1))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("etcd3 -> etcd2 downgrade is supported only between 3.0.x and 2.2.1"))} ) (ControlFlow token:<ControlFlow_Return return> arg_word:{(0)}) ] spids: [-1 1984] ) ] spids: [-1 1999] ) (C {(echo)} {(DQ ("Backup and remove all existing v2 data"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ROLLBACK_BACKUP_DIR) op: Equal rhs: {(DQ (${ VSub_Name DATA_DIRECTORY) (.bak))} spids: [2009] ) ] spids: [2009] ) (C {(rm)} {(-rf)} {(DQ (${ VSub_Name ROLLBACK_BACKUP_DIR))}) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name ROLLBACK_BACKUP_DIR))}) (C {(cp)} {(-r)} {(DQ (${ VSub_Name DATA_DIRECTORY))} {(DQ (${ VSub_Name ROLLBACK_BACKUP_DIR))} ) (C {(echo)} {(DQ ("Performing etcd3 -> etcd2 rollback"))}) (C {(${ VSub_Name ROLLBACK)} {(--data-dir)} {(DQ (${ VSub_Name DATA_DIRECTORY))}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_QMark "$?"))} {(-ne)} {(DQ (0))} {(Lit_Other "]")} ) terminator: <Op_Semi ";"> ) ] action: [(C {(echo)} {(DQ ("Rollback to etcd2 failed"))}) (C {(exit)} {(1)})] spids: [-1 2094] ) ] spids: [-1 2109] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CURRENT_STORAGE) op: Equal rhs: {(DQ (etcd2))} spids: [2112] ) ] spids: [2112] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CURRENT_VERSION) op: Equal rhs: {(DQ (2.2.1))} spids: [2118] ) ] spids: [2118] ) (SimpleCommand words: [{(echo)} {(DQ (${ VSub_Name CURRENT_VERSION) (/) (${ VSub_Name CURRENT_STORAGE))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (${ VSub_Name DATA_DIRECTORY) (/) (${ VSub_Name VERSION_FILE))} spids: [2136] ) ] ) ] spids: [-1 1936] ) ] spids: [-1 2148] ) (C {(echo)} { (DQ (CommandSubPart command_list: (CommandList children: [(C {(date)} {(Lit_Other "+") (SQ <"%Y-%m-%d %H:%M:%S">)})] ) left_token: <Left_CommandSub "$("> spids: [2154 2161] ) (" Migration finished") ) } ) ] )