[bug] Metadata resourceVersion is not send on update of custom resource
Dcoutelle opened this issue · 2 comments
Dcoutelle commented
On php-K8S version 3.1.3, with a custom resource definied like this ::
<?php
namespace App\Service\Core\Kubernetes;
use RenokiCo\PhpK8s\Contracts\InteractsWithK8sCluster;
use RenokiCo\PhpK8s\Kinds\K8sResource;
use RenokiCo\PhpK8s\Traits\Resource\HasAccessModes;
use RenokiCo\PhpK8s\Traits\Resource\HasAttributes;
use RenokiCo\PhpK8s\Traits\Resource\HasEvents;
use RenokiCo\PhpK8s\Traits\Resource\HasSelector;
use RenokiCo\PhpK8s\Traits\Resource\HasSpec;
use RenokiCo\PhpK8s\Traits\Resource\HasStatus;
use RenokiCo\PhpK8s\Traits\Resource\HasStatusConditions;
use RenokiCo\PhpK8s\Traits\Resource\HasTemplate;
class SealedSecretKind extends K8sResource implements InteractsWithK8sCluster
{
use HasSelector;
use HasSpec;
use HasStatus;
use HasStatusConditions;
use HasTemplate;
/**
* The resource Kind parameter.
*
* @var string|null
*/
protected static $kind = 'SealedSecret';
/**
* The default version for the resource.
*
* @var string
*/
protected static $defaultVersion = 'bitnami.com/v1alpha1';
/**
* Wether the resource has a namespace.
*
* @var bool
*/
protected static $namespaceable = true;
}
Registered this way :
SealedSecretKind::register('sealedSecret');
On this call :
$manifest = $cluster->fromYaml($yamlManifest);
$response = $manifest->createOrUpdate();
We have a 422 Unprocessable Entity
error, because of metadata.resourceVersion
attribute missing for an update
if I add this L227 of RunsClusterOperations file this is working:
$this->attributes['metadata']['resourceVersion'] = $this->original['metadata']['resourceVersion'];
This is a very dirty fix... and i have no idea how fix this properly.
Dcoutelle commented
I confirm your fix working!
rennokki commented
I was being able to replicate the issue within the tests and fix it. Thanks for catching it. 👍
If there are any more issues, please let me know.