Skip to content

Refactor the state module kubernetes.py present functions to be idempotent #16

@djivey

Description

@djivey

Most of the saltext-kubernetes state module present functions replace the resource if changes are detected. Ideally the state module is idempotent to prevent unnecessary changes to resource. As it stands now, the module replaces resources i.e. deployments, services, secrets, etc. - or hard fails for things like pods which are mostly immutable after creation.

Discussion on the topic below.

assert ret.changes["kubernetes.node_label_folder"]["new"] == "absent"

Yes, that's correct.

I do not think we can do that because the state module doesn't treat resources as idempotent like typical salt present functions.

Oh, you're right. The state module .present functions are not idempotent -.-. Just comment out the assertions then, but leave them in for future improvements.

# TODO: improve checks # pylint: disable=fixme

This is a bit of a hyperbole since there are none. 😅 Idempotency is the whole point of a state module...

Originally posted by @lkubb in #11 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions