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

IACS-295 Revert "Elide last applied configuration annotation when SSA is supported" #1

Merged
merged 2 commits into from
Jun 19, 2023

Conversation

kaz130
Copy link

@kaz130 kaz130 commented Jun 15, 2023

概要

https://m-pipe.atlassian.net/browse/IACS-295

last-applied-configuration を書き出さないようにするPR (pulumi#1863) をrevertしました。
deployment-workerの修正と合わせて更新してリソースが正しく更新できることを確認しています。
また、test (make test_provider) が通ることも確認しています。

@kaz130 kaz130 changed the title IACS-295 enable last applied IACS-295 Revert "Elide last applied configuration annotation when SSA is supported" Jun 15, 2023
Comment on lines -2792 to -2807
if k.serverSideApplyMode || k.supportsDryRun(config.GroupVersionKind()) {
// Skip last-applied-config annotation if the resource supports server-side apply.
return config, nil
}

// CRDs are updated using a separate mechanism, so skip the last-applied-configuration annotation, and delete it
// if it was present from a previous update.
if clients.IsCRD(config) {
// Deep copy the config before returning.
config = config.DeepCopy()

annotations := getAnnotations(config)
delete(annotations, lastAppliedConfigKey)
config.SetAnnotations(annotations)
return config, nil
}
Copy link
Author

Choose a reason for hiding this comment

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

revertした影響でメソッドから関数に変わっておりちょっと分かりづらいですが、下のwithLastAppliedConfigと比較するとannotaationの設定をスキップする部分を削除しています。

Copy link

@ta-sunaga ta-sunaga Jun 16, 2023

Choose a reason for hiding this comment

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

Revertしただけでは解決せず、以下の処理を加える必要があったということでしょうか?

annotaationの設定をスキップする部分を削除し

Copy link
Author

Choose a reason for hiding this comment

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

Revertすることで「annotationの設定をスキップする部分が削除される」という意図でした。

@ta-sunaga
Copy link

ta-sunaga commented Jun 16, 2023

d884482 について

  • Workflowを削除すると、Fork Syncする際にConflictが起きる可能性があるかと思いました。ただ、滅多にある問題ではないので気にする必要はないかもしれないです。
  • GitHub Actionを有効にしなければWorkflowがあっても問題ないと思われるので、わざわざ削除する必要もないかなと思いました。上記と同様に気にする程の問題でもないです。

@ta-sunaga
Copy link

ta-sunaga commented Jun 16, 2023

d4b1caf について
Revertした内容をまた戻しているように見えます。
PRとして最終的なDiffが減るようにそのような修正をしたのかと思いましたが、Revert以外にどのような修正を加えたかを正確に知りたいので、「ロジックに変更のないPRとして最終的なDiffが減るようにした部分」と「Revert以外に加えた修正」でコミットを分けて頂けるとありがたいです。
個人的には、「ロジックに変更のないPRとして最終的なDiffが減るようにした部分」は変更を追いづらくなるいらないかなと思いました。

@kaz130
Copy link
Author

kaz130 commented Jun 16, 2023

d4b1caf について

pulumi#1863 に含まれる変更の内、last-applied-configurationを書き出さないようにする変更( pulumi@e9115d9 )はrevertしたままにして、変数名と一部ロジックの修正( pulumi@87b009f )だけ中途半端にrevert前に戻そうとしてました。
それに加えて、revert時にうまくconflictが解消できていなかった部分も追加で直そうとしたせいでややこしくなってましたね。

  • d4b1caf をrevertするコミット
  • 最初にPRをrevertした時に正しくconflictを解消するために必要だったコミット
    • 本来はrevert時に削除すべきだった withLastAppliedConfig の削除

を新たに積む形で「ロジックに変更のないPRとして最終的なDiffが減るようにした部分」は削除しようと思います。

@@ -2785,39 +2788,6 @@ func (k *kubeProvider) tryServerSidePatch(
return nil, nil, false, err
}

func (k *kubeProvider) withLastAppliedConfig(config *unstructured.Unstructured) (*unstructured.Unstructured, error) {

Choose a reason for hiding this comment

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

Revert前後で修正がないので消す必要はないかと思いました。

Copy link
Author

@kaz130 kaz130 Jun 16, 2023

Choose a reason for hiding this comment

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

ここ、私がrevertするときにconflictをうまく解消できていなかったせいでややこしくなっているポイントです。

元の履歴だと以下のようになっています。
(現在)

(過去)

そのため、単純に pulumi#1863 をrevertするとconflictが発生したため、一旦は両方のwithLastAppliedConfigを残すようにconflictを解消しました。
その後、withLastAppliedConfigメソッドの方はどこからも呼び出されないため不要と判断し、CRDに関する条件分岐もろともwithLastAppliedConfigメソッドを削除したのが上記のコミットになります。

@ta-sunaga
Copy link

ta-sunaga commented Jun 16, 2023

本PRと直接関係ないですが、tagがpushされていると、どこからブランチが切ってるかが分かりやすくて良いかと思います。

@kaz130
Copy link
Author

kaz130 commented Jun 16, 2023

69a0dc1deab87a を追加で積みました。これでPRのrevert以外の要素は無くなったはずです。これでtestも通ることを確認してます。ここら辺のコミットはマージする際に一つにまとめます。
(元のPRだとCHANGELOGの変更もありますが、conflictの解消が面倒だったのでそのままにしてます。)
また、tagもpushしておきました。

Comment on lines 457 to 469
func TestDryRun(t *testing.T) {
test := baseOptions.With(integration.ProgramTestOptions{
Dir: filepath.Join("dry-run", "step1"),
EditDirs: []integration.EditDir{
{
Dir: filepath.Join("dry-run", "step2"),
Additive: true,
},
},
})
integration.ProgramTest(t, &test)
}

Choose a reason for hiding this comment

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

あまりロジック部分には関係ないですが、このテストは、pulumi@11e356e のコミットの内容には存在しないようです。
確かにRevertコマンド打つと本テストが出てきますが、これって入れるべきなんですかね...?
どういう原理でRevertで出てきているんでしょうか...

Copy link
Author

Choose a reason for hiding this comment

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

これは pulumi#1863 でテストの中に処理を追加し、その後の別の修正でテストが削除されたというコミットが積まれているみたいです。
なので pulumi#1863 だけrevertするとテストの中に追加された処理だけが中途半端に復活してしまうため、テスト全てを復活させるか、全て無かったことにするかしてconflictを解消する必要があった感じですね。今回は全て復活させましたが、sync forkする時に邪魔になりそうなので削除しておきます。

Copy link

@ta-sunaga ta-sunaga left a comment

Choose a reason for hiding this comment

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

ロジック部分のRevertには問題がないかと思いますのでApproveいたします。
Merge前に、Revertが1つのコミットになるようにして頂ければと思います。

@kaz130 kaz130 force-pushed the IACS-295-enable-last-applied branch from deab87a to 2091815 Compare June 19, 2023 02:39
@kaz130 kaz130 changed the base branch from patched to v3.25.0-patched June 19, 2023 09:21
@kaz130 kaz130 merged commit 413e190 into v3.25.0-patched Jun 19, 2023
@kaz130 kaz130 deleted the IACS-295-enable-last-applied branch June 19, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants