Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade: cleanup CreateWithRetry usage (opendatahub-io#1145)
* cluster: CreateWithRetry: make work for already existing object Intention of the function was to ensure that the object is created and retry in case of webhook is temporary not available. The original code lacks handling already existing object. Handling with and without webhook configurations make the things more complicated. Let's check Create() errors for different cases: If webhook enabled: - no error (err == nil) - 500 InternalError likely if webhook is not available (yet) - 403 Forbidden if webhook blocks creation (check of existance) - some problem (real error) else, if webhook disabled: - no error (err == nil) - 409 AlreadyExists if object exists - some problem (real error) Check already existing object after Create() with a call to Get(). It covers both with and without webhook configurations. Reuse the same object for Get() to avoid fetching Gvk for it. It doesn't make harm, the object structure is not used after creation. 500 InternalError is not 100% webhook problem, but consider it as a reason for retry. Fixes: e26100e ("upgrade: retry if default DSCI creation fails (opendatahub-io#1008)") Signed-off-by: Yauheni Kaliuta <[email protected]> * upgrade: cleanup CreateWithRetry usage CreateWithRetry() now checks AlreadyExists condition inside, so skip its handling. sleep() is not needed for DSCI with proper working CreateWithRetry since it is the actual point of existance of the function. Keep checking number of DSCI instances for non-webhook configuration. Basically, using CreateWithRetry for DSC is redundant from webhook unavailability point of view since it is created after DSCI which garantees working webhook. But it handles already existed object. Signed-off-by: Yauheni Kaliuta <[email protected]> --------- Signed-off-by: Yauheni Kaliuta <[email protected]>
- Loading branch information