{"id":"590271a1ca922faf","repo":"docker/cli","slug":"role-was-already-set-to-the-requested-value","errorCode":null,"errorMessage":"role was already set to the requested value","messagePattern":"role was already set to the requested value","errorType":"exception","errorClass":"errNoRoleChange","httpStatus":null,"severity":"info","filePath":"cli/command/node/update.go","lineNumber":22,"sourceCode":"package node\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"maps\"\n\n\t\"github.com/docker/cli/cli\"\n\t\"github.com/docker/cli/cli/command\"\n\t\"github.com/docker/cli/cli/command/completion\"\n\t\"github.com/docker/cli/opts\"\n\t\"github.com/moby/moby/api/types/swarm\"\n\t\"github.com/moby/moby/client\"\n\t\"github.com/spf13/cobra\"\n\t\"github.com/spf13/pflag\"\n)\n\nvar errNoRoleChange = errors.New(\"role was already set to the requested value\")\n\nfunc newUpdateCommand(dockerCLI command.Cli) *cobra.Command {\n\toptions := newNodeOptions()\n\n\tcmd := &cobra.Command{\n\t\tUse:   \"update [OPTIONS] NODE\",\n\t\tShort: \"Update a node\",\n\t\tArgs:  cli.ExactArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn runUpdate(cmd.Context(), dockerCLI, cmd.Flags(), args[0])\n\t\t},\n\t\tValidArgsFunction:     completeNodeNames(dockerCLI),\n\t\tDisableFlagsInUseLine: true,\n\t}\n\n\tflags := cmd.Flags()\n\tflags.StringVar(&options.role, flagRole, \"\", `Role of the node (\"worker\", \"manager\")`)\n\tflags.StringVar(&options.availability, flagAvailability, \"\", `Availability of the node (\"active\", \"pause\", \"drain\")`)","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/node/update.go#L4-L40","documentation":"errNoRoleChange is returned by `docker node promote`/`docker node demote` when the node already has the requested role. The promote/demote helpers detect the no-op before submitting a NodeUpdate and report it; the callers typically treat it as informational ('node is already a manager/worker') rather than a hard failure.","triggerScenarios":"`docker node promote <node>` on a node whose role is already manager, or `docker node demote <node>` on one already a worker; with multiple nodes, any node already in the target role triggers it for that node.","commonSituations":"Idempotent provisioning scripts (Ansible/cloud-init) that promote nodes on every run; retrying a promote after a partially observed failure; operating on the wrong node name.","solutions":["Treat it as a no-op success — the node is already in the desired role; check with `docker node ls` first","Make automation idempotent by checking `docker node inspect --format '{{.Spec.Role}}'` before promoting/demoting","Verify you targeted the intended node if the role was expected to differ"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker","swarm","node","promote","idempotency"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}